[Bug] Gemini 3.x BYOK fails with HTTP 400: missing thought_signature in functionCall
Author: evetypCreated Sep 23, 2026Updated Sep 23, 2026
Environment
- App: GenOffice Desktop (v0.10.1038)
- OS: Windows 11 x64
- AI Provider: Google Gemini (BYOK)
- Model:
gemini-3.5-flash-lite(or any Gemini 3.x model)
Describe the Bug
When using a custom Google Gemini 3.x model (e.g., gemini-3.5-flash-lite), requesting document generation tasks that trigger the default_api:write_document function call results in a Gemini HTTP 400: INVALID_ARGUMENT error.
Although the document is injected into the editor, the conversation turn fails with an error and falls back to showing "登录 Genspark".
Steps to Reproduce
- Go to Settings -> AI Models.
- Select Gemini as the provider and enter an API Key from Google AI Studio.
- Choose a Gemini 3.x model (such as
gemini-3.5-flash-lite). - In the document assistant sidebar, prompt: "帮我生成一份述职文档模板" (or any prompt that triggers
write_document). - After step 1 completes, the API returns HTTP 400.
Error Output
{
"error": {
"code": 400,
"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:write_document`, position 6. Please refer to https://ai.google.dev/gemini-api/docs/thought-signatures for more details.",
"status": "INVALID_ARGUMENT"
}
}Root Cause Analysis
In Gemini 3.x models, Google strictly enforces returning the thought_signature token that came with the model's functionCall part when sending back the conversation history:
- In
emitGeminiJsonMessage/ streaming event handler:part.thought_signature(orthoughtSignature) is received alongsidepart.functionCall, but it is not captured into the tool call metadata. - In
geminiContents(messages): When reconstructing themodelrole turn,parts.push({ functionCall: ... })does not include the correspondingthought_signature. - Reference: https://ai.google.dev/gemini-api/docs/thought-signatures
Source: genspark-ai/genoffice