Skip to content

Don't throw in setRequestTools when agent is gone#313068

Merged
roblourens merged 1 commit intomainfrom
agents/fix-https-github-com-microsoft-vscode-issues-312-76799622
Apr 28, 2026
Merged

Don't throw in setRequestTools when agent is gone#313068
roblourens merged 1 commit intomainfrom
agents/fix-https-github-com-microsoft-vscode-issues-312-76799622

Conversation

@roblourens
Copy link
Copy Markdown
Member

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 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.

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>
Copilot AI review requested due to automatic review settings April 28, 2026 18:04
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 setRequestTools to 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

Comment thread src/vs/workbench/contrib/chat/common/participants/chatAgents.ts
@github-actions
Copy link
Copy Markdown
Contributor

Screenshot Changes

Base: ffc280de Current: 2762dcea

Changed (1)

imageCarousel/imageCarousel/SingleSection/Dark
Before After
before after

@roblourens roblourens enabled auto-merge (squash) April 28, 2026 18:18
@roblourens roblourens merged commit 48784eb into main Apr 28, 2026
30 checks passed
@roblourens roblourens deleted the agents/fix-https-github-com-microsoft-vscode-issues-312-76799622 branch April 28, 2026 18:25
@vs-code-engineering vs-code-engineering Bot added this to the 1.119.0 milestone 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>
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.

[Error] unhandlederror-No activated agent with id "setup.vscode"

3 participants