agentHost: Fix sessions stuck in progress after subagent completion - #334781
Merged
Benjamin Christopher Simmonds (benibenj) merged 2 commits intoSep 6, 2026
Merged
Conversation
Match subagent stop hooks by invocation ID when the SDK provides the agent identity only in the start event input. Reuse the existing completion path so finished follow-up turns do not keep the session in progress. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Benjamin Christopher Simmonds (benibenj)
enabled auto-merge (squash)
September 6, 2026 08:51
Copilot started reviewing on behalf of
Benjamin Christopher Simmonds (benibenj)
September 6, 2026 08:52
View session
Contributor
|
This PR will be automatically cherry-picked to |
Contributor
There was a problem hiding this comment.
Copilot review overview
🟢 Approval recommended
The focused implementation handles the reported event sequence and includes appropriate regression coverage.
Review tier: Balanced
Findings: None
What changed in this PR
Fixes stale In Progress state by correlating subagent stop hook events.
Changes:
- Tracks subagent IDs across matching stop hooks.
- Completes resumed subagent turns without envelope IDs.
- Adds regression coverage for overlapping and duplicate events.
| File | Description |
|---|---|
copilotAgentSession.ts |
Correlates stop hooks and completes subagent turns. |
copilotAgentSession.test.ts |
Tests missing IDs, overlapping hooks, and duplicates. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Dmitriy Vasyura (dmitrivMS)
previously approved these changes
Sep 6, 2026
Fix the Compile & Hygiene failure by checking that SDK hook input is a non-null, non-array object before reading agentId. Cover missing, primitive, array, and non-string inputs. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Dmitriy Vasyura (dmitrivMS)
approved these changes
Sep 6, 2026
Benjamin Christopher Simmonds (benibenj)
merged commit Sep 6, 2026
814ab13
into
main
50 of 51 checks passed
Benjamin Christopher Simmonds (benibenj)
deleted the
benibenj/agents/fix-session-status-regression
branch
September 6, 2026 10:04
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.agentIdfor asubagentStophook, but omits it from thehook.endenvelope. Our handler only completed subagents fromagentStopevents with an envelope agent ID, leaving the follow-up turn active. #333999 made that stale child status visible on the parent session row.Fix
hookInvocationIduntil the matching stop hook ends.Validation
copilotAgentSession.test.tspassed afterward.npm run transpile-clientnpm run precommit)git diff --checkRelease cherry-pick requested via
~release-cherry-pick.