Repository navigation
fix: add cancellation token support to ChatAgentResponseStream - #291327
Merged
Merged
Conversation
Karthik Nadig (karthiknadig)
marked this pull request as ready for review
January 28, 2026 16:47
Karthik Nadig (karthiknadig)
enabled auto-merge (squash)
January 28, 2026 16:47
left a comment
Contributor
There was a problem hiding this comment.
Pull request overview
This PR wires cancellation support into ChatAgentResponseStream so that question carousels (used by the Ask tool) respect the request cancellation token, fixing the issue where pressing Stop did not correctly stop the agent session.
Changes:
- Extended
ChatAgentResponseStreamto accept aCancellationTokenand usedraceCancellationwhen awaitingquestionCarouselanswers, so the await unblocks when the request is cancelled. - Updated
ExtHostChatAgents2.$invokeAgentto pass the request’sCancellationTokenintoChatAgentResponseStream, and to continue cleaning up any pending carousel resolvers on request completion or cancellation. - Updated
ExtHostChatSessionto adapt to the newChatAgentResponseStreamconstructor by passingCancellationToken.None, keeping chat sessions’ behavior unchanged while enabling cancellation for agent-based requests.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/vs/workbench/api/common/extHostChatSessions.ts |
Adjusts ExtHostChatSession construction and getActiveRequestStream to pass a CancellationToken (set to CancellationToken.None) into the new ChatAgentResponseStream signature. |
src/vs/workbench/api/common/extHostChatAgents2.ts |
Adds a CancellationToken parameter to ChatAgentResponseStream, uses raceCancellation in questionCarousel, and passes the request token from $invokeAgent, ensuring Ask tool question carousels are cancellable and properly cleaned up. |
Benjamin Pasero (bpasero)
approved these changes
Jan 28, 2026
roblourens
reviewed
Jan 28, 2026
| // Wait for the user to submit answers | ||
| return deferred.p; | ||
| // Wait for the user to submit answers, but respect cancellation | ||
| return raceCancellation(deferred.p, that._token); |
Member
There was a problem hiding this comment.
Why is this tool implemented in the extension when it has this tight coupling with UI? The ChatAgentResponseStream is not supposed to return a value to the caller, that's contrary to the concept of a "stream" IMO
Member
Author
There was a problem hiding this comment.
I will create an issue to move this into main and get rid of this part.
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
fixes: #291295