Skip to content

agentHost: retain client tools across nested session unsubscribe - #340894

Merged
Sandeep Somavarapu (sandy081) merged 3 commits into
mainfrom
sandy081/agents/i-pulled-latest-changes-and-check-it-again
Oct 12, 2026
Merged

Sandeep Somavarapu (sandy081) merged 3 commits into
mainfrom
sandy081/agents/i-pulled-latest-changes-and-check-it-again

Conversation

@sandy081

Copy link
Copy Markdown
Member

Summary

Fixes active-client lifecycle reconciliation when one nested session unsubscribes. The client now keeps its session-wide tool contribution while any active parent-session or sibling nested-session subscription remains across its live connections.

Explicit unsubscribe now follows the same session-level participation rule as reconnect. The active client and its orphaned calls are released only after the client has left the entire parent session. Existing nested-session tool routing, confirmation, and execution behavior remains unchanged.

Adds regressions for retention through parent, sibling, and nested-session subscriptions, plus cleanup after the last nested-session subscription is removed.

Validation

  • npm run compile — passed
  • npm run hygiene — passed
  • npm run build-fast -- --client-only — passed
  • ./scripts/test.sh --run src/vs/platform/agentHost/test/node/protocolServerHandler.test.ts --reporter dot — 253 passing, 1 pending
  • npm run typecheck-client — passed
  • npm run eslint -- src/vs/platform/agentHost/node/protocolServerHandler.ts src/vs/platform/agentHost/test/node/protocolServerHandler.test.ts — passed

Keep a client's session-wide tool contribution while any active parent or sibling nested-session subscription remains. Reconcile explicit unsubscribe with reconnect behavior without introducing exact-chat tool routing.

Co-authored-by: Copilot <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 11, 2026 02:16
@sandy081 Sandeep Somavarapu (sandy081) added this to the 1.142.0 milestone Oct 11, 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.

🟡 Changes recommended

Malformed ahp-chat subscriptions can throw during reconciliation and prevent cleanup.

1 open finding
What changed in this PR

Fixes Agent Host client-tool lifecycle reconciliation across parent and nested session subscriptions.

Changes:

  • Retains active clients while any session-related subscription remains.
  • Adds unsubscribe cleanup and retention regression tests.
File Description
protocolServerHandler.ts Reconciles client ownership at session scope.
protocolServerHandler.test.ts Tests parent, sibling, and final-unsubscribe behavior.

🧠 Review effort: Balanced


💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Avoid aborting active-client reconciliation when a retained state subscription uses a malformed ahp-chat URI.

Co-authored-by: Copilot <[email protected]>
roblourens
roblourens previously approved these changes Oct 11, 2026
Model full client departure by releasing both the nested chat and parent session subscriptions. Keep the resulting failed tool completion observable through a separate subscribed client.\n\nCo-authored-by: Copilot <[email protected]>
@sandy081
Sandeep Somavarapu (sandy081) merged commit 7151ef0 into main Oct 12, 2026
35 checks passed
@sandy081
Sandeep Somavarapu (sandy081) deleted the sandy081/agents/i-pulled-latest-changes-and-check-it-again branch October 12, 2026 08:11
@sandy081 Sandeep Somavarapu (sandy081) added the ~release-cherry-pick Trigger: cherry-pick this PR to the latest release branch label Oct 12, 2026
@vs-code-engineering vs-code-engineering Bot added release-cherry-pick Automated cherry-pick between release and main branches and removed ~release-cherry-pick Trigger: cherry-pick this PR to the latest release branch labels Oct 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-cherry-pick Automated cherry-pick between release and main branches

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants