Skip to content

Speed up new Pi agent startup#1727

Merged
boudra merged 2 commits into
mainfrom
fix/draft-feature-model-lookup
Jun 25, 2026
Merged

Speed up new Pi agent startup#1727
boudra merged 2 commits into
mainfrom
fix/draft-feature-model-lookup

Conversation

@boudra

@boudra boudra commented Jun 25, 2026

Copy link
Copy Markdown
Collaborator

Linked issue

Closes #1541

Type of change

  • Bug fix
  • New feature (with prior issue + design alignment)
  • Refactor / code improvement
  • Docs

What does this PR do

This removes the remaining extra provider work from new-agent draft metadata lookups.

Draft feature and command listing now use only the model explicitly present in the draft config. If the UI has not resolved a model yet, the daemon returns no draft metadata instead of discovering a default model through provider catalog loading. Pi also reports an empty draft feature list directly, so Paseo does not start a throwaway Pi session just to learn there are no feature controls.

How did you verify it

  • npm run format
  • npm run lint
  • npm run typecheck
  • Pre-commit hooks ran format checks, targeted lint, and npm run typecheck
  • npx vitest run packages/server/src/server/agent/agent-manager.test.ts packages/server/src/server/agent/providers/pi/agent.test.ts --bail=1

The new tests cover the important behavior: draft features and commands with no model do not fetch the provider catalog, check availability, or create a scratch session; explicit-model draft metadata still works without default-model fetching; Pi draft features return [] without starting a Pi runtime session.

Checklist

  • One focused change. Unrelated cleanups split out.
  • npm run typecheck passes
  • npm run lint passes
  • npm run format ran (Biome)
  • UI changes include screenshots or video for every affected platform (N/A - no UI changes)
  • Tests added or updated where it made sense

@greptile-apps

greptile-apps Bot commented Jun 25, 2026

Copy link
Copy Markdown

Greptile Summary

This PR eliminates unnecessary provider catalog fetches and session creation from the draft metadata paths (listDraftCommands, listDraftFeatures). When no model is present in the draft config, both methods now return an empty array immediately rather than triggering default-model resolution through fetchCatalog. Pi's listFeatures now returns [] directly, removing the previously implicit Pi session creation just to report no feature controls.

  • normalizeConfig gains a resolveDefaultModel option (defaults to true for backward compatibility), and its default-model resolution logic is extracted into resolveDefaultModelId.
  • Both listDraftCommands and listDraftFeatures call normalizeConfig({ resolveDefaultModel: false }) and return [] before the availability check when no model is present.
  • PiRpcAgentClient.listFeatures is added, returning [] so AgentManager dispatches through client.listFeatures rather than falling through to createSession.

Confidence Score: 5/5

Safe to merge — targeted optimization with no changes to the normal agent startup flow.

All call sites of normalizeConfig that need default-model resolution keep the default behavior. The draft-listing methods return early when no model is present. Pi's listFeatures correctly short-circuits session creation. The new tests cover both the no-model and explicit-model branches with specific assertions.

No files require special attention.

Important Files Changed

Filename Overview
packages/server/src/server/agent/agent-manager.ts Adds NormalizeConfigOptions, extracts resolveDefaultModelId, and gates catalog/session work in both draft-listing methods behind resolveDefaultModel: false + early no-model return.
packages/server/src/server/agent/agent-manager.test.ts Adds four new tests covering no-model and explicit-model paths for both listDraftCommands and listDraftFeatures.
packages/server/src/server/agent/providers/pi/agent.ts Adds listFeatures returning [] directly, preventing AgentManager from falling through to createSession for Pi draft feature listing.
packages/server/src/server/agent/providers/pi/agent.test.ts Adds a single test verifying listFeatures returns [] without recording any Pi runtime launches.
docs/providers.md Appends one sentence documenting the new explicit-model-only contract for feature and command listing.

Reviews (2): Last reviewed commit: "fix(providers): avoid draft command mode..." | Re-trigger Greptile

@boudra boudra merged commit bdd9419 into main Jun 25, 2026
15 checks passed
@boudra boudra deleted the fix/draft-feature-model-lookup branch June 25, 2026 14:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: New agent takes ~30s to open — pi spawned 3x sequentially (isAvailable + listFeatures + createSession)

1 participant