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>
This commit is contained in:
Rob Lourens
2026-04-28 18:25:44 +00:00
committed by GitHub
co-authored by Copilot
parent fe1f660349
commit 48784ebe96
@@ -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);