Skip to content

perf: split agent setup into staged phases to reduce startup blocking#8746

Merged
morgmart merged 3 commits into
mainfrom
slow-goose
Apr 22, 2026
Merged

perf: split agent setup into staged phases to reduce startup blocking#8746
morgmart merged 3 commits into
mainfrom
slow-goose

Conversation

@matt2e
Copy link
Copy Markdown
Collaborator

@matt2e matt2e commented Apr 22, 2026

Summary

  • Splits agent setup into two phases: ProviderReady (fast, ~55ms) and FullyReady (after extensions load), so provider-only operations (set_model, update_provider, build_config_update, update_goose_mode) unblock as soon as the provider is initialized instead of waiting for all extensions
  • Makes phase-2 extension failures non-fatal — individual failures are logged but don't block the session since the provider is already usable
  • Extracts get_agent_or_receiver helper to deduplicate session lookup logic across get_session_agent and the new get_session_agent_provider_ready

Test plan

  • Verify new session creation still works end-to-end
  • Verify set_model / update_provider respond faster during startup (before extensions finish loading)
  • Verify extension load failures don't prevent the session from becoming usable
  • Verify on_prompt still waits for full readiness (extensions loaded)

🤖 Generated with Claude Code

matt2e and others added 3 commits April 22, 2026 14:15
setProvider was blocked for ~7s waiting for all extensions (including
failing MCPs) to finish loading, even though it only needs the provider.

Reorder spawn_agent_setup so provider initialization (~55ms) runs before
extension loading (~7s). Signal ProviderReady on the watch channel as
soon as the provider and goose-mode are set, then continue loading
extensions in the background. update_provider now uses the new
get_session_agent_provider_ready() which returns at ProviderReady,
while on_prompt and other extension-dependent callers still wait for
FullyReady.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…cking

Address code review feedback on the staged ProviderReady/FullyReady
agent setup:

- Phase-2 (extension loading) failures no longer overwrite the watch
  channel with Err. Since extension failures are non-fatal (individual
  failures are already logged as warnings), always send FullyReady so
  late callers to get_session_agent_provider_ready aren't incorrectly
  rejected.

- Promote AgentHandle to Ready and apply pending_working_dir even when
  phase 2 errors, preventing the session from being bricked when
  extensions fail but the provider works fine.

- Hoist Config::new before the phase split so both phases share a
  single config read instead of redundant file I/O.

- Switch on_set_model and on_set_mode to use
  get_session_agent_provider_ready since they only touch the provider
  and goose_mode (both initialized in phase 1), giving the same
  latency win as update_provider during startup.

Signed-off-by: Matt Toohey <contact@matttoohey.com>
… in build_config_update

Address remaining code review feedback on the staged ProviderReady/FullyReady
agent setup:

- Extract get_agent_or_receiver() to deduplicate the session-lookup and
  AgentHandle matching logic shared by get_session_agent and
  get_session_agent_provider_ready. The helper returns Either<Agent, Receiver>
  so each caller only implements its own wait predicate.

- Switch build_config_update from get_session_agent (FullyReady) to
  get_session_agent_provider_ready, since it only reads agent.provider()
  and agent.goose_mode() — both initialized in phase 1. This prevents
  build_config_update (called by set_config_option and its background
  refresh) from blocking on extension loading during startup.

Signed-off-by: Matt Toohey <contact@matttoohey.com>
@morgmart morgmart added this pull request to the merge queue Apr 22, 2026
Merged via the queue into main with commit 37bd4e7 Apr 22, 2026
21 checks passed
@morgmart morgmart deleted the slow-goose branch April 22, 2026 14:04
lifeizhou-ap added a commit that referenced this pull request Apr 23, 2026
* main:
  fix: preprompt would show after loading session (#8744)
  commands to acp+ migration: extensions management (#8733)
  feat: desktop notification when goose finishes a task (#8647)
  harden code review skill for async state and default-resolution bugs (#8740)
  Feature/at agent mention (#8571)
  fix: removed hardcoded dependency of goose-acp-macro (#8753)
  perf: split agent setup into staged phases to reduce startup blocking (#8746)
  Add /skills command (#8600)
  Replace deprecated Claude ACP package links (#8625)
lifeizhou-ap added a commit that referenced this pull request Apr 23, 2026
* main: (34 commits)
  fix(goose-server): cache TLS cert to disk to avoid slow startup on first launch (#8174)
  feat: add Exa AI-powered search tool (#8487)
  fix: preprompt would show after loading session (#8744)
  commands to acp+ migration: extensions management (#8733)
  feat: desktop notification when goose finishes a task (#8647)
  harden code review skill for async state and default-resolution bugs (#8740)
  Feature/at agent mention (#8571)
  fix: removed hardcoded dependency of goose-acp-macro (#8753)
  perf: split agent setup into staged phases to reduce startup blocking (#8746)
  Add /skills command (#8600)
  Replace deprecated Claude ACP package links (#8625)
  removed the specific code owner for documentation change (#8749)
  fix(providers): handle missing delta field in streaming chunks (#8700)
  refactor(providers): extract http_status module and rename handle_status_openai_compat (#8620)
  fix(providers/openai): accept streaming chunks with both reasoning fields (#8715)
  feat: associate threads with projects (#8745)
  upgrade goose sdk and tui to be compatible with the latest agentclientprotocol/sdk package (#8667)
  feat: extend goose2 context window ux with auto-compaction (#8721)
  improve goose2 agent management flows (#8737)
  alexhancock/tui-improvements (#8736)
  ...
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.

2 participants