#769·genoffice

[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

  1. Go to Settings -> AI Models.
  2. Select Gemini as the provider and enter an API Key from Google AI Studio.
  3. Choose a Gemini 3.x model (such as gemini-3.5-flash-lite).
  4. In the document assistant sidebar, prompt: "帮我生成一份述职文档模板" (or any prompt that triggers write_document).
  5. After step 1 completes, the API returns HTTP 400.

Error Output

json
{
  "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:

  1. In emitGeminiJsonMessage / streaming event handler: part.thought_signature (or thoughtSignature) is received alongside part.functionCall, but it is not captured into the tool call metadata.
  2. In geminiContents(messages): When reconstructing the model role turn, parts.push({ functionCall: ... }) does not include the corresponding thought_signature.
  3. Reference: https://ai.google.dev/gemini-api/docs/thought-signatures