Skip to content

Gemini 3 Bots finish a tool call on ADK, AG2, CrewAI, Langroid, Mastra and Strands - #2397

Merged
davidmckayv merged 4 commits into
mainfrom
fix/gemini-thought-signature
Nov 29, 2026
Merged

davidmckayv merged 4 commits into
mainfrom
fix/gemini-thought-signature

Conversation

@davidmckayv

Copy link
Copy Markdown
Contributor

What this changes

What a person saw. A Bot on Gemini 3 or later (gemini-3.8-flash, Gemini 4) on Google ADK, AG2,
CrewAI, Langroid, Mastra or Strands stopped as soon as one of its tools returned. The tool ran, and
the next model call failed with Google's 400: "Function call is missing a thought_signature in
functionCall parts". That happens with a Gemini key saved in Settings or OpenBot Desktop (Google's
OpenAI-compatible endpoint) and on OpenBot Cloud's AI connection (the model gateway). The LangGraph
engines were fixed in #2334 and #2335.

Why. Gemini 3+ gives the first function call of each model step a thought signature and refuses
a request whose current turn holds a step whose first call comes back without it
(Google's thought signatures guide). OpenBot
runs the tool between two runs and hands the call back from the thread, and these engines sent it
back unsigned.

The fix, per engine, checked against what each framework does today:

  • CrewAI keeps the real signature, as LangGraph does: the flow puts it on the call as AG-UI's
    encryptedValue in the run's snapshot, and sends it back from the thread as
    extra_content.google.thought_signature, to a Gemini model only.
  • ADK already keeps the real one in the process that made the call (ADK's LiteLLM model carries
    it). ag_ui_adk sends no signature out with a client tool's call, so a fresh process (a restart or
    another replica) has none in the thread.
  • AG2 carries signatures only on its own Gemini config, and Strands, Langroid and
    Mastra (@ai-sdk/openai) not at all on an OpenAI-compatible endpoint. Checked on the latest
    releases (AG2 1.3.4, @ai-sdk/openai 4.0.125, ag-ui-adk, strands-agents, ag-ui-langroid):
    no bump fixes it.
  • Where an engine cannot carry it, or the thread has none for a call, the call goes with Google's
    documented placeholder for a call whose signature is not available,
    skip_thought_signature_validator. For the Python engines that is shared/gemini_signatures.py,
    applied at the HTTP request the way run_model_key.py puts a run's key in (each framework builds
    its request its own way, and all send through httpx). For Mastra it is a fetch given to its
    compatible-endpoint model client only.

Narrow on purpose. Only a POST to Chat Completions, on Google's own host or OpenBot's model
gateway, for a Gemini 3+ model, is touched, and only the first call of a step that has no signature.
A real signature is kept. Every other request to every other provider and model is sent as before.
Compared with #2365 this leaves out the BOT_PROVIDER=google model-name and AG2 GeminiConfig
changes (and the ag2[gemini] extra), the native generateContent and aiohttp signing (LiteLLM
already adds the placeholder on that path), the LlamaIndex and LangGraph changes, and the model check
script.

First found by lorenzejay in #2365.

Where it runs

  • New state that outlives a request? None. CrewAI's signature lives in the thread, as the
    call's encryptedValue; the placeholder is decided from each request alone.
  • What happens on the second replica? It answers the tool's result the same way: CrewAI reads
    the signature from the thread, and the other engines send the placeholder. Tested as a fresh
    process.
  • Anything serialised? No.
  • Anything fanned out to a browser? No.
  • New listener, port, or schedule? No.

Boundary and audit

  • Every acting call still goes through the gateway. Only the body of a model request to Gemini
    changes.
  • No new refusals or failures.
  • Nothing new is trusted from the client.

API and database

  • This changes nothing under api/, no app's requests, no database change and no
    release-policy.json.

Changelog

  • A line in CHANGELOG.md under Unreleased.

Proof

Regression tests, each red on main's engine source and green on this branch. A fake Gemini at
its OpenAI-compatible endpoint (fake_gemini in shared/harness_contract.py) gives a signed
look_up_order call in run one and holds run two to Google's rule. Run two hands the call back the
way the server does, to the same process and to a fresh one:

