Repository navigation
Gemini 3 and 4: sign handed-back tool calls on every engine that runs Gemini - #2365
Closed
lorenzejay wants to merge 3 commits into
Closed
lorenzejay wants to merge 3 commits into
lorenzejay wants to merge 3 commits into
Conversation
…s fix did not reach
Gemini 3 and later refuse a function call in the current turn without the thought signature the
model gave it ("Function call is missing a thought_signature in functionCall parts"). OpenBot runs
each tool between two runs and an AG-UI tool call has no field for a signature. 1.2.2 carries the
real signature through the thread on both LangGraph engines (CopilotKit#2334, CopilotKit#2335); every other engine
still sent the handed-back call unsigned, so a Bot on Gemini 3.x or 4 failed after its first tool.
- shared/gemini_signatures.py: ADK, AG2, CrewAI, Langroid, LlamaIndex and Strands install it beside
run_model_key. It wraps httpx/httpx2 sends and aiohttp requests and gives each unsigned call
Google's documented placeholder, `skip_thought_signature_validator`: on Gemini's own API
(`functionCall` parts, any host) and on Google's OpenAI-compatible endpoint or OpenBot's gateway
for a Gemini model (`extra_content.google.thought_signature`). A real signature is kept; any other
provider's or model's request is sent byte for byte.
- shared/gemini-signatures.ts: the same rules as a fetch wrapper, for Mastra's OpenAI-compatible
client.
- LiteLLM engines (ADK, Strands, Langroid, CrewAI, LlamaIndex) address Gemini as `gemini/`, not
`google/` ("LLM Provider NOT provided"), through `litellm_model` in model_providers.py.
- AG2 answers `BOT_PROVIDER=google` with its GeminiConfig on the Google key, instead of the OpenAI
config that asked for OPENAI_API_KEY.
- scripts/model-compat.ts: the one run per model now hands back an unsigned tool call and its
result (`handBackRun`), so the lock no longer verifies a model a Bot cannot finish a tool call on.
- Tests: a hand-back test per engine against the shared fake provider (now also serving Gemini's
generateContent), signing-rule tests for both modules, model-compat's run body.
tests/compose.test.ts imports the LangChain harness with httpx stubbed as a bare module; the signer, installed at import, assumed httpx.Client and stopped the import. It now patches only a client that is there.
…cord gets the placeholder thought_signatures.py (CopilotKit#2335) sends back the signature Gemini gave a call, when the thread carries it. A thread without one (a conversation from before it, or a caller that drops encryptedValue) still reached Google's OpenAI-compatible endpoint unsigned and was refused with "Function call is missing a thought_signature". The engine now installs shared/gemini_signatures.py like the other Python engines: it fills in Google's placeholder only where a call has no signature, so a real one still goes as it came, and nothing changes for another provider's model. The LangGraph (TypeScript) engine already does this in thought-signatures.ts.
lorenzejay
requested review from
MikeRyanDev,
davidmckayv,
dustywusty,
guidovizoso,
mxmzb,
samjulien and
tylerslaton
as code owners
November 28, 2026 03:27
10 tasks done
davidmckayv
added a commit
that referenced
this pull request
Nov 29, 2026
…every engine (#2397) A Bot on Gemini 3 or later on Google ADK, AG2, CrewAI, Langroid, Mastra or Strands stopped once a tool's result came back: Google refused the next request with "Function call is missing a thought_signature in functionCall parts". The call comes back from the thread without the signature Gemini gave it, and Gemini checks the first call of each step in the current turn. - CrewAI keeps the real signature, as the LangGraph engines do: it leaves on the call as its AG-UI encryptedValue in the run's snapshot, and goes back to Gemini from the thread. - ADK already keeps it within the process that made the call. - Where an engine cannot carry it (and for a thread that has none), the call goes with Google's documented placeholder, skip_thought_signature_validator: shared/gemini_signatures.py for the Python engines, at the HTTP request as run_model_key.py does, and a fetch on Mastra's compatible-endpoint model client. Only a Chat Completions request for a Gemini 3+ model, on Google's host or OpenBot's model gateway, is changed; a real signature is kept. First found by lorenzejay in #2365.
Contributor
|
Thanks for finding this. It's fixed in #2397 and ships in the next release. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2363.
What this changes
Gemini 3 and later refuse a function call in the current turn that does not carry the thought
signature the model gave it ("Function call is missing a thought_signature in functionCall parts").
OpenBot runs each tool between two runs, and an AG-UI tool call has no field for a signature. #2334
and #2335 carry the real signature through the thread on the two LangGraph engines. Every other
engine still handed the call back unsigned, so a Bot on Gemini 3.x or Gemini 4 failed as soon as a
tool's result came back. That happens with a key saved as Google's OpenAI-compatible endpoint (how
OpenBot Desktop and Settings save a Gemini key), on ADK, AG2, CrewAI, Langroid, Mastra and Strands.
Checked against the live API (2026-11-27) on
gemini-3.8-flashandgemini-4-hydrogen:generateContentskip_thought_signature_validator(raw or base64, one or two parallel calls)Signing, once per language, at the HTTP request
shared/gemini_signatures.py: ADK, AG2, CrewAI, Langroid, LlamaIndex and Strands install it besiderun_model_key. It wrapshttpx/httpx2sends andaiohttprequests (google-genai sends throughaiohttpwhen that is installed). It gives an unsigned call Google's documented placeholder:functionCallpart, on a POST to.../models/gemini-*:(stream)generateContent, on any host;extra_content.google.thought_signatureon the tool call.A real signature is kept. A request to any other provider, or for any other model, is sent byte
for byte.
shared/gemini-signatures.ts: the same rules as afetchwrapper, passed to Mastra'sOpenAI-compatible client.
LangGraph (Python) installs the Python signer too, on top of LangGraph (Python): keep Gemini's thought signature on a tool call #2335.
thought_signatures.pysends back the signature the thread carries. A thread without one (a conversation from before
1.2.2, or a caller that drops
encryptedValue) still reached the compatible endpoint unsigned andwas refused; the signer fills in the placeholder only there. LangGraph (TypeScript) already does
this in
thought-signatures.tsand is not changed.BOT_PROVIDER=googlereaches Gemini at allgoogle/<model>, but LiteLLM readsgemini/,so they failed with "LLM Provider NOT provided". Fixed through
litellm_modelinshared/model_providers.py.OPENAI_API_KEY. It now uses AG2'sGeminiConfigwith the Google key. This adds theag2[gemini]extra, with google-genai held<3like the other engines.
The model check catches it
scripts/model-compat.ts: the one run per model is now a hand-back (handBackRun): the user'sask, the assistant's unsigned call to
look_up_order, and its result. A model a Bot cannot finisha tool call on no longer passes, and so no longer gets into the lock.
model-lock.jsonisuntouched; CI writes it.
Not changed
call as a function call. It passed the live hand-back unchanged.
BOT_PROVIDER=googleat start by design.Its Gemini path is Google's compatible endpoint, which is now signed.
call it sends as a call is covered.
Where it runs
it keeps nothing between requests.
body changes.
Boundary and audit
changes.
API and database
api/, no app's requests, no database change and norelease-policy.json.Changelog
CHANGELOG.mdunderUnreleased.Proof
Live hand-back runs, every engine (2026-11-27, paid-tier key, images built from this branch's
head
ba68f20b, on 1.2.2). Each run hands the engine an unsignedlook_up_ordercall and itsresult, as the server does after running a tool, and passes when the engine answers with the
order's status. "Compatible" is Google's OpenAI-compatible endpoint, which is how OpenBot Desktop
and Settings save a Gemini key; "native" is
BOT_PROVIDER=google.38 runs passed and none failed. Mastra answers on OpenAI and Anthropic only, and refuses
BOT_PROVIDER=googleat start, so its two native runs never reach a model. Antigravity alwaystalks to Gemini's own API, so its run marked
compatin the output below is on that API too.Run output
Before this change, the published images failed every compatible-path cell except LangGraph's with
"Function call is missing a thought_signature". On the native path, ADK, Strands, Langroid and CrewAI
failed with "LLM Provider NOT provided", and AG2 asked for an OpenAI key.
Tests, run locally on this branch:
215 (with LangGraph (Python): keep Gemini's thought signature on a tool call #2335's
test_thought_signatures.py), Langroid 31, LlamaIndex 16, Strands 25, all pass;bun test agent-mastra: 40 pass;bun test shared/gemini-signatures.test.ts scripts/model-compat.test.ts tests/compose.test.ts: 80pass;
biome lint --error-on-warningsandbiome formaton the changed files: clean.With the signer switched off, each engine's
test_gemini_handback.pyfails on the compatible path.On LangGraph (Python) it fails on #2335 alone for a thread with no signature on record. LangGraph
(TypeScript) on 1.2.2 passes the same unsigned hand-back on both paths, so it is not changed here.