Repository navigation
[ENG-21157] fix(agents): replay Gemini thought signatures through OpenAI-compatible proxies - #280
Conversation
…nAI-compatible proxies Gemini 3 models return a thought signature on the first tool call of a turn (extra_content.google.thought_signature). Vertex AI rejects the next request when the signature is not replayed: 400 Function call is missing a thought_signature in functionCall parts The OpenAI-completions transport already stores the signature and replays it, but only for provider "google" or a Google endpoint class. A Gemini model behind an OpenAI-compatible proxy, such as an LLM gateway, has a custom or local endpoint class. Its signatures are stored and never sent back, so every tool loop fails on the second request. Add the opt-in model compat flag requiresGoogleThoughtSignatures. When it is true, the existing replay path runs for that model, whatever the endpoint class. Models without the flag do not change. The flag is accepted by the config schema, the config types and the model catalog normalizer.
There was a problem hiding this comment.
All reported issues were addressed across 7 files
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
|
@cubic-dev-ai review |
@orswn I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
All reported issues were addressed across 7 files
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
… proxy The parallel tool-call test for a proxied Gemini model stopped after stream parsing. It could not catch a lost signature on the first call or a lost skip-validator sentinel on the second call when the next request sends the parallel set back, which is the shape a real agent turn sends. Build the next request from the parsed output and both tool results, and assert that the first call carries its thought_signature and the second carries skip_thought_signature_validator.
…iases With compat.requiresGoogleThoughtSignatures set, signature replay runs for a proxied model whatever its id. The skip-validator fallback still needed "gemini-3" in the model id. A proxy alias without it sent the unsigned calls of a parallel set, and tool calls from another route, with no signature, and Vertex AI rejects that request. Let the flag also enable the fallback. Run the parallel replay test for a gemini-3 id and for an alias id, and cover a cross-route call on an alias id.
There was a problem hiding this comment.
LGTM. The update to requiresGoogleCompatToolCallThoughtSignature ensures aliased proxy IDs correctly receive the skip_thought_signature_validator sentinel for parallel tool calls and cross-route tool calls. Clean implementation and comprehensive test coverage.
There was a problem hiding this comment.
Re-verified after merge of boon into the PR branch (head 5726e46). CI is all green and all checks pass cleanly. Approved.
Cut the fork release for the PRs merged to boon after the v2026.6.35-boon.4 tag: - #328 (ENG-22237): replayed user turns keep the same bytes, so a new user message in Boon Web, Slack and MS Teams reads the previous prompt from cache instead of writing the whole history again. - #280 (ENG-21157): opt-in model compat flag requiresGoogleThoughtSignatures, so Gemini 3 tool loops work behind an OpenAI-compatible proxy. No fleet model config sets it yet. - #327: the v2026.6.35-boon.4 tag was cut from the PR branch. The review fixes that merged after it change tests and one comment only. Bump the root package.json and npm-shrinkwrap.json, all 136 bundled plugin manifests (scripts/sync-plugin-versions.ts), and the version and openclaw peer floor in every extension npm-shrinkwrap.json (scripts/generate-npm-shrinkwrap.mjs --all). The regeneration also picks up the registry's updated deprecation text for @smithy/core 3.24.6 in amazon-bedrock, amazon-bedrock-mantle and tlon; no resolved version or integrity changes. Add the 2026.6.35-boon.5 CHANGELOG.md section. No source or dependency change beyond the merged PRs above.
Related: ENG-21157
What Problem This Solves
Gemini 3 models fail every tool loop when they run behind an OpenAI-compatible proxy, such as the Boon LLM gateway.
Gemini returns a thought signature on the first tool call of a model turn, in
extra_content.google.thought_signature. The next request must send it back on that tool call. Vertex AI rejects the request without it:The OpenAI-completions transport already stores and replays these signatures, but only for provider
googleor a Google endpoint class. A gateway URL is a custom or local endpoint class. The signature is stored and never sent back, so the first tool call works and the request after the tool result fails.Why This Change Was Made
requiresGoogleThoughtSignatures.true,isGoogleOpenAICompatModelreturnstruefor that model, whatever the endpoint class. The existing replay path then runs unchanged.skip_thought_signature_validatorfallback for unsigned tool calls. Before, that fallback neededgemini-3in the model id, so a proxy alias such asgateway-plannersent those calls with no signature.Why a flag and not detection by model id:
extra_content.googleon its tool calls.Model entry used in the tests below:
{ "id": "gemini-3.8-flash", "api": "openai-completions", "reasoning": true, "compat": { "requiresGoogleThoughtSignatures": true, "supportsReasoningEffort": true, "supportedReasoningEfforts": ["low", "medium", "high"], "maxTokensField": "max_completion_tokens", "supportsUsageInStreaming": true, "supportsDeveloperRole": false, "supportsStore": false, "supportsStrictMode": false } }Only the first flag is new. Without
supportsReasoningEffort, a custom endpoint sends noreasoning_effort.Parallel tool calls: Vertex signs only the first call of a parallel set. The transport sends
skip_thought_signature_validatorfor the unsigned calls of agemini-3model, or of any model with the flag. Vertex accepted this shape in the live run below.User Impact
Evidence
Unit tests. The first 6 rows failed before the change, the last 2 passed before and after:
thought_signatureis sent back when the flag is setgemini-3requiresGoogleThoughtSignaturesextra_contentwithout the flagrequiresGoogleThoughtSignatureRe-run on head
d789184288b, after the merge ofboon(2026-11-05):Re-run on head
5726e460678, after the merge ofboonwith #328 (2026-11-05): the same commands give the same results. The 10 test files that #328 changed pass on this head too (329 tests).Config flow: the real
validateConfigObjectandresolveModelkeepcompat.requiresGoogleThoughtSignatures: trueon the resolved model. No other code path strips the key, and the same-route history transforms keep the signature.Live tool loop with the transport from this branch (
createOpenAICompletionsTransportStreamFn). Vertex AIgemini-3.8-flash, reasoninghigh, through a local LLM gateway with the gateway change. The prompt asks for 2 parallelget_weathercalls, then the second request sends both tool results:Without the flag the gateway returns 502 on the stream. The same request without streaming returns the Vertex 400 above.
Re-check on head
4fa361065f3after the merge ofboon(2026-11-05). Same probe, through a local gateway built from getboon/boon-llm-gateway#130 after its merge ofmain:all providers failed(3 attempts)Re-check on the head
d789184288b(2026-11-05), through a local gateway built from the head of getboon/boon-llm-gateway#130. The alias rows go through a small local test proxy that maps the modelgateway-plannertogemini-3.8-flash, the way an OpenAI-compatible proxy can hide the model family:gemini-3.8-flashgemini-3.8-flashall providers failed(3 attempts)gateway-planner(alias)gateway-planner(alias)all providers failed(3 attempts)Re-check on the head
5726e460678after the merge ofboonwith #328 (2026-11-05). #328 sends the per-turn context as a separate user message right after the active user message. On this route it stays a separate message, so Gemini gets two user messages in a row. Same probe with that message added throughbuildRuntimeContextCustomMessage, through a local gateway built from the head of getboon/boon-llm-gateway#130:all providers failed(3 attempts)Agent run: the same change, applied to
v2026.6.34-boon.3together with the Claude fix from #278, served a Boon agent on Gemini 3.8 Flash with the flag set. After that run,boonchangedopenai-transport-stream.tsonly in the xAI encrypted-content retry check. The Gemini replay path is the same. The agent ran the agent regression suite 4 times, 11 scenarios each:thought_signature.Summary by cubic
Fixes Gemini 3 tool loops failing when the model runs behind an OpenAI-compatible proxy, such as the Boon LLM gateway. Vertex AI requires the
thought_signaturefrom the first tool call to be replayed on the next request, but the replay logic only ran for Google endpoints, not custom or local endpoint classes.Adds an opt-in
compat.requiresGoogleThoughtSignaturesmodel flag. When set, the existing thought-signature replay path and the skip-validator fallback run for that model regardless of endpoint class or model id, so proxied aliases replay the first call's signature and sendskip_thought_signature_validatoron unsigned calls. Models without the flag keep current behavior. The config schema, config types, and model catalog normalizer now accept the key, and the parallel tool-call test verifies the next request replays the signature on the first call and the skip sentinel on the second.Rollout
"requiresGoogleThoughtSignatures": trueon the model entry.getboon/boon-llm-gateway#130andGOOGLE_CLOUD_LOCATION=global; neither is part of this PR.Written for commit d789184. Summary will update on new commits.