Skip to content

agentHost: Reconcile retained-child status after stale reads - #335979

Draft
Dmitriy Vasyura (dmitrivMS) wants to merge 3 commits into
mainfrom
agents/retained-child-state-fix-validation
Draft

Dmitriy Vasyura (dmitrivMS) wants to merge 3 commits into
mainfrom
agents/retained-child-state-fix-validation

Conversation

@dmitrivMS

@dmitrivMS Dmitriy Vasyura (dmitrivMS) commented Sep 12, 2026

Copy link
Copy Markdown
Collaborator

Summary

Fix retained subagents staying active when a resume invalidates an in-flight task-status read.

  • Capture freshness at RPC start and coalesce trailing refreshes, guarding against stale results, cancellation and disposal.
  • Clear aborted-root-owned child activity and usage before reuse, preserving stable routing and unrelated background children.
  • Add deterministic race/accounting regressions and better E2E failure diagnostics. No polling, retry-count, fixture or snapshot changes.

Related to #335458. Duplicate-child execution identity is handled separately in #335989.

Validation

  • 65 targeted unit tests passed, plus focused TypeScript, transpilation and hygiene/ESLint checks.
  • Strict tokenless Windows source-Electron retained-child E2E passed: exactly 1/2/3 completed turns, expected responses and no active child.
  • Separate temporary integration with agentHost: prevent phantom custom-subagent turns #335989 at c77343648da0: 127 selected unit tests and 4 strict replays passed. Combined code is not included here.

Capture task-status freshness when each RPC starts and drain invalidated reads through the existing single-flight scheduler. Guard completion application across resumption, cancellation and disposal, and add deterministic delayed-query regressions.

Related to #335458; child execution identity remains a separate fix.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings September 12, 2026 21:47
@dmitrivMS Dmitriy Vasyura (dmitrivMS) added vscode-build VS Code build process issues engineering VS Code - Build / issue tracking / etc. agent-host Issues for the agent-host implementation (not the protocol) labels Sep 12, 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.

Copilot review overview

🟢 Approval recommended

The scheduler changes are internally consistent and covered by targeted deterministic regressions.

Review tier: Balanced (auto)
Findings: None

Note

Copilot is running an experiment and ran this review at Balanced.

What changed in this PR

Fixes stale retained-subagent status reconciliation while improving related diagnostics and regression coverage.

Changes:

  • Reconciles invalidated status reads serially until reaching a stable revision.
  • Stops reconciliation after cancellation or disposal.
  • Adds deterministic race/lifecycle tests and richer E2E failure details.
File Description
src/​vs/​platform/​agentHost/​node/​copilot/​copilotAgentSession.ts Implements revision-aware reconciliation.
src/​vs/​platform/​agentHost/​test/​node/​copilotAgentSession.test.ts Adds race, serialization, and lifecycle tests.
src/​vs/​platform/​agentHost/​test/​node/​e2e/​suites/​subagentSuite.ts Expands retained-child diagnostics.
src/​vs/​platform/​agentHost/​test/​node/​e2e/​README.md Documents failure interpretation and coverage.

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

@github-actions

github-actions Bot commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Base: e6a2323c Current: 477d5b22

No screenshot changes.

Clear only the aborted root's active child ownership and usage through the existing silent completion cleanup before awaiting the SDK. Preserve stable routing and cancellation guards so late status replies cannot affect a reused child.

Add abort/reuse accounting regressions and explicit initial/follow-up identities in retained-child fixtures. Keep the duplicate-child ledger and combined validation overlay out of this standalone change.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

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.

Copilot review overview

🟢 Approval recommended

The concurrency and cleanup changes are narrowly scoped and covered by comprehensive deterministic regressions.

Review tier: Balanced (auto)
Findings: None

Note

Copilot is running an experiment and ran this review at Balanced.

@dmitrivMS
Dmitriy Vasyura (dmitrivMS) marked this pull request as draft September 15, 2026 08:04
auto-merge was automatically disabled September 15, 2026 08:04

Pull request was converted to draft

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

Labels

agent-host Issues for the agent-host implementation (not the protocol) engineering VS Code - Build / issue tracking / etc. vscode-build VS Code build process issues

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants