Skip to content

Commit deb2d4a

Browse files
authored
chat: mark streaming tool calls as skipped when request completes (#297130)
* chat: mark streaming tool calls as skipped when request completes When a steering message causes the extension to yield after handleToolStream has been received but before invokeTool is called, the streaming tool call should be marked as skipped instead of being silently deleted. - Call cancelToolCallsForRequest in CancellableRequest.dispose() to ensure streaming tool calls are marked as skipped when requests complete naturally - Update cancelToolCallsForRequest to call invocation.cancelFromStreaming() before deleting pending tool calls from the map Fixes #294224 (Commit message generated by Copilot) * tests
1 parent 1365070 commit deb2d4a

File tree

3 files changed

+7
-0
lines changed

3 files changed

+7
-0
lines changed

src/vs/workbench/contrib/chat/browser/tools/languageModelToolsService.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1150,6 +1150,7 @@ export class LanguageModelToolsService extends Disposable implements ILanguageMo
11501150
// Clean up any pending tool calls that belong to this request
11511151
for (const [toolCallId, invocation] of this._pendingToolCalls) {
11521152
if (invocation.chatRequestId === requestId) {
1153+
invocation.cancelFromStreaming(ToolConfirmKind.Skipped);
11531154
this._pendingToolCalls.delete(toolCallId);
11541155
}
11551156
}

src/vs/workbench/contrib/chat/common/chatService/chatServiceImpl.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ class CancellableRequest implements IDisposable {
7070
) { }
7171

7272
dispose() {
73+
if (this.requestId) {
74+
this.toolsService.cancelToolCallsForRequest(this.requestId);
75+
}
7376
this.cancellationTokenSource.dispose();
7477
}
7578

src/vs/workbench/contrib/chat/test/common/chatService/chatService.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ import { MockChatVariablesService } from '../mockChatVariables.js';
5050
import { IPromptsService } from '../../../common/promptSyntax/service/promptsService.js';
5151
import { MockPromptsService } from '../promptSyntax/service/mockPromptsService.js';
5252
import { CancellationToken } from '../../../../../../base/common/cancellation.js';
53+
import { ILanguageModelToolsService } from '../../../common/tools/languageModelToolsService.js';
54+
import { MockLanguageModelToolsService } from '../tools/mockLanguageModelToolsService.js';
5355

5456
const chatAgentWithUsedContextId = 'ChatProviderWithUsedContext';
5557
const chatAgentWithUsedContext: IChatAgent = {
@@ -163,6 +165,7 @@ suite('ChatService', () => {
163165
[IWorkbenchAssignmentService, new NullWorkbenchAssignmentService()],
164166
[IMcpService, new TestMcpService()],
165167
[IPromptsService, new MockPromptsService()],
168+
[ILanguageModelToolsService, testDisposables.add(new MockLanguageModelToolsService())]
166169
)));
167170
instantiationService.stub(IStorageService, testDisposables.add(new TestStorageService()));
168171
instantiationService.stub(IChatEntitlementService, new TestChatEntitlementService());

0 commit comments

Comments
 (0)