Skip to content

feat(gemini): add thought signature preservation for thinking models#1622

Draft
pgrayy wants to merge 1 commit intostrands-agents:mainfrom
pgrayy:gemini-thought-signature
Draft

feat(gemini): add thought signature preservation for thinking models#1622
pgrayy wants to merge 1 commit intostrands-agents:mainfrom
pgrayy:gemini-thought-signature

Conversation

@pgrayy
Copy link
Member

@pgrayy pgrayy commented Feb 3, 2026

Description

Related Issues

Documentation PR

Type of Change

Bug fix
New feature
Breaking change
Documentation update
Other (please describe):

Testing

How have you tested the change? Verify that the changes do not break functionality or introduce warnings in consuming repositories: agents-docs, agents-tools, agents-cli

  • I ran hatch run prepare

Checklist

  • I have read the CONTRIBUTING document
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly
  • I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@github-actions github-actions bot added the size/m label Feb 3, 2026
@codecov
Copy link

codecov bot commented Feb 3, 2026

Codecov Report

❌ Patch coverage is 72.72727% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/strands/event_loop/streaming.py 0.00% 2 Missing and 2 partials ⚠️
src/strands/models/gemini.py 86.66% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@pgrayy pgrayy force-pushed the gemini-thought-signature branch from 192e3c7 to 2811c58 Compare February 3, 2026 18:15
@github-actions github-actions bot added size/m and removed size/m labels Feb 3, 2026
@pgrayy pgrayy force-pushed the gemini-thought-signature branch from 2811c58 to 6450f71 Compare February 3, 2026 18:16
@github-actions github-actions bot added size/m and removed size/m labels Feb 3, 2026
@mkmeral
Copy link
Contributor

mkmeral commented Feb 6, 2026

/strands review

current_tool_use["name"] = tool_use_data["name"]
current_tool_use["input"] = ""
if "reasoningSignature" in tool_use_data:
current_tool_use["reasoningSignature"] = tool_use_data["reasoningSignature"]
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Issue: Missing test coverage for reasoningSignature handling.

Codecov reports 0% patch coverage for the streaming.py changes. The existing parameterized tests for handle_content_block_start and handle_content_block_stop should be extended to cover the reasoningSignature field.

Suggestion: Add test cases to the existing parameterized tests in test_streaming.py:

# In test_handle_content_block_start parameters:
(
    {"start": {"toolUse": {"toolUseId": "test", "name": "test", "reasoningSignature": "YWJj"}}},
    {"toolUseId": "test", "name": "test", "input": "", "reasoningSignature": "YWJj"},
),

# In test_handle_content_block_stop parameters (with reasoningSignature):
(
    {
        "content": [],
        "current_tool_use": {"toolUseId": "123", "name": "test", "input": '{}', "reasoningSignature": "YWJj"},
        "text": "",
        "reasoningText": "",
        "citationsContent": [],
        "redactedContent": b"",
    },
    {
        "content": [{"toolUse": {"toolUseId": "123", "name": "test", "input": {}, "reasoningSignature": "YWJj"}}],
        ...
    },
),

@github-actions
Copy link

github-actions bot commented Feb 6, 2026

Issue: PR description is incomplete.

Please update the PR description to include:

  • A detailed description of what this change does (thought signature preservation for thinking models)
  • Select the appropriate type of change (appears to be "New feature")
  • Confirm testing checklist items (particularly hatch run prepare)
  • Link any related issues if applicable

This helps reviewers understand the context and purpose of the changes.

@github-actions
Copy link

github-actions bot commented Feb 6, 2026

Review Summary

Assessment: Request Changes

Overview

This PR adds thought signature preservation for Gemini thinking models by:

  1. Properly handling reasoningSignature in tool use content blocks
  2. Using base64 encoding/decoding for the thought signatures
  3. Updating type definitions to include the new field

Key Themes

Test Coverage Gap (Important)
The streaming.py changes have 0% test coverage according to Codecov. The existing parameterized tests in test_streaming.py should be extended to cover the reasoningSignature field in both handle_content_block_start and handle_content_block_stop.

PR Documentation
The PR description template should be filled out to help reviewers understand the purpose and testing status of these changes.

What Looks Good

  • ✅ Correct base64 encoding/decoding for thought signatures
  • ✅ Comprehensive tests for the Gemini model request formatting
  • ✅ Type definitions properly updated with NotRequired annotation
  • ✅ Follows existing code patterns and conventions

Requested Changes

  1. Add test cases for reasoningSignature handling in test_streaming.py
  2. Consider adding a response-side test for tool use with thought signature
  3. Update the PR description with context about the changes

Overall the implementation looks solid - just needs the test coverage addressed before merging.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants