Skip to content

fix: preserve Gemini thought_signature in tool call messages - #188

Closed
0xbyt4 wants to merge 1 commit into
NousResearch:mainfrom
0xbyt4:fix/gemini-thought-signature
Closed

fix: preserve Gemini thought_signature in tool call messages#188
0xbyt4 wants to merge 1 commit into
NousResearch:mainfrom
0xbyt4:fix/gemini-thought-signature

Conversation

@0xbyt4

@0xbyt4 0xbyt4 commented Feb 28, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Gemini 3 thinking models (Flash/Pro) attach extra_content.google.thought_signature to function call responses. This signature must be echoed back on subsequent API calls or the server rejects with a 400 error.
  • _build_assistant_message was only extracting id, type, and function from tool calls, dropping the extra_content field entirely. This caused all Gemini 3 tool-calling flows to fail after the first function call.
  • Fix preserves extra_content (with Pydantic model_dump safety) so it round-trips through the conversation history. Non-thinking models are unaffected -- the field is only included when present.

Changes

  • run_agent.py: Preserve extra_content from tool call objects in _build_assistant_message
  • tests/test_run_agent.py: Add 2 tests verifying extra_content is preserved when present and omitted when absent

Gemini 3 thinking models attach extra_content with thought_signature
to function call responses. This must be echoed back on subsequent
API calls or the server rejects with a 400 error. The assistant
message builder was dropping this field, causing all Gemini 3 Flash/Pro
tool-calling flows to fail after the first function call.
@teknium1

teknium1 commented Mar 1, 2026

Copy link
Copy Markdown
Contributor

Which provider are we talking about here?

We pushed a commit earlier to preserve all OpenRouter & Nous Portal reasoning - and one that makes it so our Codex Provider works like that too.

But openrouter doesn't work like this (neither does nous portal) - so not sure where this fix applies

@teknium1 teknium1 closed this Mar 1, 2026
@0xbyt4

0xbyt4 commented Mar 1, 2026

Copy link
Copy Markdown
Contributor Author

Which provider are we talking about here?

We pushed a commit earlier to preserve all OpenRouter & Nous Portal reasoning - and one that makes it so our Codex Provider works like that too.

But openrouter doesn't work like this (neither does nous portal) - so not sure where this fix applies

This fix is for direct Google AI Studio usage via the OpenAI-compatible endpoint
(OPENAI_BASE_URL=https://generativelanguage.googleapis.com/v1beta/openai/), not OpenRouter or Nous Portal. Gemini 3 thinking models (Flash/Pro) attach
extra_content.google.thought_signature to function calls through this endpoint, and reject subsequent requests with a 400 error if it's not echoed back.
The fix simply preserves extra fields on tool_call objects it's a no-op for providers that don't send them (OpenRouter, Nous, OpenAI etc.).

zapabob added a commit to zapabob/hermes-agent that referenced this pull request Jul 28, 2026
… test

Pin brace-expansion to 5.0.8 via npm overrides for Dependabot NousResearch#188, and make the LSP workspace tilde-expansion test respect USERPROFILE on Windows.

Co-authored-by: Cursor <cursoragent@cursor.com>
zapabob added a commit to zapabob/hermes-agent that referenced this pull request Jul 28, 2026
…orts to react-router

Keep website on brace-expansion 5.0.8 for Dependabot NousResearch#188, bump only the root 5.0.7 slot, and stop forcing nested 1.x consumers onto the 5.x API that broke eslint expand().

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants