mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-20 16:57:46 +00:00
[Fix Telemetry for tool calls, PR 1/n] Propagate tool reported errors via ToolCallResponseInfo and ToolResult (#5222)
This commit is contained in:
@@ -53,6 +53,7 @@ describe('Circular Reference Handling', () => {
|
||||
responseParts: [{ text: 'test result' }],
|
||||
resultDisplay: undefined,
|
||||
error: undefined, // undefined means success
|
||||
errorType: undefined,
|
||||
};
|
||||
|
||||
const mockCompletedToolCall: CompletedToolCall = {
|
||||
@@ -100,6 +101,7 @@ describe('Circular Reference Handling', () => {
|
||||
responseParts: [{ text: 'test result' }],
|
||||
resultDisplay: undefined,
|
||||
error: undefined, // undefined means success
|
||||
errorType: undefined,
|
||||
};
|
||||
|
||||
const mockCompletedToolCall: CompletedToolCall = {
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
ErroredToolCall,
|
||||
GeminiClient,
|
||||
ToolConfirmationOutcome,
|
||||
ToolErrorType,
|
||||
ToolRegistry,
|
||||
} from '../index.js';
|
||||
import { logs } from '@opentelemetry/api-logs';
|
||||
@@ -448,6 +449,7 @@ describe('loggers', () => {
|
||||
responseParts: 'test-response',
|
||||
resultDisplay: undefined,
|
||||
error: undefined,
|
||||
errorType: undefined,
|
||||
},
|
||||
tool: new EditTool(mockConfig),
|
||||
durationMs: 100,
|
||||
@@ -511,6 +513,7 @@ describe('loggers', () => {
|
||||
responseParts: 'test-response',
|
||||
resultDisplay: undefined,
|
||||
error: undefined,
|
||||
errorType: undefined,
|
||||
},
|
||||
durationMs: 100,
|
||||
outcome: ToolConfirmationOutcome.Cancel,
|
||||
@@ -574,6 +577,7 @@ describe('loggers', () => {
|
||||
responseParts: 'test-response',
|
||||
resultDisplay: undefined,
|
||||
error: undefined,
|
||||
errorType: undefined,
|
||||
},
|
||||
outcome: ToolConfirmationOutcome.ModifyWithEditor,
|
||||
tool: new EditTool(mockConfig),
|
||||
@@ -638,6 +642,7 @@ describe('loggers', () => {
|
||||
responseParts: 'test-response',
|
||||
resultDisplay: undefined,
|
||||
error: undefined,
|
||||
errorType: undefined,
|
||||
},
|
||||
tool: new EditTool(mockConfig),
|
||||
durationMs: 100,
|
||||
@@ -703,6 +708,7 @@ describe('loggers', () => {
|
||||
name: 'test-error-type',
|
||||
message: 'test-error',
|
||||
},
|
||||
errorType: ToolErrorType.UNKNOWN,
|
||||
},
|
||||
durationMs: 100,
|
||||
};
|
||||
@@ -729,8 +735,8 @@ describe('loggers', () => {
|
||||
success: false,
|
||||
error: 'test-error',
|
||||
'error.message': 'test-error',
|
||||
error_type: 'test-error-type',
|
||||
'error.type': 'test-error-type',
|
||||
error_type: ToolErrorType.UNKNOWN,
|
||||
'error.type': ToolErrorType.UNKNOWN,
|
||||
prompt_id: 'prompt-id-5',
|
||||
},
|
||||
});
|
||||
|
||||
@@ -137,7 +137,7 @@ export class ToolCallEvent {
|
||||
? getDecisionFromOutcome(call.outcome)
|
||||
: undefined;
|
||||
this.error = call.response.error?.message;
|
||||
this.error_type = call.response.error?.name;
|
||||
this.error_type = call.response.errorType;
|
||||
this.prompt_id = call.request.prompt_id;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import {
|
||||
ErroredToolCall,
|
||||
SuccessfulToolCall,
|
||||
} from '../core/coreToolScheduler.js';
|
||||
import { ToolErrorType } from '../tools/tool-error.js';
|
||||
import { Tool, ToolConfirmationOutcome } from '../tools/tools.js';
|
||||
|
||||
const createFakeCompletedToolCall = (
|
||||
@@ -54,6 +55,7 @@ const createFakeCompletedToolCall = (
|
||||
},
|
||||
},
|
||||
error: undefined,
|
||||
errorType: undefined,
|
||||
resultDisplay: 'Success!',
|
||||
},
|
||||
durationMs: duration,
|
||||
@@ -73,6 +75,7 @@ const createFakeCompletedToolCall = (
|
||||
},
|
||||
},
|
||||
error: error || new Error('Tool failed'),
|
||||
errorType: ToolErrorType.UNKNOWN,
|
||||
resultDisplay: 'Failure!',
|
||||
},
|
||||
durationMs: duration,
|
||||
|
||||
Reference in New Issue
Block a user