Skip to content

agentHost: Clean up disconnected client tool ownership - #336826

Draft
roblourens wants to merge 3 commits into
mainfrom
roblou/agents/bug-fix-and-regression-analysis
Draft

roblourens wants to merge 3 commits into
mainfrom
roblou/agents/bug-fix-and-regression-analysis

Conversation

@roblourens

@roblourens roblourens commented Sep 18, 2026

Copy link
Copy Markdown
Member

Summary

  • remove disconnected active clients from provider-owned tool and customization registries when the host emits its automatic removal action
  • preserve the authoring client when Copilot promotes a steering message so duplicate client tools route to the correct window
  • add unit, real-SDK, and deterministic Agent Host E2E coverage for cleanup and steering ownership

Root cause

The protocol server removed disconnected clients from synchronized session state with a server-originated session/activeClientRemoved action, but provider cleanup only ran for client-originated actions. Copilot therefore retained stale client tools and customizations internally. Steering-created turns also discarded their sender client ID, allowing duplicate client tools to fall back to the stale first-inserted owner.

Validation

  • npm run typecheck-client
  • npm run valid-layers-check
  • ESLint on all changed TypeScript files
  • affected unit suites: 779 passing
  • Copilot mock-LLM provider integration: 5 passing
  • deterministic Agent Host E2E suite, twice: 325 passing, 16 expected pending; conformance, Claude, Codex, and Copilot all passed
  • targeted new E2E and steering integration scenarios repeated independently
  • detailed Claude Opus 5 code and test reviews
  • three-platform ADO CI validation succeeded twice: 475152 and 475176

(Written by Copilot)

Remove disconnected active clients from provider-owned tool and customization registries when the host emits its automatic removal action. Preserve the authoring client when Copilot promotes a steering message so duplicate client tools remain routed to the correct window.

Add unit, real-SDK, and deterministic full-host coverage for automatic cleanup, steering attribution, and replacement tool ownership.

(Written by Copilot)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings September 18, 2026 20:05

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 functional changes are well-covered and coherent; the only finding is a minor JSDoc placement issue.

Review effort: Balanced
Findings: 1 Low severity

Open (1)
What changed in this PR

Fixes stale provider-owned client registrations after disconnects and preserves steering-message ownership for correct tool routing.

Changes:

  • Cleans up provider tools and customizations on automatic client removal.
  • Propagates steering sender identity into Copilot turns.
  • Adds unit, integration, and deterministic E2E coverage.
File Description
common/​agent.ts Extends pending-message API with sender metadata.
node/​agentSideEffects.ts Handles server-originated client removal.
node/​chatContributions/​queueDrain/​queueDrainContribution.ts Tracks steering-message sender ownership.
node/​copilot/​copilotAgent.ts Forwards sender metadata to Copilot sessions.
node/​copilot/​copilotAgentSession.ts Preserves sender identity during steering promotion.
test/​node/​mockAgent.ts Records steering sender in the mock provider.
test/​node/​agentSideEffects.test.ts Tests automatic provider cleanup and sender propagation.
test/​node/​chatContributions.test.ts Tests steering sender replacement and removal.
test/​node/​copilotAgentSession.test.ts Tests preferred steering-client tool routing.
test/​node/​providerIntegration/​copilotMockLlm.integrationTest.ts Covers steering ownership with the real Copilot SDK.
test/​node/​e2e/​suites/​mcpPluginSuite.ts Covers disconnected-client customization cleanup.
test/​node/​e2e/​suites/​copilotRuntimeToolsSuite.ts Covers duplicate tool ownership transfer.
test/​node/​e2e/​captures/​copilotcli-runtime-tools-removing-a-client-transfers-duplicate-tool-ownership-to-the-surviving-client.yaml Records deterministic model traffic for the ownership test.

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

Comment thread src/vs/platform/agentHost/common/agent.ts
roblourens and others added 2 commits September 18, 2026 14:59
Move the pending-message sender type ahead of the provider-interface JSDoc so editor and generated documentation remain attached to IAgent.

(Written by Copilot)

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

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

# Conflicts:
#	src/vs/platform/agentHost/test/node/e2e/suites/copilotRuntimeToolsSuite.ts
@github-actions

Copy link
Copy Markdown
Contributor

Screenshot Changes

Base: ee8bba4d Current: f8c55509

Changed (1)

chat/agent-lifecycle/chatAgentLifecycle/RetainedFollowUpLatestTurn/LightHighContrast
Before After
before after

2 insignificant change(s) omitted (≤20 px, Δ≤2). See CI logs for details.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants