Skip to content

sessions: wait for eager Agent Host creation before first send - #330575

Draft
Paul (pwang347) wants to merge 2 commits into
mainfrom
pwang347/fix-agent-host-first-send-race
Draft

sessions: wait for eager Agent Host creation before first send#330575
Paul (pwang347) wants to merge 2 commits into
mainfrom
pwang347/fix-agent-host-first-send-race

Conversation

@pwang347

Copy link
Copy Markdown
Member

Summary

  • track the complete eager Agent Host draft creation task, including workspace trust and active-client resolution
  • wait for eager createSession and its state subscription before dispatching the first request
  • preserve the existing send-time fallback when the eager precondition cannot be resolved
  • add focused provider regression tests and update the Agent Host provider spec

Failure evidence

Recent unrelated PR runs repeatedly failed macOS Electron smoke test Agents Window (local AgentHost) > Test Copilot CLI session via AgentHost:

In the failed AHP trace, the first request subscribed to the client-allocated session before the asynchronous workspace-trust check started eager creation. The host returned Session not found on backend; eager createSession then raced the handler fallback, and no chat/turnStarted was dispatched for the real prompt. A passing trace consistently completed createSession, opened the session subscription, and only then dispatched the turn.

Validation

  • npm run valid-layers-check
  • npm run typecheck-client
  • node --experimental-strip-types build/hygiene.ts src/vs/sessions/contrib/providers/agentHost/browser/baseAgentHostSessionsProvider.ts src/vs/sessions/contrib/providers/agentHost/test/browser/localAgentHostSessionsProvider.test.ts
  • git diff --check

The focused unit cases were added in localAgentHostSessionsProvider.test.ts. The current checkout's generated test output was stale because the active watch task targets a different checkout, so executable validation is delegated to PR CI and the focused Flaky Smoke Tests pipeline run.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 9dfb4b59-c716-468a-a424-b8394af3d743
Copilot AI balanced review requested due to automatic review settings August 13, 2026 00:08

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Ensures the first Agent Host request waits for eager backend creation and subscription, preventing session-not-found races.

Changes:

  • Tracks and awaits the complete eager-creation task.
  • Preserves fallback behavior and adds regression tests.
  • Updates provider lifecycle documentation.
Show a summary per file
File Description
baseAgentHostSessionsProvider.ts Tracks and awaits eager session creation.
localAgentHostSessionsProvider.test.ts Tests trust-delay ordering and fallback.
AGENT_HOST_SESSIONS_PROVIDER.md Documents the updated first-send lifecycle.

Review details

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 3/3 changed files
  • Comments generated: 1
  • Review effort level: Balanced


async waitForEagerCreate(): Promise<void> {
if (this._eagerCreateTask) {
await raceCancellationError(this._eagerCreateTask, this.cancellationToken);
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