fix voice debug-log privacy and docs drift

omit tool arguments unless content logging is enabled
correct the remaining current tool-count references
This commit is contained in:
manjunath22466 committed 2026-10-05 05:46:47 +05:30
1 parent a697ceae40
commit ae3612a356
5 files changed
+195 -36

No files matched your search

+167 -20
View File
@@ -399,37 +399,184 @@ test('OpenAI routes answer generically when the upstream or the request fails',
assert.equal(token.body.includes('fixture-upstream-secret'), false);
});
test('the debug-log sink omits what people said unless content logging is enabled', async (t) => {
const record = {
event: 'server.event',
payload: {
type: 'conversation.item.input_audio_transcription.completed',
transcript: 'my home address is 12 Elm Street',
usage: { input_tokens: 40 },
nested: [{ type: 'input_text', text: 'call my sister' }],
},
span: { answer_text: 'Flying to Tokyo.', answer_words: 3 },
test('the debug-log sink omits what people said and tool arguments unless content logging is enabled', async (t) => {
const nestObject = (value, levels) => {
let nested = value;
for (let index = 0; index < levels; index += 1) nested = { nested };
return nested;
};
const nestArray = (value, levels) => {
let nested = value;
for (let index = 0; index < levels; index += 1) nested = [nested];
return nested;
};
const records = [
{
timestamp: '2026-10-05T00:00:00.000Z',
sessionId: 'gev-session-1',
event: 'tool.call',
status: 'active',
payload: {
name: 'analyst_query',
callId: 'call-1',
arguments: { location: '12 Elm Street', note: 'meet Alice there' },
},
},
{
timestamp: '2026-10-05T00:00:01.000Z',
sessionId: 'gev-session-1',
event: 'server.event',
status: 'active',
payload: {
type: 'response.function_call_arguments.done',
eventId: 'event-1',
responseId: 'response-1',
payload: {
type: 'response.function_call_arguments.done',
event_id: 'event-1',
response_id: 'response-1',
item_id: 'item-1',
output_index: 0,
call_id: 'call-1',
name: 'analyst_query',
arguments: '{"query":"Tokyo Station"}',
},
},
},
{
event: 'server.event',
status: 'active',
payload: {
type: 'response.audio_transcript.done',
transcript: 'my home address is 12 Elm Street',
text: 'call my sister',
delta: 'Flying to Tokyo.',
usage: { input_tokens: 40 },
},
},
{
event: 'voice.cost',
status: 'active',
payload: { delta: 17, total: 41 },
},
{
event: 'tool.call',
status: 'active',
payload: { name: 'adjust_camera_zoom', callId: 'call-2', arguments: 2 },
},
{
event: 'deep.object',
status: 'active',
payload: nestObject(
{
transcript: 'deep-object-transcript-secret',
arguments: { query: 'deep-object-argument-secret' },
},
14,
),
},
{
event: 'deep.array',
status: 'active',
payload: nestArray(
{
transcript: 'deep-array-transcript-secret',
arguments: { query: 'deep-array-argument-secret' },
},
14,
),
},
];
for (const includeContent of [false, true]) {
const sourceRoot = root(t);
const handler = createDebugLogHandler({ sourceRoot, includeContent });
const response = await request(handler, {
method: 'POST',
body: JSON.stringify(record),
});
assert.equal(response.status, 204);
for (const record of records) {
const response = await request(handler, {
method: 'POST',
body: JSON.stringify(record),
});
assert.equal(response.status, 204);
}
const logged = readFileSync(
path.join(sourceRoot, '.gev-logs/realtime-conversations.jsonl'),
'utf8',
);
assert.equal(logged.includes('Elm Street'), includeContent);
assert.equal(logged.includes('call my sister'), includeContent);
assert.equal(logged.includes('meet Alice there'), includeContent);
assert.equal(logged.includes('Tokyo Station'), includeContent);
assert.equal(logged.includes('Flying to Tokyo'), includeContent);
const parsed = JSON.parse(logged);
assert.equal(parsed.payload.usage.input_tokens, 40, 'numbers stay');
assert.equal(parsed.span.answer_words, 3);
if (!includeContent)
assert.equal(parsed.payload.transcript, '[omitted 32 chars]');
assert.equal(
logged.includes('deep-object-transcript-secret'),
includeContent,
);
assert.equal(
logged.includes('deep-object-argument-secret'),
includeContent,
);
assert.equal(
logged.includes('deep-array-transcript-secret'),
includeContent,
);
assert.equal(logged.includes('deep-array-argument-secret'), includeContent);
const [
toolCall,
serverEvent,
transcriptEvent,
numericDelta,
numericArguments,
deepObject,
deepArray,
] = logged
.split('\n')
.filter(Boolean)
.map((line) => JSON.parse(line));
assert.equal(toolCall.timestamp, records[0].timestamp);
assert.equal(toolCall.sessionId, 'gev-session-1');
assert.equal(toolCall.event, 'tool.call');
assert.equal(toolCall.status, 'active');
assert.equal(toolCall.payload.name, 'analyst_query');
assert.equal(toolCall.payload.callId, 'call-1');
assert.equal(serverEvent.payload.eventId, 'event-1');
assert.equal(serverEvent.payload.responseId, 'response-1');
assert.equal(serverEvent.payload.payload.event_id, 'event-1');
assert.equal(serverEvent.payload.payload.response_id, 'response-1');
assert.equal(serverEvent.payload.payload.item_id, 'item-1');
assert.equal(serverEvent.payload.payload.output_index, 0);
assert.equal(serverEvent.payload.payload.call_id, 'call-1');
assert.equal(serverEvent.payload.payload.name, 'analyst_query');
assert.equal(transcriptEvent.payload.usage.input_tokens, 40);
assert.equal(numericDelta.payload.delta, 17);
assert.equal(numericDelta.payload.total, 41);
if (!includeContent) {
assert.equal(toolCall.payload.arguments, '[omitted]');
assert.match(
serverEvent.payload.payload.arguments,
/^\[omitted \d+ chars\]$/,
);
assert.equal(transcriptEvent.payload.transcript, '[omitted 32 chars]');
assert.equal(transcriptEvent.payload.text, '[omitted 14 chars]');
assert.equal(transcriptEvent.payload.delta, '[omitted 16 chars]');
assert.equal(numericArguments.payload.arguments, '[omitted]');
assert.equal(
JSON.stringify(deepObject.payload).includes('[omitted: max depth]'),
true,
);
assert.equal(
JSON.stringify(deepArray.payload).includes('[omitted: max depth]'),
true,
);
} else {
assert.deepEqual(
toolCall.payload.arguments,
records[0].payload.arguments,
);
assert.equal(
serverEvent.payload.payload.arguments,
records[1].payload.payload.arguments,
);
assert.equal(numericArguments.payload.arguments, 2);
}
}
});