agentHost: fix background subagent lifecycle and recipient labels - #337620
Conversation
Preserve reusable child routing on cancellation and settle unroutable approval requests instead of buffering indefinitely. Restore live inline subagent observations across history hydration, including reused turns and new tool approvals. Fixes #337339. Refs #335292. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Two moderate cleanup issues can retain stale child state and accumulate failed routing markers indefinitely.
Get a fresh assessment by requesting another Copilot review.
Review effort: Balanced
Findings: 2
Open (2)
What changed in this PR
Fixes background subagent reuse after cancellation and restores live inline progress when reopening chats.
Changes:
- Preserves reusable child routing while cleaning up execution state.
- Bounds orphaned startup signals and settles approvals.
- Restores live inline child tools, approvals, and resumed activity.
| File | Review |
|---|---|
src/vs/workbench/contrib/chat/test/browser/agentSessions/agentHostChatContribution.test.ts |
Tests restored inline child activity and tools. |
src/vs/workbench/contrib/chat/browser/agentSessions/agentHost/agentHostSessionHandler.ts |
Restores live subagent observation and snapshot adoption. |
src/vs/platform/agentHost/test/node/copilotAgentSession.test.ts |
Tests child reuse after cancellation. |
src/vs/platform/agentHost/test/node/agentSideEffects.test.ts |
Tests routing, buffering, approvals, and cleanup. |
src/vs/platform/agentHost/node/copilot/copilotAgentSession.ts |
Moderate (2 votes): Abort cleanup bypasses _completeSubagentTurn, retaining stale usage, model, and routing state that may be republished on reuse. |
src/vs/platform/agentHost/node/agentSideEffects.ts |
Moderate (2 votes): Failed pending-buffer markers remain indefinitely, allowing unbounded map growth across unique orphan routes. |
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Screenshot ChangesBase: Changed (2)1 insignificant change(s) omitted (≤20 px, Δ≤2). See CI logs for details. |
Retire cancelled child execution state through the existing completion cleanup so reuse cannot inherit usage or Auto routing. Bound failed routing suppression separately and release disposed signal buffers immediately. Add regression coverage for cancelled usage, late completion, failed-route eviction, scoped cleanup, and reentrant permission denial. Addresses review feedback on #337620. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Accept the CI-generated light-theme baseline for the MCP provenance fixture. The recorded difference is limited to insignificant border antialiasing. Refs #337620. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Bring in the upstream pet transition test that is failing on the PR merge before applying the focused CI stabilization. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The sprite player advances from elapsed time, so busy CI runners can legitimately skip intermediate frames. Verify both phase endpoints and reverse/forward ordering while retaining geometry, visibility, landing and focus assertions. Refs #337620. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Defer painting until the fixture is ready to avoid intermediate-paint antialiasing noise, and restore the latest CI baseline. Repeated targeted captures were stable in both themes. Refs #337620. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Addressed both selected review threads in e7fb135 (cancelled-child accounting cleanup and bounded failed-route suppression); both are resolved. Follow-up CI stabilization is pushed through 68b72bf:
Post-sync subagent validation: 909 host/provider tests and 242 focused browser tests passed; changed-file lint and commit hygiene passed. Fresh CI is green for both repaired failures:
|
Resolve agent names from lifecycle events, completion notifications and runtime task metadata in live and restored chats. Name each recipient for multi-agent writes while preserving raw routing IDs and the existing unknown-ID fallback. Validated with 880 focused tests and a live Code OSS/AHP scenario covering single-recipient writes, broadcasts and renderer reload. Refs #337620. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Keep upstream's redesigned fixture CI gating while retaining deferred painting. Preserve the subagent lifecycle and readable recipient-label changes against current upstream. Validated with client transpilation, 1,314 focused Electron tests, and targeted ESLint. Refs #337620. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Resolved the merge conflict and pushed signed merge commit 6600c55. Kept upstream’s redesigned MCP fixture gating ( Validation: client transpilation, 1,314 focused Electron tests, targeted ESLint, and commit hygiene passed. The full client type-check still reports only the two previously noted unrelated SinonFakeTimersConfig errors in unchanged test files. |

Fixes #337339
Refs #335292
Summary
The optional Subagents summary above the prompt and approval policy are unchanged.
Why
Parent cancellation removed the host's routing identity while the SDK retained the reusable agent, stranding later progress and approvals. Restored inline pills also did not reactivate idle children or append newly emitted tools. The recipient-name lookup only learned names from start events, and multi-recipient writes had no targeted display label.
Focused regressions reproduced these failures before the corresponding fixes. The inline change targets the restored/reused cases of #335292 rather than introducing another surface.
Live Copilot / AHP validation
Built with
npm run build-fastand launched through./scripts/code.shon macOS arm64 using Code OSS 1.140.0 dev, the real Copilot harness, GPT-5.4 mini, and AHP 0.9.0. No model or protocol responses were mocked.taskwithmode: "background".Write to agent Label AlphaandWrite to agents Label Alpha, Label Betain both AHP ready/completed actions and the rendered accessible chat buttons.Screenshot caption: Real background agents shown as ordinary inline subagent pills, with readable single- and multi-recipient write labels.
Automated validation
git diff --checkpassed.SinonFakeTimersConfigerrors in unchanged MCP/sticky-scroll test files; no changed-file diagnostics.deferPaintoption on the MCP provenance fixture. Code OSS and Component Fixtures passed at68b72bf3de1; CI for the new recipient-label commit is pending.Validation limits
The successful live scenario was submitted through the normal authenticated AHP endpoint and verified in the actual rendered window. An additional direct UI-send attempt was blocked by GitHub Copilot sign-in in the cloned test profile. Renderer reload was tested, not an Agent Host process restart. Notification-only name recovery is covered by automated tests.
This PR remains a draft.