Skip to content

[cherry-pick] agentHost: Fix sessions stuck in progress after subagent completion - #334787

Open
vs-code-engineering[bot] wants to merge 1 commit into
release/1.136from
cherry-pick/334781
Open

[cherry-pick] agentHost: Fix sessions stuck in progress after subagent completion#334787
vs-code-engineering[bot] wants to merge 1 commit into
release/1.136from
cherry-pick/334781

Conversation

@vs-code-engineering

Copy link
Copy Markdown
Contributor

Cherry-pick of #334781 from main.

Summary

Fix completed Copilot Agent Host sessions remaining In Progress in the Agents window after a subagent follow-up finishes.

The observed SDK sequence supplies the subagent ID in hook.start.data.input.agentId for a subagentStop hook, but omits it from the hook.end envelope. Our handler only completed subagents from agentStop events with an envelope agent ID, leaving the follow-up turn active. #333999 made that stale child status visible on the parent session row.

Fix

  • Remember the subagent ID by hookInvocationId until the matching stop hook ends.
  • Reuse the existing subagent completion path and remove the correlation immediately.
  • Keep the sessions-list behavior unchanged; no polling, timeouts, or forced UI status.
  • Cover follow-up completion without an envelope agent ID, overlapping hooks, and duplicate completions that must not close a later turn.

Validation

  • Both new regression tests failed before the fix.
  • All 430 tests in copilotAgentSession.test.ts passed afterward.
  • npm run transpile-client
  • Targeted ESLint and staged hygiene (npm run precommit)
  • git diff --check

Release cherry-pick requested via ~release-cherry-pick.

Copilot AI balanced review requested due to automatic review settings September 6, 2026 10:05
@vs-code-engineering vs-code-engineering Bot added the cherry-pick-artifact Auto-generated cherry-pick PR label Sep 6, 2026

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.

🟢 Approval recommended

The focused fix is correctly guarded against duplicate completion and has comprehensive regression coverage.

Pull request overview

Fixes Agent Host sessions remaining in progress after subagent follow-up completion.

Changes:

  • Correlates subagent stop-hook starts and ends by invocation ID.
  • Adds regression coverage for missing IDs, overlapping hooks, and duplicate completions.
File summaries
File Description
copilotAgentSession.ts Completes correlated subagent stop hooks.
copilotAgentSession.test.ts Tests completion and correlation edge cases.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Balanced

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cherry-pick-artifact Auto-generated cherry-pick PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants