-
Notifications
You must be signed in to change notification settings - Fork 512
fix(gemini): Add skip thought signature #1298
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(gemini): Add skip thought signature #1298
Conversation
…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
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
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): |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
Description
Fixes Gemini 3 Pro multi-turn function calling by adding
skip_thought_signature_validatorto toolUse parts.Gemini 3 Pro requires a
thought_signaturefield when sending function call history back to the model. Without it, requests fail with: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_signatureis included in formatted toolUse contentAdded parameterized integration test running multi-turn tool use against both
gemini-2.5-flashandgemini-3-pro-previewIntegration test fails on main for Gemini 3 Pro, passes with this fix
I ran
hatch run prepareChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.