Skip to content

fix(responses): preserve Gemini text thought signatures - #43435

Draft
Alex0AI wants to merge 1 commit into
BerriAI:mainfrom
Alex0AI:fix-gemini-responses-text-signatures
Draft

Alex0AI wants to merge 1 commit into
BerriAI:mainfrom
Alex0AI:fix-gemini-responses-text-signatures

Conversation

@Alex0AI

@Alex0AI Alex0AI commented Sep 27, 2026

Copy link
Copy Markdown

TLDR

Problem this solves:

  • Responses replay loses Gemini signatures attached to text

How it solves it:

  • Preserve text signatures on Responses message items
  • Restore the original signed text when replaying those items

User Flow

Before: a developer replays a Gemini tool turn through the Responses API and loses its signed reasoning state

  1. They POST to http://localhost:4000/v1/responses using Gemini with thinking and a tool
  2. The answer includes text followed by a tool call
  3. They send the output items back with the tool result, but the text signature is absent

After: the same tool turn preserves its text signature when replayed

  1. They POST to http://localhost:4000/v1/responses using Gemini with thinking and a tool
  2. The answer includes text followed by a tool call
  3. They send the output items back with the tool result, and the text signature is restored

Relevant issues

Fixes #43011

Local verification

The two affected Responses transformation test files pass: 239 tests. The regression follows a serialized Responses message through tool-history replay into the Gemini request and checks both signed and unsigned text, preserving whitespace

Running the added test against the merge base f4308bc1 gives one failure and one pass. The signed case fails because the outgoing text part lacks thoughtSignature. Restoring this fix makes both cases pass

Ruff and git diff --check pass. The affected module has the same diagnostic counts as the merge base under basedpyright and the type discipline checker

Pre-Submission checklist

  • I have added meaningful tests
  • The handful of test files covering my change pass locally
  • My PR passes all required CI/CD checks
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • I have received a Greptile Confidence Score of at least 4/5 before requesting a maintainer review

Type

Bug Fix

Caveats

Low

  • Real Gemini and interactive client QA remain unverified
  • This fixes full-input replay; previous_response_id needs separate verification

Final Attestation

  • The tests check the right things, including the edge cases, and regressions in the respective real-world customer use-cases are not possible after this PR

@codspeed

codspeed Bot commented Sep 27, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing Alex0AI:fix-gemini-responses-text-signatures (de9a25d) with main (f4308bc)

Open in CodSpeed

@codecov

codecov Bot commented Sep 27, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 86.20690% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...itellm_completion_transformation/transformation.py 86.20% 4 Missing ⚠️

📢 Thoughts on this report? Let us know!

This branch has not been deployed

No deployments
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.

[Bug]: /v1/responses bridge drops Gemini thought signatures on text parts

1 participant