Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions packages/core/src/core/coreToolScheduler.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12705,7 +12705,7 @@ describe('CoreToolScheduler telemetry spans', () => {
expect(responseText).not.toContain('had already completed');
});

it('tells the model a post-completion cancellation discarded finished work', async () => {
it('tells the model a post-completion cancellation was user-directed and should stop', async () => {
const abortController = new AbortController();
const { completedCalls } = await runSingleTool({
abortController,
Expand All @@ -12719,8 +12719,9 @@ describe('CoreToolScheduler telemetry spans', () => {
expect(completedCall.status).toBe('cancelled');
expect(completedCall.response.executionStatus).toBe('cancelled');
const responseText = JSON.stringify(completedCall.response.responseParts);
expect(responseText).toContain('The tool had already completed');
expect(responseText).not.toContain('User cancelled tool execution.');
expect(responseText).toContain('User intentionally cancelled');
expect(responseText).toContain('Stop and await further instructions');
expect(responseText).toContain('discarded');
});

// A post-execution cancellation drops the model-visible output, but the
Expand Down
4 changes: 3 additions & 1 deletion packages/core/src/core/coreToolScheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,9 @@ const TOOL_SPAN_STATUS_TOOL_TIMEOUT = 'Tool execution timed out';
const TOOL_CANCELLED_BEFORE_COMPLETION_MESSAGE =
'User cancelled tool execution.';
const TOOL_CANCELLED_AFTER_COMPLETION_MESSAGE =
'The tool had already completed; its output was discarded.';
'User intentionally cancelled this tool call after it completed. ' +
'Its output was discarded. Stop and await further instructions; ' +
'do not retry or work around it.';

/**
* Builds the failure ToolResult surfaced when a tool call exceeds the
Expand Down
Loading