diff --git a/.changeset/cuddly-parrots-hug.md b/.changeset/cuddly-parrots-hug.md new file mode 100644 index 000000000..dae7a7f36 --- /dev/null +++ b/.changeset/cuddly-parrots-hug.md @@ -0,0 +1,5 @@ +--- +"@livekit/agents": patch +--- + +fix(generation): preserve LLM-supplied call_id instead of overwriting with item id diff --git a/agents/src/voice/generation.ts b/agents/src/voice/generation.ts index 3d938abdc..d0dea2b27 100644 --- a/agents/src/voice/generation.ts +++ b/agents/src/voice/generation.ts @@ -539,7 +539,8 @@ export function performLLMInference( if (tool.type !== 'function_call') continue; const toolCall = FunctionCall.create({ - callId: `${data.id}/fnc_${data.generatedToolCalls.length}`, + id: `${data.id}/fnc_${data.generatedToolCalls.length}`, + callId: tool.callId, name: tool.name, args: tool.args, // Preserve thought signature for Gemini 3+ thinking mode diff --git a/examples/src/testing/basic_task_group.test.ts b/examples/src/testing/basic_task_group.test.ts index afbc7400e..07931279b 100644 --- a/examples/src/testing/basic_task_group.test.ts +++ b/examples/src/testing/basic_task_group.test.ts @@ -436,7 +436,28 @@ describe('basic_task_group', { timeout: 120_000 }, () => { toolCalls: [{ name: 'save_email', args: { email: 'charlie@test.com' } }], }, { - input: 'Conversation to summarize:\n\nuser: My name is Charlie.\nuser: charlie@test.com', + input: [ + 'Conversation to summarize:', + '', + '', + 'My name is Charlie.', + '', + '', + '{"name":"Charlie"}', + '', + '', + '"Saved name: Charlie"', + '', + '', + 'charlie@test.com', + '', + '', + '{"email":"charlie@test.com"}', + '', + '', + '"Saved email: charlie@test.com"', + '', + ].join('\n'), content: 'Summary: name=Charlie, email=charlie@test.com.', }, ]); @@ -461,7 +482,7 @@ describe('basic_task_group', { timeout: 120_000 }, () => { ); expect(summaryMsg).toBeDefined(); if (summaryMsg && summaryMsg.type === 'message') { - expect(summaryMsg.textContent).toContain('[history summary]'); + expect(summaryMsg.textContent).toContain(''); } }); });