engine on main this branch
ADK fresh process refused (same process already passed) real signature in the same process, placeholder in a fresh one
AG2 refused, both placeholder
CrewAI refused, both real signature from the thread, both; placeholder for a thread with none
Langroid refused, both placeholder
Strands refused, both placeholder
Mastra (index.test.ts) refused placeholder, and a gpt-5.5 request goes unchanged

agent-adk/tests/test_gemini_signatures.py checks the rule itself: which models, which hosts, a
real signature kept, and other providers and Gemini 2.x left alone.

Full suites on this branch: ADK 57, AG2 28, CrewAI 29, Langroid 30, Strands 24, Mastra 40, all pass.
biome format, biome lint and typecheck are clean.

Live, on Google's OpenAI-compatible endpoint with gemini-3.8-flash. A real call in run one,
then its result handed to a fresh process:

agent-adk     PASS  "The status of order 42 is shipped."
agent-ag2     PASS  "The status of order 42 is shipped."
agent-crewai  PASS  "The status of order 42 is **shipped**."   (real signature from the thread)
agent-langroid PASS "The status of order 42 is shipped."
agent-strands PASS  "The status of order 42 is **shipped**."
agent-mastra  PASS  "Order 42 is shipped."
agent-strands on main: RUN_ERROR 400 "Function call is missing a thought_signature in functionCall parts"

…every engine

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.
…gnature

# Conflicts:
#	CHANGELOG.md
#	agent-adk/Dockerfile
#	agent-ag2/Dockerfile
#	agent-crewai/Dockerfile
#	agent-langroid/Dockerfile
#	agent-mastra/src/mastra/index.test.ts
#	agent-mastra/src/mastra/index.ts
#	agent-strands/Dockerfile
…gnature

# Conflicts:
#	agent-adk/Dockerfile
#	agent-crewai/Dockerfile
#	agent-langroid/Dockerfile
#	agent-strands/Dockerfile
@davidmckayv
davidmckayv merged commit 6a9e2af into main Nov 29, 2026
42 checks passed
@davidmckayv
davidmckayv deleted the fix/gemini-thought-signature branch November 29, 2026 21:05
lorenzejay added a commit to lorenzejay/OpenBot that referenced this pull request Dec 1, 2026
The CrewAI Bot's main.py takes this branch's side; the next commit carries main's Gemini thought
signatures (CopilotKit#2397), progress reminders (CopilotKit#2436, CopilotKit#2443) and empty-turn rule (CopilotKit#2449) into it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
lorenzejay added a commit to lorenzejay/OpenBot that referenced this pull request Dec 1, 2026
…ain's Gemini and reminder rules

The conversational Agent now does what the Bot on main did:

- A tool whose name CrewAI changes for the model (`showNote`, `askApproval`, `mcp__...`) is handed
  back under the server's name. The model calls it by `sanitize_tool_name`, and the hand-back
  looked it up by the server's name, so the turn answered "Handed to the caller to run."
- A handed-back call leaves out the `null`s its own schema did not ask for. CrewAI offers tools in
  strict mode, so every optional field came back as `null`.
- A `developer` message is kept as an instruction and left out of CrewAI's session, whose messages
  have no such role. It refused the whole run.
- An empty `OPENAI_BASE_URL` or `ANTHROPIC_BASE_URL` is unset. The providers' own SDKs took `""` as
  the address, and every OpenAI run failed with `APIConnectionError`.
- The model runs on CrewAI's own client for OpenAI, Anthropic and Google, whatever it is called.
  CrewAI sent a model it has not heard of (Gemini on the model gateway, `qwen/qwen3-8b`) to
  LiteLLM, which offered it no tools.
- The words the model said in a step that called tools are the reply's content. CrewAI keeps that
  step with none, so a line on a long job never reached the person.

From main: Gemini's thought signature goes out on the handed-back call's `encryptedValue` and back
to Gemini, with Google's placeholder only for a call the thread has none for (CopilotKit#2397); the progress
reminder after five silent steps (CopilotKit#2436, CopilotKit#2443), added to the latest result where CrewAI would take
a note in the person's turn for the request; the empty-turn rule (CopilotKit#2449); `google` as `gemini/`.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.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.

1 participant