From 48784ebe96ab1bea5edad042fcdcc19b63d44905 Mon Sep 17 00:00:00 2001 From: Rob Lourens Date: Tue, 28 Apr 2026 11:25:44 -0700 Subject: [PATCH] Don't throw in setRequestTools when agent is gone (#313068) 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> --- src/vs/workbench/contrib/chat/common/participants/chatAgents.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vs/workbench/contrib/chat/common/participants/chatAgents.ts b/src/vs/workbench/contrib/chat/common/participants/chatAgents.ts index 25984d05e03..4de51aa176f 100644 --- a/src/vs/workbench/contrib/chat/common/participants/chatAgents.ts +++ b/src/vs/workbench/contrib/chat/common/participants/chatAgents.ts @@ -537,7 +537,7 @@ export class ChatAgentService extends Disposable implements IChatAgentService { setRequestTools(id: string, requestId: string, tools: UserSelectedTools): void { const data = this._agents.get(id); if (!data?.impl) { - throw new Error(`No activated agent with id "${id}"`); + return; } data.impl.setRequestTools?.(requestId, tools);