gemini-cli - 💡(How to fix) Fix bug(core): Vertex AI requests failing with 400 INVALID_ARGUMENT due to camelCase thoughtSignature injection [1 pull requests]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

✕ [API Error: [{ "error": { "code": 400, "message": "Unable to submit request because function call default_api:run_shell_command in the 1034. content block is missing a thought_signature. Learn more: https://docs.cloud.google.com/vertex-ai/generative-ai/docs/thought-signatures", "errors": [ { "message": "Unable to submit request because function call default_api:run_shell_command in the 1034. content block is missing a thought_signature. Learn more: https://docs.cloud.google.com/vertex-ai/generative-ai/docs/thought-signatures", "domain": "global", "reason": "badRequest" } ], "status": "INVALID_ARGUMENT" } } ]]

Root Cause

Users are encountering 400 INVALID_ARGUMENT errors from the Gemini API (specifically when using Vertex AI). The error message typically states: Unable to submit request because function call <tool_name> in the <N>. content block is missing a thought_signature.

Fix Action

Fixed

Code Example

[API Error: [{
    "error": {
      "code": 400,
      "message": "Unable to submit request because function call `default_api:run_shell_command` in the 1034. content block is missing a `thought_signature`. Learn more: https://docs.cloud.google.com/vertex-ai/generative-ai/docs/thought-signatures",
      "errors": [
        {
          "message": "Unable to submit request because function call `default_api:run_shell_command` in the 1034. content block is missing a `thought_signature`. Learn more: https://docs.cloud.google.com/vertex-ai/generative-ai/docs/thought-signatures",
          "domain": "global",
          "reason": "badRequest"
        }
      ],
      "status": "INVALID_ARGUMENT"
    }
  }
  ]]
RAW_BUFFERClick to expand / collapse

What happened?

Users are encountering 400 INVALID_ARGUMENT errors from the Gemini API (specifically when using Vertex AI). The error message typically states: Unable to submit request because function call <tool_name> in the <N>. content block is missing a thought_signature.

This happens frequently during long-running sessions or when the user provides model steering updates that trigger internal tool calls like update_topic.

After sending a model steering update, I see an error similar to this, then the agentic loop kicks out and I am forced to re-prompt

✕ [API Error: [{
    "error": {
      "code": 400,
      "message": "Unable to submit request because function call `default_api:run_shell_command` in the 1034. content block is missing a `thought_signature`. Learn more: https://docs.cloud.google.com/vertex-ai/generative-ai/docs/thought-signatures",
      "errors": [
        {
          "message": "Unable to submit request because function call `default_api:run_shell_command` in the 1034. content block is missing a `thought_signature`. Learn more: https://docs.cloud.google.com/vertex-ai/generative-ai/docs/thought-signatures",
          "domain": "global",
          "reason": "badRequest"
        }
      ],
      "status": "INVALID_ARGUMENT"
    }
  }
  ]]

What did you expect to happen?

API requests should be correctly formatted according to Vertex AI requirements so that tool calls (including synthetic signatures for loop validation) are accepted without errors.

Client information

<details> <summary>Client Information</summary>

Gemini CLI v0.41.0, v0.41.1, v0.41.2 Platform: All (Linux, macOS, Windows).

</details>

Login information

Observed primarily with Vertex AI / OAuth-based authentication.

Anything else we need to know?

Root Cause: The Gemini API (Vertex AI) requires the property thought_signature (snake_case) on the first function call of a model turn within an active loop.

While scrubHistory attempts to clean up the history before sending it to the API, the function ensureActiveLoopHasThoughtSignatures (in geminiChat.ts) runs after the scrubbing pass. This function incorrectly injects the camelCase version (thoughtSignature) back into the object to bypass the loop validator, which Vertex AI then rejects.

Suspected Commits:

  • 86828bb56: Initially introduced ensureActiveLoopHasThoughtSignatures using the camelCase key.
  • 71f313b51 / v0.41.0 refactors: The restructuring of how history is scrubbed and processed (scrubbedContents) made it so this post-scrub injection is now the final state sent to the API, exposing the bug.

Proposed Fix: Update ensureActiveLoopHasThoughtSignatures in packages/core/src/core/geminiChat.ts to inject thought_signature (snake_case) instead of thoughtSignature. Additionally, ensure scrubHistory (if it handles thoughts) expects and passes through the snake_case version.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING