-
Notifications
You must be signed in to change notification settings - Fork 210
Description
Describe the bug
When using gemini-3-flash-preview model with function calling, the API returns a 400 error:
Function call is missing a thought_signature in functionCall parts. This is required for tools to work correctly, and missing thought_signature may lead to degraded
model performance. Additional data, function call `default_api:getData`, position 3. Please refer to https://ai.google.dev/gemini-api/docs/thought-signatures for
more details.
Relevant log output
[ERROR] Voice session error {"error":{"type":"error","errorName":"APIConnectionError","errorMessage":"Google LLM: API error - {"error":{"message":"{\n \"error\": {\n \"code\": 400,\n \"message\": \"Function call is missing a thought_signature in functionCall parts. This is required for tools to work correctly, and missing thought_signature may lead to degraded model performance. Additional data, function call default_api:getData , position 3. Please refer to https://ai.google.dev/gemini-api/docs/thought-signatures for more details.\",\n \"status\": \"INVALID_ARGUMENT\"\n }\n}\n","code":400,"status":"Bad Request"}}","errorBody":null,"errorStack":"APIConnectionError: Google LLM: API error - {"error":{"message":"{\n \"error\": {\n \"code\": 400,\n \"message\": \"Function call is missing a thought_signature in functionCall parts. This is required for tools to work correctly, and missing thought_signature may lead to degraded model performance. Additional data, function call default_api:getData , position 3. Please refer to https://ai.google.dev/gemini-api/docs/thought-signatures for more details.\",\n \"status\": \"INVALID_ARGUMENT\"\n }\n}\n","code":400,"status":"Bad Request"}}\n at LLMStream.run (/home/tc/Documents/Sophiie/monorepo/node_modules/.pnpm/@livekit+agents-plugin-google@1.0.27_@livekit+agents@1.0.27_@livekit+rtc-node@0.13.22_z_04e2ee7e5bb94832599d6115b14964a6/node_modules/@livekit/agents-plugin-google/src/llm.ts:432:13)\n at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n at async tracer.startActiveSpan.name (/home/tc/Documents/Sophiie/monorepo/node_modules/.pnpm/@livekit+agents@1.0.27_@livekit+rtc-node@0.13.22_zod@4.1.13/node_modules/@livekit/agents/src/llm/llm.ts:151:22)\n at async (/home/tc/Documents/Sophiie/monorepo/node_modules/.pnpm/@livekit+agents@1.0.27_@livekit+rtc-node@0.13.22_zod@4.1.13/node_modules/@livekit/agents/src/telemetry/traces.ts:109:16)\n at async DynamicTracer.startActiveSpan (/home/tc/Documents/Sophiie/monorepo/node_modules/.pnpm/@livekit+agents@1.0.27_@livekit+rtc-node@0.13.22_zod@4.1.13/node_modules/@livekit/agents/src/telemetry/traces.ts:107:12)\n at async LLMStream.mainTaskImpl (/home/tc/Documents/Sophiie/monorepo/node_modules/.pnpm/@livekit+agents@1.0.27@livekit+rtc-node@0.13.22_zod@4.1.13/node_modules/@livekit/agents/src/llm/llm.ts:147:16)\n at async (/home/tc/Documents/Sophiie/monorepo/node_modules/.pnpm/@livekit+agents@1.0.27_@livekit+rtc-node@0.13.22_zod@4.1.13/node_modules/@livekit/agents/src/telemetry/traces.ts:109:16)\n at async DynamicTracer.startActiveSpan (/home/tc/Documents/Sophiie/monorepo/node_modules/.pnpm/@livekit+agents@1.0.27_@livekit+rtc-node@0.13.22_zod@4.1.13/node_modules/@livekit/agents/src/telemetry/traces.ts:107:12)","retryable":true,"fullError":"{"stack":"APIConnectionError: Google LLM: API error - {\"error\":{\"message\":\"{\\n \\\"error\\\": {\\n \\\"code\\\": 400,\\n \\\"message\\\": \\\"Function call is missing a thought_signature in functionCall parts. This is required for tools to work correctly, and missing thought_signature may lead to degraded model performance. Additional data, function call default_api:getData , position 3. Please refer to https://ai.google.dev/gemini-api/docs/thought-signatures for more details.\\\",\\n \\\"status\\\": \\\"INVALID_ARGUMENT\\\"\\n }\\n}\\n\",\"code\":400,\"status\":\"Bad Request\"}}\n at LLMStream.run (/home/tc/Documents/Sophiie/monorepo/node_modules/.pnpm/@livekit+agents-plugin-google@1.0.27_@livekit+agents@1.0.27_@livekit+rtc-node@0.13.22_z_04e2ee7e5bb94832599d6115b14964a6/node_modules/@livekit/agents-plugin-google/src/llm.ts:432:13)\n at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n at async tracer.startActiveSpan.name (/home/tc/Documents/Sophiie/monorepo/node_modules/.pnpm/@livekit+agents@1.0.27_@livekit+rtc-node@0.13.22_zod@4.1.13/node_modules/@livekit/agents/src/llm/llm.ts:151:22)\n at async (/home/tc/Documents/Sophiie/monorepo/node_modules/.pnpm/@livekit+agents@1.0.27_@livekit+rtc-node@0.13.22_zod@4.1.13/node_modules/@livekit/agents/src/telemetry/traces.ts:109:16)\n at async DynamicTracer.startActiveSpan (/home/tc/Documents/Sophiie/monorepo/node_modules/.pnpm/@livekit+agents@1.0.27_@livekit+rtc-node@0.13.22_zod@4.1.13/node_modules/@livekit/agents/src/telemetry/traces.ts:107:12)\n at async LLMStream.mainTaskImpl (/home/tc/Documents/Sophiie/monorepo/node_modules/.pnpm/@livekit+agents@1.0.27@livekit+rtc-node@0.13.22_zod@4.1.13/node_modules/@livekit/agents/src/llm/llm.ts:147:16)\n at async (/home/tc/Documents/Sophiie/monorepo/node_modules/.pnpm/@livekit+agents@1.0.27_@livekit+rtc-node@0.13.22_zod@4.1.13/node_modules/@livekit/agents/src/telemetry/traces.ts:109:16)\n at async DynamicTracer.startActiveSpan (/home/tc/Documents/Sophiie/monorepo/node_modules/.pnpm/@livekit+agents@1.0.27_@livekit+rtc-node@0.13.22_zod@4.1.13/node_modules/@livekit/agents/src/telemetry/traces.ts:107:12)","message":"Google LLM: API error - {\"error\":{\"message\":\"{\\n \\\"error\\\": {\\n \\\"code\\\": 400,\\n \\\"message\\\": \\\"Function call is missing a thought_signature in functionCall parts. This is required for tools to work correctly, and missing thought_signature may lead to degraded model performance. Additional data, function call default_api:getData , position 3. Please refer to https://ai.google.dev/gemini-api/docs/thought-signatures for more details.\\\",\\n \\\"status\\\": \\\"INVALID_ARGUMENT\\\"\\n }\\n}\\n\",\"code\":400,\"status\":\"Bad Request\"}}","body":null,"retryable":true,"name":"APIConnectionError"}","fullEvent":"{"type":"error","error":{"body":null,"retryable":true,"name":"APIConnectionError"},"source":{"_events":{},"_eventsCount":2},"createdAt":1766025947764}"}}
Describe your environment
@livekit/agents-plugin-google: 1.0.27@livekit/agents: 1.0.27- Node.js: 22.x
Minimal reproducible example
import * as google from '@livekit/agents-plugin-google';
const llm = new google.LLM({
apiKey: process.env.GEMINI_API_KEY,
model: "gemini-3-flash-preview",
temperature: 0.7,
});
// Use with AgentSession and tools - fails after first tool callExpected Behavior
Function calling should work with Gemini 3 models, preserving and returning thought_signature as required by the API.
Actual Behavior
First LLM response works, but after a tool is called and the result is sent back, the API returns a 400 INVALID_ARGUMENT error about missing thought_signature.
Root Cause
Gemini 3 models require thought signatures to be preserved and passed back during function calling
conversations. From the docs:
"When using Gemini 3 models, you must pass back thought signatures during function calling, otherwise you will get a validation error."
The plugin needs to:
- Extract
thought_signaturefrom function call parts in the model response - Include the signature when sending function results back to the model
Additional information
No response