Skip to content

fix(gemini): preserve per-tool-call thought signatures#3140

Open
macro-ss wants to merge 1 commit into
charmbracelet:mainfrom
B3-Buidler:main
Open

fix(gemini): preserve per-tool-call thought signatures#3140
macro-ss wants to merge 1 commit into
charmbracelet:mainfrom
B3-Buidler:main

Conversation

@macro-ss

@macro-ss macro-ss commented Jun 17, 2026

Copy link
Copy Markdown

Gemini 3 thinking models attach a thoughtSignature to each function-call
part that must be replayed verbatim on that specific part. crush stored a
single ReasoningContent per assistant message and concatenated every
signature into one string (AppendThoughtSignature), losing per-call
association. On replay ToAIMessage sent the concatenated blob as one
signature, so Gemini rejected the request with 'Corrupted thought
signature'. The corrupted signature was persisted, poisoning the whole
session and recurring across restarts.

  • message.ToolCall: add ThoughtSignature field; preserve it in FinishToolCall/AppendToolCallInput; add SetToolCallThoughtSignature
  • stop reasoning mutators (FinishThinking, AppendReasoningContent, SetReasoningResponsesData) from silently dropping signature fields
  • ToAIMessage: emit each signature in its own ReasoningPart immediately before its text/tool-call part instead of concatenating
  • agent: buffer per-toolID signatures in OnReasoningEnd and attach them to the matching tool call in OnToolCall

Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com

  • I have read CONTRIBUTING.md.
  • I have created a discussion that was approved by a maintainer (for new features).

  Gemini 3 thinking models attach a thoughtSignature to each function-call
  part that must be replayed verbatim on that specific part. crush stored a
  single ReasoningContent per assistant message and concatenated every
  signature into one string (AppendThoughtSignature), losing per-call
  association. On replay ToAIMessage sent the concatenated blob as one
  signature, so Gemini rejected the request with 'Corrupted thought
  signature'. The corrupted signature was persisted, poisoning the whole
  session and recurring across restarts.

  - message.ToolCall: add ThoughtSignature field; preserve it in
    FinishToolCall/AppendToolCallInput; add SetToolCallThoughtSignature
  - stop reasoning mutators (FinishThinking, AppendReasoningContent,
    SetReasoningResponsesData) from silently dropping signature fields
  - ToAIMessage: emit each signature in its own ReasoningPart immediately
    before its text/tool-call part instead of concatenating
  - agent: buffer per-toolID signatures in OnReasoningEnd and attach them
    to the matching tool call in OnToolCall

  Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@charmcli

Copy link
Copy Markdown
Contributor

Thank you for your submission. We really appreciate it! Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request comment same as the below format.


I have read the Contributor License Agreement (CLA) and hereby sign the CLA.


You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

@macro-ss

Copy link
Copy Markdown
Author

bugfix for the same issue: #1698

@macro-ss

macro-ss commented Jun 17, 2026

Copy link
Copy Markdown
Author

I have read the Contributor License Agreement (CLA) and hereby sign the CLA.

@macro-ss

Copy link
Copy Markdown
Author

recheck

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants