Adding TurnId to Tool call and API responses and error logs. (#3039)

Co-authored-by: Scott Densmore <scottdensmore@mac.com>
This commit is contained in:
uttamkanodia14
2025-07-10 00:19:30 +05:30
committed by GitHub
parent 6c12f9e0d9
commit 063481faa4
26 changed files with 289 additions and 72 deletions

View File

@@ -127,7 +127,7 @@ describe('loggers', () => {
} as unknown as Config;
it('should log a user prompt', () => {
const event = new UserPromptEvent(11, 'test-prompt');
const event = new UserPromptEvent(11, 'prompt-id-8', 'test-prompt');
logUserPrompt(mockConfig, event);
@@ -201,6 +201,7 @@ describe('loggers', () => {
const event = new ApiResponseEvent(
'test-model',
100,
'prompt-id-1',
usageData,
'test-response',
);
@@ -224,6 +225,7 @@ describe('loggers', () => {
tool_token_count: 2,
total_token_count: 0,
response_text: 'test-response',
prompt_id: 'prompt-id-1',
},
});
@@ -260,6 +262,7 @@ describe('loggers', () => {
const event = new ApiResponseEvent(
'test-model',
100,
'prompt-id-1',
usageData,
'test-response',
'test-error',
@@ -296,7 +299,11 @@ describe('loggers', () => {
} as Config;
it('should log an API request with request_text', () => {
const event = new ApiRequestEvent('test-model', 'This is a test request');
const event = new ApiRequestEvent(
'test-model',
'prompt-id-7',
'This is a test request',
);
logApiRequest(mockConfig, event);
@@ -308,12 +315,13 @@ describe('loggers', () => {
'event.timestamp': '2025-01-01T00:00:00.000Z',
model: 'test-model',
request_text: 'This is a test request',
prompt_id: 'prompt-id-7',
},
});
});
it('should log an API request without request_text', () => {
const event = new ApiRequestEvent('test-model');
const event = new ApiRequestEvent('test-model', 'prompt-id-6');
logApiRequest(mockConfig, event);
@@ -324,6 +332,7 @@ describe('loggers', () => {
'event.name': EVENT_API_REQUEST,
'event.timestamp': '2025-01-01T00:00:00.000Z',
model: 'test-model',
prompt_id: 'prompt-id-6',
},
});
});
@@ -394,6 +403,7 @@ describe('loggers', () => {
},
callId: 'test-call-id',
isClientInitiated: true,
prompt_id: 'prompt-id-1',
},
response: {
callId: 'test-call-id',
@@ -427,6 +437,7 @@ describe('loggers', () => {
duration_ms: 100,
success: true,
decision: ToolCallDecision.ACCEPT,
prompt_id: 'prompt-id-1',
},
});
@@ -455,6 +466,7 @@ describe('loggers', () => {
},
callId: 'test-call-id',
isClientInitiated: true,
prompt_id: 'prompt-id-2',
},
response: {
callId: 'test-call-id',
@@ -487,6 +499,7 @@ describe('loggers', () => {
duration_ms: 100,
success: false,
decision: ToolCallDecision.REJECT,
prompt_id: 'prompt-id-2',
},
});
@@ -516,6 +529,7 @@ describe('loggers', () => {
},
callId: 'test-call-id',
isClientInitiated: true,
prompt_id: 'prompt-id-3',
},
response: {
callId: 'test-call-id',
@@ -549,6 +563,7 @@ describe('loggers', () => {
duration_ms: 100,
success: true,
decision: ToolCallDecision.MODIFY,
prompt_id: 'prompt-id-3',
},
});
@@ -578,6 +593,7 @@ describe('loggers', () => {
},
callId: 'test-call-id',
isClientInitiated: true,
prompt_id: 'prompt-id-4',
},
response: {
callId: 'test-call-id',
@@ -609,6 +625,7 @@ describe('loggers', () => {
),
duration_ms: 100,
success: true,
prompt_id: 'prompt-id-4',
},
});
@@ -638,6 +655,7 @@ describe('loggers', () => {
},
callId: 'test-call-id',
isClientInitiated: true,
prompt_id: 'prompt-id-5',
},
response: {
callId: 'test-call-id',
@@ -675,6 +693,7 @@ describe('loggers', () => {
'error.message': 'test-error',
error_type: 'test-error-type',
'error.type': 'test-error-type',
prompt_id: 'prompt-id-5',
},
});