Skip to content

Conversation

@mkmeral
Copy link
Contributor

@mkmeral mkmeral commented Dec 5, 2025

Description

Fixes Gemini 3 Pro multi-turn function calling by adding skip_thought_signature_validator to toolUse parts.

Gemini 3 Pro requires a thought_signature field when sending function call history back to the model. Without it, requests fail with:

Function call is missing a thought_signature in functionCall parts

This PR uses Google's documented workaround (skip_thought_signature_validator) to bypass the validation until we implement proper thought signature preservation.

Reference: https://ai.google.dev/gemini-api/docs/thought-signatures

Related Issues

Fixes #1199

Documentation PR

N/A - no user-facing API changes

Type of Change

Bug fix

Testing

  • Added unit test verifying thought_signature is included in formatted toolUse content

  • Added parameterized integration test running multi-turn tool use against both gemini-2.5-flash and gemini-3-pro-preview

  • Integration test fails on main for Gemini 3 Pro, passes with this fix

  • 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.

Murat Kaan Meral added 2 commits December 5, 2025 12:07
…mpatibility

Gemini 3 Pro requires thought_signature to be passed back during multi-turn
function calling. As a temporary workaround, we use the skip_thought_signature_validator
bypass to get the model working without modifying the SDK's core type system.

This is a short-term fix. A proper implementation that preserves thought signatures
through the message history will be addressed in a follow-up PR.

Fixes strands-agents#1199
@github-actions github-actions bot added the size/s label Dec 5, 2025
@mkmeral mkmeral changed the title Fix/gemini 3 pro thought signature skip fix(gemini): Add skip thought signature Dec 5, 2025
@codecov
Copy link

codecov bot commented Dec 5, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@dpolistwm
Copy link

Cross-posting here:

Hey @mkmeral, I understand your concern, but implementing this workaround and degrading the tought process of such a popular model would make strands agents a "second class citizen" among other frameworks in the market.

Many users may stop using Strands Agents with Gemini 3 Pro (one of the most popular, fast and powerful LLMs in the market) if this is the official solution and probably choose ADK instead. While it does not support AWS Agentcore directly (memory, etc.), it does support Google's equally feature-rich AgentEngine counterpart. We would certainly consider that.

Please take this risk into account when making your decision.



@pytest.mark.asyncio
async def test_stream_request_with_tool_use_includes_thought_signature_skip(gemini_client, model, model_id):
Copy link
Member

Choose a reason for hiding this comment

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

Nit: Look like test_stream_request_with_tool_use already captures this use case and so looks like we don't need an additional test here.

if "toolUse" in content:
# Use skip_thought_signature_validator to bypass Gemini 3 Pro's strict validation
# This is a temporary workaround until we implement proper thought signature preservation
# See: https://ai.google.dev/gemini-api/docs/thought-signatures
Copy link
Member

Choose a reason for hiding this comment

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

Are we creating our own issue to track the permanent fix.

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.

[BUG] INVALID_ARGUMENT using gemini-3-pro-preview

3 participants