Skip to content

agentHost: release edit timing correlations when turns end - #335585

Draft
Aaron Munger (amunger) wants to merge 3 commits into
mainfrom
aamunger/agent-host-turn-correlation-lifetime
Draft

agentHost: release edit timing correlations when turns end#335585
Aaron Munger (amunger) wants to merge 3 commits into
mainfrom
aamunger/agent-host-turn-correlation-lifetime

Conversation

@amunger

Copy link
Copy Markdown
Collaborator

What and why

Stop long-lived Copilot sessions from retaining the SDK turn and interaction IDs of every completed host turn. This follows up on the performance review comment on #331983.

Previously, these string-to-string correlations remained in session-level maps after their host turn ended. They now belong to the active CopilotTurn and are cleared on disposal, covering completion, cancellation, failure, discard, replacement, and session teardown without scanning historical entries.

Routing behavior

A delayed model-call event for a completed turn is now dropped by the provider rather than forwarded with the old turn ID for downstream rejection. An unknown interaction ID never falls back to a reused SDK turn ID. Steering transfers the active SDK-turn association to the promoted turn, and SDK assistant.turn_end alone does not expire correlations while the host turn is still active.

Regression coverage checks retained-key counts over repeated turns, terminal paths, steering telemetry, and late-event routing. This addresses unnecessary ID retention; it does not claim a measured user-visible performance improvement.

Release completed-turn SDK and interaction IDs instead of retaining them for the lifetime of a Copilot session. Keep steering and late-event routing safe through turn-owned correlation sets.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings September 10, 2026 22:48
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

🔵 Needs a closer look

Stale SDK turn IDs must be invalidated on host-turn teardown before approval.

Review tier: Lite
Findings: None

What changed in this PR

This pull request moves SDK turn and interaction correlations onto active CopilotTurn instances and releases them when host turns end.

Changes:

  • Adds per-turn correlation storage and cleanup.
  • Updates steering and late-event routing.
  • Adds regression coverage for lifecycle cleanup and delayed events.

A moderate issue remains: teardown paths can leave a stale SDK turn ID that is copied during later steering promotion, misrouting a delayed model-call event.

File Description
src/​vs/​platform/​agentHost/​test/​node/​copilotAgentSession.test.ts Tests cleanup, steering, and delayed-event behavior.
src/​vs/​platform/​agentHost/​node/​copilot/​copilotAgentSession.ts Implements per-turn correlation storage, cleanup, steering transfer, and routing.

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

Keep steering from inheriting an SDK turn ID left behind by an earlier completed, failed, aborted, discarded, or replaced host turn.

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

Copy link
Copy Markdown
Collaborator Author

Addressed the review's stale SDK-turn concern in 478aaf6. The active SDK-turn ID now belongs to CopilotTurn as well, and steering transfers it only from the current host turn. Completion, cancellation, failure, discard, and replacement can no longer leave an old ID for a later turn to inherit.

All five regression cases failed before this fix and pass afterward. The three targeted unit suites now pass 716 tests; the two subagent scenarios that failed in macOS CI also pass locally with runtime 1.0.84-4. The macOS failure's root cause remains unconfirmed; no subagent lifecycle changes, timeout increases, or weakened assertions were made to mask it.

[comment authored by copilot]

@github-actions

Copy link
Copy Markdown
Contributor

Screenshot Changes

Base: 0ac867d1 Current: c30e8285

Changed (11)

editor/multiDiffEditor/variants/noCards/MultiFile/Dark
Before After
before after
editor/multiDiffEditor/variants/noCards/NarrowInlineRename/Dark
Before After
before after
editor/multiDiffEditor/variants/noCards/StickyHorizontalOverflow/Dark
Before After
before after
editor/multiDiffEditor/variants/noCards/AddedDeletedBinary/Dark
Before After
before after
editor/multiDiffEditor/variants/noCards/LongHiddenRegionsWithBreadcrumbs/Dark
Before After
before after
editor/multiDiff/multiDiffEditorScroll/RealWidget/Dark
Before After
before after
editor/multiDiff/multiDiffEditorScroll/RealWidget/Light
Before After
before after
peekReference/PeekReferences/Dark
Before After
before after
peekReference/PeekReferences/Light
Before After
before after
imageCarousel/imageCarousel/SingleSection/Light
Before After
before after
imageCarousel/imageCarousel/SingleSectionMiddleImage/Light
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