Don't throw in setRequestTools when agent is gone#313068
Merged
roblourens merged 1 commit intomainfrom Apr 28, 2026
Merged
Conversation
Fixes #312803 The autorun in chatServiceImpl that calls setRequestTools is per-request and can fire after the target agent has been unregistered (e.g., setup.vscode is disposed when Copilot setup completes while a request is still in-flight). Throwing here surfaces as an unhandled error from inside the autorun. Match the existing pattern used by setYieldRequested and getFollowups in the same file and silently return. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Prevents an unhandled error in the chat request lifecycle by making ChatAgentService.setRequestTools gracefully no-op when the target agent has been disposed/unregistered, matching the existing behavior of similar per-request updates in the chat pipeline.
Changes:
- Change
setRequestToolsto return silently when the agent implementation is missing (instead of throwing). - Align behavior with existing patterns in the same service (e.g.,
setYieldRequested,getFollowups) to avoid lifecycle-race crashes.
Show a summary per file
| File | Description |
|---|---|
src/vs/workbench/contrib/chat/common/participants/chatAgents.ts |
Avoid throwing from setRequestTools when the agent implementation is no longer available, preventing unhandled autorun errors. |
Copilot's findings
- Files reviewed: 1/1 changed files
- Comments generated: 1
Contributor
anthonykim1
approved these changes
Apr 28, 2026
cwebster-99
pushed a commit
that referenced
this pull request
Apr 28, 2026
Fixes #312803 The autorun in chatServiceImpl that calls setRequestTools is per-request and can fire after the target agent has been unregistered (e.g., setup.vscode is disposed when Copilot setup completes while a request is still in-flight). Throwing here surfaces as an unhandled error from inside the autorun. Match the existing pattern used by setYieldRequested and getFollowups in the same file and silently return. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Fixes #312803
The
autoruninchatServiceImplthat callssetRequestToolsis per-request and can fire after the target agent has been unregistered (e.g.,setup.vscodeis disposed when Copilot setup completes while a request is still in-flight). Throwing here surfaces as an unhandled error from inside the autorun.Match the existing pattern used by
setYieldRequestedandgetFollowupsin the same file and silently return when the agent is no longer registered.There's only one caller of
setRequestTools(chatServiceImpl.ts:1266) and it always passes the id of an agent it just successfully invoked, so the throw was never catching real misuse — only this lifecycle race.