Skip to content

fix(ai): preserve Gemini thought signatures on OpenAI Chat tool calls - #51768

Merged
rekram1-node merged 2 commits into
v2from
gemini-thought-signatures
Sep 28, 2026
Merged

rekram1-node merged 2 commits into
v2from
gemini-thought-signatures

Conversation

@rekram1-node

@rekram1-node rekram1-node commented Sep 28, 2026 •

Copy link
Copy Markdown
Member

Fixes #50833 for the V2 native runtime.

Problem

Gemini's OpenAI-compatible surface returns thought signatures on tool calls as extra_content.google.thought_signature and rejects a replayed parallel tool call batch without them:

400 Function call is missing a thought_signature in functionCall parts.

V2 routes @ai-sdk/openai-compatible providers through @opencode/ai's OpenAI Chat protocol, which dropped extra_content, so Gemini tool loops with parallel calls over OpenAI-compatible providers failed on the continuation.

Changes

  • Decode a tool call's native extra_content (known shape only) and store it verbatim as providerMetadata[key].extraContent, the same way reasoning_details is stored as reasoningDetails.
  • Lowering sends the stored value back as extra_content. Core already restricts tool call metadata replay to the producing model.
  • ToolStream.appendOrStart accepts provider metadata on the delta that starts a call.
  • Omit store for generativelanguage.googleapis.com, which rejects the field (Unknown name "store") and otherwise fails every request to Google's OpenAI endpoint.

Tests

  • Fixture tests for lowering, Gemini's index-less parallel stream shape, and extra content arriving before the call identity.
  • Recorded cassette against Google's OpenAI-compatible endpoint (gemini-3.8-flash): a parallel two-city tool loop whose continuation replays the signature and succeeds. The same continuation without extra_content returns the 400 from the issue against the live endpoint.

@rekram1-node
rekram1-node merged commit d73396a into v2 Sep 28, 2026
10 checks passed
@rekram1-node
rekram1-node deleted the gemini-thought-signatures branch September 28, 2026 03:57
@ayorgo

ayorgo commented Oct 6, 2026

Copy link
Copy Markdown

Thank you for fixing this ❤️!

Is there a chance for it to appear in v1 as well?

As v2 is currently

  • a little unstable
  • isn't yet available in nixpkgs

@rekram1-node

Copy link
Copy Markdown
Member Author

hm might port for v1 but lemme see about the nixpkgs

Also v2 doesnt ship any breaking changes rn without proper semver, so next breaking changes will be in 2.1.x

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