Wait for request to be handled before disposing chat model (#296421)

This commit is contained in:
Don Jayamanne
2026-02-20 12:58:52 +11:00
committed by GitHub
parent 1c84a7ca4a
commit 603ec3dfd4
@@ -576,8 +576,16 @@ export class ChatSessionsService extends Disposable implements IChatSessionsServ
if (chatOptions) {
const resource = URI.revive(chatOptions.resource);
const ref = await chatService.loadSessionForResource(resource, ChatAgentLocation.Chat, CancellationToken.None);
await chatService.sendRequest(resource, chatOptions.prompt, { agentIdSilent: type, attachedContext: chatOptions.attachedContext });
ref?.dispose();
try {
const result = await chatService.sendRequest(resource, chatOptions.prompt, { agentIdSilent: type, attachedContext: chatOptions.attachedContext });
if (result.kind === 'queued') {
await result.deferred;
} else if (result.kind === 'sent') {
await result.data.responseCompletePromise;
}
} finally {
ref?.dispose();
}
}
}
}),