Repository navigation
fix(venice): replay Gemini tool signatures by turn occurrence - #119783
Patrick-Erichsen merged 11 commits into
Conversation
7a3e68c to
293aab7
Compare
|
Codex review: needs maintainer review before merge. Reviewed August 6, 2026, 10:36 PM ET / August 7, 2026, 02:36 UTC. ClawSweeper reviewWhat this changesThe PR captures Venice Gemini’s top-level tool signature, preserves it in transcripts, and replays it only for the matching historical tool-turn occurrence. Regression provenancePossible regression — probable (reproduction; failure trace). No predecessor PR is attributed. Merge readinessNo blocking findings: current main still lacks Venice’s top-level signature capture and Venice-local replay, while this PR repairs that path with route- and occurrence-scoped transcript handling. The explicitly accepted compatibility policy and supplied exact-head Gateway/restart proof support normal merge handling rather than further repair work. Priority: P1 Review scores
Verification
How this fits togetherThe shared OpenAI-compatible transport turns provider stream chunks into transcript tool calls, and the Venice provider plugin shapes those stored calls into a later Venice continuation request. This change carries Venice’s opaque signature through that path without changing other providers’ request behavior. flowchart LR
A[Venice streamed tool call] --> B[Shared transport capture]
B --> C[Agent transcript]
C --> D[Venice provider wrapper]
D --> E[Route and turn matching]
E --> F[Venice continuation request]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +198, Tests +458. Total +656 across 7 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Merge the Venice-local replay policy after the normal exact-head merge gate, retaining the existing transcript field and the narrowly scoped textual fallback for invalid unsigned legacy Venice Gemini 3 history. Do we have a high-confidence way to reproduce the issue? Yes: current-main source proves the top-level Venice signature is not captured, and the linked report plus maintainer Gateway/restart evidence give a concrete tool-turn continuation path. Is this the best way to solve the issue? Yes: generic transport capture belongs in the shared OpenAI-compatible layer, while Venice-only replay and fallback remain in the owning provider plugin; sibling Google and foreign routes stay outside the policy. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 21e9634f1084. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (4 earlier review cycles)
|
293aab7 to
0a94d2b
Compare
|
@clawsweeper re-review Current exact head: The branch is now zero-behind current main and GitHub reports it mergeable. Every hosted exact-head workflow is green: full CI, CodeQL, CodeQL Critical Quality, OpenGrep, Workflow Sanity, and all Periphery checks. The carry-forward preserves Wen-Yong Lim's six original commits and final reviewed head Please review this current attribution-preserving head. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review The PR body now directly addresses the remaining compatibility and stored-state questions on exact head It now documents and ties to the existing regressions that:
A compatibility matrix and explicit maintainer decision are included. CI/security remain fully green, the branch is mergeable and zero behind, and there are no open inline review threads or contributor-side blockers. Please reassess patch quality and the stored-data/compatibility classification against the updated evidence. |
|
Maintainer handoff for @steipete: this P1 Venice repair is now zero-behind, mergeable, fully green, proof-sufficient, and has no open review threads or contributor-side blockers. The original six commits and Wen-Yong Lim's authorship are preserved. The remaining decision is narrowly documented in the PR body: accept the Venice-only request-time fallback that converts legacy unsigned Gemini 3 tool batches to text rather than replaying a protocol sequence known to fail with HTTP 400. Valid signatures, Google-compatible history, foreign-provider history, and persisted transcripts remain unchanged. I also completed a fresh exact-head diff audit of the capture, redaction, occurrence matching, and contiguous result ownership paths and found no additional actionable issue. |
…ught-signature-v2
|
@clawsweeper re-review Current head: The implementation diff remains patch-identical to reviewed carry-forward head The body now accurately separates prior green hosted evidence from the merge-refreshed head. Fresh workflows have not yet been scheduled. Please reassess the current head; the documented Venice-only legacy-history policy remains the maintainer decision. |
|
🦞👀 Command router queued. I will update this comment with the next step. |
…ught-signature-v2
|
@clawsweeper re-review Final refreshed head: The implementation diff still has stable patch ID |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
Maintainer decision and final-head proof for
Exact-head release-gate CI is queued at https://github.com/openclaw/openclaw/actions/runs/31129433778. Proceeding through the native prepare and merge gates when it is green. |
* origin/main: refactor(test): compress repetitive fixtures in mega-tests, batch 2 (openclaw#120124) refactor(ui): adopt shared chat-host fixture across chat suites (openclaw#120120) fix(ci): provision native Android resources for frozen current-contract targets (openclaw#120081) fix: preserve agent delivery identity (openclaw#120108) fix(qqbot): add cause-specific setup guidance (openclaw#119780) fix(venice): replay Gemini tool signatures by turn occurrence (openclaw#119783) fix(gateway): yield before TTS status diagnostics (openclaw#119788) fix: gateway restart fails and leaves the macOS LaunchAgent unloaded when the gateway drains active work (openclaw#116875) fix(clickclack): show native agent progress while replying (openclaw#116683) fix: unhandled rejection crashes process when raw stream write fails (openclaw#119400) fix: prevent duplicate outbound delivery during concurrent recovery (openclaw#119966) # Conflicts: # src/agents/embedded-agent-runner/run.incomplete-turn.test.ts
…aw#119783) * fix(venice): replay Gemini tool-call signatures * fix(venice): preserve Gemini signatures in transcripts * fix(venice): handle mixed Gemini tool history * fix(venice): downgrade unsigned Gemini tool history * fix(venice): scope Gemini tool replay by turn * fix(venice): narrow replay occurrence guards --------- Co-authored-by: Wen-Yong Lim <[email protected]> Co-authored-by: Patrick Erichsen <[email protected]>
…routes (#186942) Root cause: `packages/ai/src/transports/openai-completions-stream.ts:69` (`extractToolCallThoughtSignature`) never reads LiteLLM's `tool_calls[].provider_specific_fields.thought_signature`, and `packages/ai/src/transports/openai-completions-replay.ts:37` returns early for every non-Google endpoint, so a LiteLLM `openai-completions` route never sends Gemini's thought signature back. Strict tool-call id sanitization also cuts LiteLLM's id copy, so LiteLLM falls back to `skip_thought_signature_validator` and Gemini stops reasoning after the first tool result. Fixes #186842. Thanks @bluet for the detailed report and the re-test on 2026.11.5, and @wr-web for the fix. Their commits are kept as they are. ## What Problem This Solves A custom `openai-completions` provider pointed at LiteLLM in front of Gemini 3 loses the thought signature on every tool call: - LiteLLM returns the signature in `tool_calls[].provider_specific_fields.thought_signature` ([LiteLLM Gemini 3 guide, "Thought Signatures"](https://docs.litellm.ai/blog/gemini_3)). It may also add it to the tool-call id as `__thought__<sig>`, but only when `thought_signature_in_tool_call_id` is on. - On the next request LiteLLM reads the signature back from `provider_specific_fields` on the tool call (or its function), then from the id suffix ([`get_thought_signature_from_tool`](https://github.com/BerriAI/litellm/blob/795baa77e5a26828f205c9d6f8389e60cbe36847/litellm/litellm_core_utils/prompt_templates/factory.py#L1307)). If neither has it, LiteLLM sends a dummy `skip_thought_signature_validator` signature. - Gemini 3 needs the signatures from earlier responses sent back: a missing one means HTTP 400, and the skip value "should be a last resort as it will negatively impact model performance" ([Vertex AI, Thought signatures](https://cloud.google.com/vertex-ai/generative-ai/docs/thought-signatures)). OpenClaw never captured that field and never sent it back, and strict id sanitization cut the id copy down to 40 alphanumeric characters. The reporter saw 0 reasoning tokens on every request after a tool result. ## User Impact On LiteLLM-fronted Gemini routes, the signature now goes back with each tool call, so Gemini keeps reasoning after tool results. Requests to plain OpenAI-compatible providers, Google endpoints and Venice do not change. ## Why This Change Was Made - Capture (contributor): `extractToolCallThoughtSignature` also reads `provider_specific_fields.thought_signature` into the existing `toolCall.thoughtSignature`. - Replay (contributor): on non-Google endpoints, `injectToolCallThoughtSignatures` sends back only signatures issued on the same route (same api, provider and model), in `provider_specific_fields.thought_signature`. Cross-route signatures, the skip-validator fallback, truncated signatures and JSON reasoning details (OpenRouter) are never sent there. Google endpoints keep `extra_content.google` as before, and id sanitization is unchanged. - Venice (added on top): Venice already replays its own Gemini signatures in its top-level `thought_signature` field, matched per assistant turn because Venice reuses tool-call ids (#119783). Without this change Venice requests would also get the generic `provider_specific_fields` copy, which is keyed by id. The Venice adapter now drops that copy, so Venice requests stay byte-identical to main. - Merged current `main`. Line deltas against the merge base: production +24/-9 (stream +5/-0, replay +15/-8, Venice +3), tests +65/-56. ## Evidence Real Gateway from source (`gateway run` + `agent --message` through the Gateway, isolated profile and state). It runs against a local LiteLLM-shaped fixture: the tool-call turn carries `provider_specific_fields.thought_signature` and the `__thought__` id suffix, and the fixture reads the continuation request the way LiteLLM does. Fixture key only. Base and candidate run from the same checkout path so request bodies can be compared. | continuation request after the `read` tool result | main `c027899907ab` | this branch `e113e72c6bc7` | |---|---|---| | replayed tool-call id | `call6055144thoughtQ2lZQjRIMUZ4ZmlYdHVyZT` (signature cut off) | same | | `provider_specific_fields.thought_signature` | absent | the issued signature | | what LiteLLM would send Gemini | `skip_thought_signature_validator` | the real signature | | plain OpenAI-compatible provider, both requests | | byte-identical to main | | Venice Gemini, both requests | | byte-identical to main | Tests: the signature table in `openai-completions-replay.google-signatures.test.ts` fails 2 rows on main (LiteLLM capture, LiteLLM same-route replay). The Venice reused-id case fails on main once the transport field is in its input. All of these pass on this branch, and so do `agent-tools.prefix-stability.test.ts` and all `openai-completions*.test.ts` files. Observed proof lines: #186942 (comment) Not covered: no run against a real LiteLLM and Vertex deployment (no Vertex credentials). The reporter's direct LiteLLM check shows that sending the signature back brings reasoning back (64/188/160 vs 0/0/0 reasoning tokens). Merge danger: two-way door. The change only shapes outgoing requests and writes no state, so a revert fully undoes it. Blast radius: `openai-completions` routes to non-Google endpoints that issue thought signatures (LiteLLM, plus any other proxy that returns one) now get `provider_specific_fields.thought_signature` back on same-route tool calls. Co-authored-by: Ayaan Zaidi <[email protected]>
…routes (openclaw#186942) Root cause: `packages/ai/src/transports/openai-completions-stream.ts:69` (`extractToolCallThoughtSignature`) never reads LiteLLM's `tool_calls[].provider_specific_fields.thought_signature`, and `packages/ai/src/transports/openai-completions-replay.ts:37` returns early for every non-Google endpoint, so a LiteLLM `openai-completions` route never sends Gemini's thought signature back. Strict tool-call id sanitization also cuts LiteLLM's id copy, so LiteLLM falls back to `skip_thought_signature_validator` and Gemini stops reasoning after the first tool result. Fixes openclaw#186842. Thanks @bluet for the detailed report and the re-test on 2026.11.5, and @wr-web for the fix. Their commits are kept as they are. ## What Problem This Solves A custom `openai-completions` provider pointed at LiteLLM in front of Gemini 3 loses the thought signature on every tool call: - LiteLLM returns the signature in `tool_calls[].provider_specific_fields.thought_signature` ([LiteLLM Gemini 3 guide, "Thought Signatures"](https://docs.litellm.ai/blog/gemini_3)). It may also add it to the tool-call id as `__thought__<sig>`, but only when `thought_signature_in_tool_call_id` is on. - On the next request LiteLLM reads the signature back from `provider_specific_fields` on the tool call (or its function), then from the id suffix ([`get_thought_signature_from_tool`](https://github.com/BerriAI/litellm/blob/795baa77e5a26828f205c9d6f8389e60cbe36847/litellm/litellm_core_utils/prompt_templates/factory.py#L1307)). If neither has it, LiteLLM sends a dummy `skip_thought_signature_validator` signature. - Gemini 3 needs the signatures from earlier responses sent back: a missing one means HTTP 400, and the skip value "should be a last resort as it will negatively impact model performance" ([Vertex AI, Thought signatures](https://cloud.google.com/vertex-ai/generative-ai/docs/thought-signatures)). OpenClaw never captured that field and never sent it back, and strict id sanitization cut the id copy down to 40 alphanumeric characters. The reporter saw 0 reasoning tokens on every request after a tool result. ## User Impact On LiteLLM-fronted Gemini routes, the signature now goes back with each tool call, so Gemini keeps reasoning after tool results. Requests to plain OpenAI-compatible providers, Google endpoints and Venice do not change. ## Why This Change Was Made - Capture (contributor): `extractToolCallThoughtSignature` also reads `provider_specific_fields.thought_signature` into the existing `toolCall.thoughtSignature`. - Replay (contributor): on non-Google endpoints, `injectToolCallThoughtSignatures` sends back only signatures issued on the same route (same api, provider and model), in `provider_specific_fields.thought_signature`. Cross-route signatures, the skip-validator fallback, truncated signatures and JSON reasoning details (OpenRouter) are never sent there. Google endpoints keep `extra_content.google` as before, and id sanitization is unchanged. - Venice (added on top): Venice already replays its own Gemini signatures in its top-level `thought_signature` field, matched per assistant turn because Venice reuses tool-call ids (openclaw#119783). Without this change Venice requests would also get the generic `provider_specific_fields` copy, which is keyed by id. The Venice adapter now drops that copy, so Venice requests stay byte-identical to main. - Merged current `main`. Line deltas against the merge base: production +24/-9 (stream +5/-0, replay +15/-8, Venice +3), tests +65/-56. ## Evidence Real Gateway from source (`gateway run` + `agent --message` through the Gateway, isolated profile and state). It runs against a local LiteLLM-shaped fixture: the tool-call turn carries `provider_specific_fields.thought_signature` and the `__thought__` id suffix, and the fixture reads the continuation request the way LiteLLM does. Fixture key only. Base and candidate run from the same checkout path so request bodies can be compared. | continuation request after the `read` tool result | main `1ff8a7df373b` | this branch `e113e72c6bc7` | |---|---|---| | replayed tool-call id | `call6055144thoughtQ2lZQjRIMUZ4ZmlYdHVyZT` (signature cut off) | same | | `provider_specific_fields.thought_signature` | absent | the issued signature | | what LiteLLM would send Gemini | `skip_thought_signature_validator` | the real signature | | plain OpenAI-compatible provider, both requests | | byte-identical to main | | Venice Gemini, both requests | | byte-identical to main | Tests: the signature table in `openai-completions-replay.google-signatures.test.ts` fails 2 rows on main (LiteLLM capture, LiteLLM same-route replay). The Venice reused-id case fails on main once the transport field is in its input. All of these pass on this branch, and so do `agent-tools.prefix-stability.test.ts` and all `openai-completions*.test.ts` files. Observed proof lines: openclaw#186942 (comment) Not covered: no run against a real LiteLLM and Vertex deployment (no Vertex credentials). The reporter's direct LiteLLM check shows that sending the signature back brings reasoning back (64/188/160 vs 0/0/0 reasoning tokens). Merge danger: two-way door. The change only shapes outgoing requests and writes no state, so a revert fully undoes it. Blast radius: `openai-completions` routes to non-Google endpoints that issue thought signatures (LiteLLM, plus any other proxy that returns one) now get `provider_specific_fields.thought_signature` back on same-route tool calls. Co-authored-by: Ayaan Zaidi <[email protected]>
…routes (#186942) Root cause: `packages/ai/src/transports/openai-completions-stream.ts:69` (`extractToolCallThoughtSignature`) never reads LiteLLM's `tool_calls[].provider_specific_fields.thought_signature`, and `packages/ai/src/transports/openai-completions-replay.ts:37` returns early for every non-Google endpoint, so a LiteLLM `openai-completions` route never sends Gemini's thought signature back. Strict tool-call id sanitization also cuts LiteLLM's id copy, so LiteLLM falls back to `skip_thought_signature_validator` and Gemini stops reasoning after the first tool result. Fixes #186842. Thanks @bluet for the detailed report and the re-test on 2026.11.5, and @wr-web for the fix. Their commits are kept as they are. ## What Problem This Solves A custom `openai-completions` provider pointed at LiteLLM in front of Gemini 3 loses the thought signature on every tool call: - LiteLLM returns the signature in `tool_calls[].provider_specific_fields.thought_signature` ([LiteLLM Gemini 3 guide, "Thought Signatures"](https://docs.litellm.ai/blog/gemini_3)). It may also add it to the tool-call id as `__thought__<sig>`, but only when `thought_signature_in_tool_call_id` is on. - On the next request LiteLLM reads the signature back from `provider_specific_fields` on the tool call (or its function), then from the id suffix ([`get_thought_signature_from_tool`](https://github.com/BerriAI/litellm/blob/795baa77e5a26828f205c9d6f8389e60cbe36847/litellm/litellm_core_utils/prompt_templates/factory.py#L1307)). If neither has it, LiteLLM sends a dummy `skip_thought_signature_validator` signature. - Gemini 3 needs the signatures from earlier responses sent back: a missing one means HTTP 400, and the skip value "should be a last resort as it will negatively impact model performance" ([Vertex AI, Thought signatures](https://cloud.google.com/vertex-ai/generative-ai/docs/thought-signatures)). OpenClaw never captured that field and never sent it back, and strict id sanitization cut the id copy down to 40 alphanumeric characters. The reporter saw 0 reasoning tokens on every request after a tool result. ## User Impact On LiteLLM-fronted Gemini routes, the signature now goes back with each tool call, so Gemini keeps reasoning after tool results. Requests to plain OpenAI-compatible providers, Google endpoints and Venice do not change. ## Why This Change Was Made - Capture (contributor): `extractToolCallThoughtSignature` also reads `provider_specific_fields.thought_signature` into the existing `toolCall.thoughtSignature`. - Replay (contributor): on non-Google endpoints, `injectToolCallThoughtSignatures` sends back only signatures issued on the same route (same api, provider and model), in `provider_specific_fields.thought_signature`. Cross-route signatures, the skip-validator fallback, truncated signatures and JSON reasoning details (OpenRouter) are never sent there. Google endpoints keep `extra_content.google` as before, and id sanitization is unchanged. - Venice (added on top): Venice already replays its own Gemini signatures in its top-level `thought_signature` field, matched per assistant turn because Venice reuses tool-call ids (#119783). Without this change Venice requests would also get the generic `provider_specific_fields` copy, which is keyed by id. The Venice adapter now drops that copy, so Venice requests stay byte-identical to main. - Merged current `main`. Line deltas against the merge base: production +24/-9 (stream +5/-0, replay +15/-8, Venice +3), tests +65/-56. ## Evidence Real Gateway from source (`gateway run` + `agent --message` through the Gateway, isolated profile and state). It runs against a local LiteLLM-shaped fixture: the tool-call turn carries `provider_specific_fields.thought_signature` and the `__thought__` id suffix, and the fixture reads the continuation request the way LiteLLM does. Fixture key only. Base and candidate run from the same checkout path so request bodies can be compared. | continuation request after the `read` tool result | main `c027899907ab` | this branch `e113e72c6bc7` | |---|---|---| | replayed tool-call id | `call6055144thoughtQ2lZQjRIMUZ4ZmlYdHVyZT` (signature cut off) | same | | `provider_specific_fields.thought_signature` | absent | the issued signature | | what LiteLLM would send Gemini | `skip_thought_signature_validator` | the real signature | | plain OpenAI-compatible provider, both requests | | byte-identical to main | | Venice Gemini, both requests | | byte-identical to main | Tests: the signature table in `openai-completions-replay.google-signatures.test.ts` fails 2 rows on main (LiteLLM capture, LiteLLM same-route replay). The Venice reused-id case fails on main once the transport field is in its input. All of these pass on this branch, and so do `agent-tools.prefix-stability.test.ts` and all `openai-completions*.test.ts` files. Observed proof lines: #186942 (comment) Not covered: no run against a real LiteLLM and Vertex deployment (no Vertex credentials). The reporter's direct LiteLLM check shows that sending the signature back brings reasoning back (64/188/160 vs 0/0/0 reasoning tokens). Merge danger: two-way door. The change only shapes outgoing requests and writes no state, so a revert fully undoes it. Blast radius: `openai-completions` routes to non-Google endpoints that issue thought signatures (LiteLLM, plus any other proxy that returns one) now get `provider_specific_fields.thought_signature` back on same-route tool calls. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit 826a79b) Co-authored-by: RomneyDa <[email protected]>
…routes (openclaw#186942) Root cause: `packages/ai/src/transports/openai-completions-stream.ts:69` (`extractToolCallThoughtSignature`) never reads LiteLLM's `tool_calls[].provider_specific_fields.thought_signature`, and `packages/ai/src/transports/openai-completions-replay.ts:37` returns early for every non-Google endpoint, so a LiteLLM `openai-completions` route never sends Gemini's thought signature back. Strict tool-call id sanitization also cuts LiteLLM's id copy, so LiteLLM falls back to `skip_thought_signature_validator` and Gemini stops reasoning after the first tool result. Fixes openclaw#186842. Thanks @bluet for the detailed report and the re-test on 2026.11.5, and @wr-web for the fix. Their commits are kept as they are. ## What Problem This Solves A custom `openai-completions` provider pointed at LiteLLM in front of Gemini 3 loses the thought signature on every tool call: - LiteLLM returns the signature in `tool_calls[].provider_specific_fields.thought_signature` ([LiteLLM Gemini 3 guide, "Thought Signatures"](https://docs.litellm.ai/blog/gemini_3)). It may also add it to the tool-call id as `__thought__<sig>`, but only when `thought_signature_in_tool_call_id` is on. - On the next request LiteLLM reads the signature back from `provider_specific_fields` on the tool call (or its function), then from the id suffix ([`get_thought_signature_from_tool`](https://github.com/BerriAI/litellm/blob/795baa77e5a26828f205c9d6f8389e60cbe36847/litellm/litellm_core_utils/prompt_templates/factory.py#L1307)). If neither has it, LiteLLM sends a dummy `skip_thought_signature_validator` signature. - Gemini 3 needs the signatures from earlier responses sent back: a missing one means HTTP 400, and the skip value "should be a last resort as it will negatively impact model performance" ([Vertex AI, Thought signatures](https://cloud.google.com/vertex-ai/generative-ai/docs/thought-signatures)). OpenClaw never captured that field and never sent it back, and strict id sanitization cut the id copy down to 40 alphanumeric characters. The reporter saw 0 reasoning tokens on every request after a tool result. ## User Impact On LiteLLM-fronted Gemini routes, the signature now goes back with each tool call, so Gemini keeps reasoning after tool results. Requests to plain OpenAI-compatible providers, Google endpoints and Venice do not change. ## Why This Change Was Made - Capture (contributor): `extractToolCallThoughtSignature` also reads `provider_specific_fields.thought_signature` into the existing `toolCall.thoughtSignature`. - Replay (contributor): on non-Google endpoints, `injectToolCallThoughtSignatures` sends back only signatures issued on the same route (same api, provider and model), in `provider_specific_fields.thought_signature`. Cross-route signatures, the skip-validator fallback, truncated signatures and JSON reasoning details (OpenRouter) are never sent there. Google endpoints keep `extra_content.google` as before, and id sanitization is unchanged. - Venice (added on top): Venice already replays its own Gemini signatures in its top-level `thought_signature` field, matched per assistant turn because Venice reuses tool-call ids (openclaw#119783). Without this change Venice requests would also get the generic `provider_specific_fields` copy, which is keyed by id. The Venice adapter now drops that copy, so Venice requests stay byte-identical to main. - Merged current `main`. Line deltas against the merge base: production +24/-9 (stream +5/-0, replay +15/-8, Venice +3), tests +65/-56. ## Evidence Real Gateway from source (`gateway run` + `agent --message` through the Gateway, isolated profile and state). It runs against a local LiteLLM-shaped fixture: the tool-call turn carries `provider_specific_fields.thought_signature` and the `__thought__` id suffix, and the fixture reads the continuation request the way LiteLLM does. Fixture key only. Base and candidate run from the same checkout path so request bodies can be compared. | continuation request after the `read` tool result | main `c027899907ab` | this branch `e113e72c6bc7` | |---|---|---| | replayed tool-call id | `call6055144thoughtQ2lZQjRIMUZ4ZmlYdHVyZT` (signature cut off) | same | | `provider_specific_fields.thought_signature` | absent | the issued signature | | what LiteLLM would send Gemini | `skip_thought_signature_validator` | the real signature | | plain OpenAI-compatible provider, both requests | | byte-identical to main | | Venice Gemini, both requests | | byte-identical to main | Tests: the signature table in `openai-completions-replay.google-signatures.test.ts` fails 2 rows on main (LiteLLM capture, LiteLLM same-route replay). The Venice reused-id case fails on main once the transport field is in its input. All of these pass on this branch, and so do `agent-tools.prefix-stability.test.ts` and all `openai-completions*.test.ts` files. Observed proof lines: openclaw#186942 (comment) Not covered: no run against a real LiteLLM and Vertex deployment (no Vertex credentials). The reporter's direct LiteLLM check shows that sending the signature back brings reasoning back (64/188/160 vs 0/0/0 reasoning tokens). Merge danger: two-way door. The change only shapes outgoing requests and writes no state, so a revert fully undoes it. Blast radius: `openai-completions` routes to non-Google endpoints that issue thought signatures (LiteLLM, plus any other proxy that returns one) now get `provider_specific_fields.thought_signature` back on same-route tool calls. Co-authored-by: Ayaan Zaidi <[email protected]> (cherry picked from commit 826a79b) Release adaptation: approved 2026.11.7 models replay; see models-hook-safe-v2/REPORT.md. Co-authored-by: RomneyDa <[email protected]>
What Problem This Solves
Venice Gemini tool turns fail on the continuation request because Venice returns an opaque signature at
tool_calls[].thought_signature, requires the exact value to be replayed, and current OpenClaw only captures/replays Google's nested signature forms.Ordinary chat succeeds, but web search, file reads, and other tool-using turns can terminate with HTTP 400 immediately after the tool itself succeeds.
Fixes #119591.
Provenance and Credit
This is a transparent carry-forward of Wen-Yong Lim's closed PR #119593, including its six original commits and authorship. The final original head is
7e1699cb53205719dfca43034796e4df5d12deef.That final head addressed the prior P1 review by replacing transcript-global tool-call ID matching with assistant-turn occurrence matching and adding repeated-ID regressions. The current branch adds only an attribution-preserving merge commit onto current
main; the original head remains its second parent.Implementation
thought_signaturevalues into the existing opaquethoughtSignaturetranscript field.tool_call_idvalues.Google-compatible nested/function signature behavior remains unchanged.
User Impact
Venice Gemini users can complete tool-based workflows instead of receiving an HTTP 400 after successful tool execution. Occurrence-scoped matching also protects resumed and mixed-provider transcripts where different assistant turns reuse the same tool-call ID.
Persistent-State and Upgrade Compatibility
This PR does not introduce a new persisted schema or require a migration:
thoughtSignatureis an existing optional transcript field already used by compatible provider routes;The compatibility policy is deliberate: when an old or foreign transcript lacks a valid Venice signature, textual history is safer than replaying an invalid tool protocol sequence that the provider rejects with HTTP 400.
Compatibility Matrix
tool_call_idin a later assistant turnFocused regressions exercise each of these boundaries, including repeated IDs, mixed signed/unsigned history, foreign-provider turns, transcript sanitization, and contiguous result ownership.
Evidence
Evidence inherited from #119593 and preserved directly in its commit history:
venice/gemini-3-6-flash: the tool ran and the final continuation completed;Current-Head Safety
d64f5b6a096088f1739ecd0e8c2f7182a0e90ce7;426978a4762b5ac216d3bb81bfe7e2d5dcd950c7;mainrefresh merges;7e1699cb53205719dfca43034796e4df5d12deefremains an ancestor and the six original Wen-Yong Lim commits retain their authorship;The implementation diff is patch-identical to reviewed carry-forward head
0a94d2b70b0fde844dcd5e9ae5ed2c7a1828dbad(stable patch ID34d542abb7433f189d734b1bceb4c85599dc0c0d).Verification
The patch-identical carry-forward head passed full hosted CI, build, lint, production/test type checks, CodeQL, CodeQL Critical Quality, OpenGrep, security checks, Workflow Sanity, and all Periphery checks.
Fresh hosted workflows for the current-main merge-refreshed head are still awaiting GitHub scheduling. No implementation patch changed during the refresh.
Maintainer Decision
The only remaining policy decision is whether to accept the route-scoped fallback for legacy unsigned Venice Gemini 3 history. The recommended behavior is the one implemented here: preserve valid signed tool protocol exactly, but degrade only invalid unsigned history to text instead of issuing a request known to fail.
No contributor-side correctness, proof, migration, or unresolved-review blocker remains. Fresh hosted checks on the merge-refreshed head and the maintainer policy decision remain.
Test Plan
thought_signatureAI Assistance
AI assistance was used to inspect the issue and closed PR history, verify that the original final head addressed the earlier P1 review, prove that current main did not overlap the affected files, and construct an attribution-preserving carry-forward. The implementation and original live proof remain Wen-Yong Lim's work.