fix(google): Fix 400 Bad Request error with Gemini 3 thought signatures
Summary
Gemini 3 models require thought_signature in tool calls and responses, and thinking content must be echoed back in the conversation loop. Changes: - Replace thought_signature field with generic metadata field on ToolRequest/ToolResponse - Add ProviderMetadata type alias for provider-specific data - Google provider stores thoughtSignature in metadata - Helper functions for Google-specific metadata extraction - Preserve thinking content in conversation when tool calls are processed - Handle signature inheritance for multi-part responses - Text-only responses treated as final answer (not thinking)
Type of Change
- [ ] Feature
- [x] Bug fix
- [x] Refactor / Code quality
- [ ] Performance improvement
- [ ] Documentation
- [x] Tests
- [ ] Security fix
- [ ] Build / Release
- [ ] Other (specify below)
AI Assistance
- [x] This PR was created or reviewed with AI assistance
Testing
Unit tests and manual testing
Related Issues
Relates to #5792 Relates to #6091
thanks @rabi for diving on this. this is a good start, but I am not sure it does everything yet. the spec says that gemini can reply with thinking messages and that we then have to keep the conversation going.
other things to note: shouldn't we just always have an optional thought signature on toolcall/response messages? the testing seems rather convoluted, I'd rather do one big round-trip thing where we construct a conversation in our native format and, convert it to google, have some asserts and then convert it back and then verify that it is the same. that would be then a parttern we can easily copy into other format checkers (since they need to be cross provider compatible)
let me know if you want to continue working on this, I do really appreciate the effort and gemini has been annoying in how they change their api without telling us
here's the related bug report: https://github.com/block/goose/issues/6091
let me know if you want to continue working on this, I do really appreciate the effort and gemini has been annoying in how they change their api without telling us
Thanks @DOsinga for reviewing. I think I've addressed your comments in the last push. Let me know.