agentHost: cancel late callbacks during abort#327427
Draft
connor4312 wants to merge 2 commits into
Draft
Conversation
Keep Copilot SDK callbacks from parking after an accepted steering message races with abort, allowing replacement turns and follow-ups to proceed. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
connor4312
enabled auto-merge (squash)
July 25, 2026 00:07
Read abort state through a method so TypeScript does not retain stale enum narrowing across awaits. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
This PR hardens the Copilot agent host against late/straggling interactive callbacks that arrive after an SDK abort begins, preventing stale-turn interactions (e.g., accepted steering) from wedging subsequent replacement turns.
Changes:
- Track an explicit “abort in progress” lifecycle and proactively cancel/deny pending interactive waits during abort.
- Reject interactive/tool callbacks that arrive while abort is in progress, until the session becomes idle again.
- Add focused unit coverage for abort-time cancellation plus a record-only E2E scenario for “steering then abort then replacement turn”.
Show a summary per file
| File | Description |
|---|---|
| src/vs/platform/agentHost/test/node/e2e/providers/copilotAgentHostE2E.integrationTest.ts | Adds a record-only E2E test validating steering + abort doesn’t block a replacement turn. |
| src/vs/platform/agentHost/test/node/e2e/KNOWN_ISSUES.md | Documents why abort-related tests are record-only under deterministic replay. |
| src/vs/platform/agentHost/test/node/copilotAgentSession.test.ts | Adds unit coverage verifying interactive callbacks are cancelled/denied while abort is in progress. |
| src/vs/platform/agentHost/node/copilot/copilotAgentSession.ts | Implements abort lifecycle tracking and cancels/denies interactive waits + rejects late callbacks during abort. |
Review details
- Files reviewed: 4/4 changed files
- Comments generated: 3
- Review effort level: Low
Comment on lines
1543
to
1545
| // call `resetTurnState` just before `send()`; this covers the | ||
| // direct-send path and is a no-op when the turn already exists. | ||
| this.resetTurnState(turnId, senderClientId); |
Comment on lines
+1103
to
+1105
| if (this._abortState === CopilotAbortState.Aborting) { | ||
| return this._toolSearchFailure('Tool call cancelled: session is aborting'); | ||
| } |
Comment on lines
2183
to
2186
| const toolCallId = request.toolCallId; | ||
| if (!toolCallId) { | ||
| // TODO: handle permission requests without a toolCallId by creating a synthetic tool call | ||
| this._logService.warn(`[Copilot:${this.sessionId}] Permission request without toolCallId, auto-denying: kind=${request.kind}`); |
connor4312
disabled auto-merge
July 25, 2026 00:28
connor4312
marked this pull request as draft
July 25, 2026 00:28
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Context
Agent Host debug logs showed an accepted steering message being echoed and executed by the SDK after its protocol turn was cancelled. Agent Host had already cleared the steering correlation and advanced to a replacement turn, causing SDK tool actions to retain stale turn identity. A later permission request was not visible in synchronized UI state and blocked all follow-up work.
Validation
copilotAgentSession.test.tsabort callback testsThe pre-commit hook could not find
npmin this environment, so it skipped the package precommit command; the equivalent targeted hygiene checks were run manually.