fix: disable Gemini thinking to prevent thought_signature replay errors#348
fix: disable Gemini thinking to prevent thought_signature replay errors#348
Conversation
Gemini 2.5+ and 3.x models enable thinking by default, which attaches a thought_signature to each tool call in the response. @convex-dev/agent does not preserve these signatures through DB storage, so when the conversation history is replayed on the next turn Gemini rejects it with "Function call is missing a thought_signature in functionCall parts". Fixes this by passing providerOptions.google.thinkingConfig.thinkingBudget=0 to every streamText call for Gemini, which disables thinking entirely and prevents signatures from being generated in the first place. Also removes the now-unused re-exports from resilience.ts (they were only consumed by resilience.test.ts) and updates that test file to import directly from the source modules. Fixes TONALCOACH-1C https://claude.ai/code/session_015HuaomY3nPah7idvmUGoJz
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThis PR refactors the resilience module to clean up the public API by removing backward-compatibility re-exports, implements Gemini "thinking" budget control in streaming calls, updates test imports accordingly, and adds comprehensive test coverage validating the Gemini-specific provider options behavior. ChangesGemini Thinking Control and Module Cleanup
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
thought_signatureto every tool call in the response.@convex-dev/agentdoes not preserve these provider-specific signatures when it persists messages to the database. On the next conversation turn, when the stored tool calls are replayed to Gemini without theirthought_signature, the API rejects the entire request with "Function call is missing a thought_signature in functionCall parts" — surfacing as the generic "I'm having trouble right now" error for users.providerOptions: { google: { thinkingConfig: { thinkingBudget: 0 } } }to every GeministreamTextcall. This disables thinking at the call level, preventingthought_signaturefrom ever being generated and eliminating the replay requirement entirely — for both new and existing conversations.resilience.ts(originally for test convenience) and updatedresilience.test.tsto import directly from the authoritative source modules (./byokErrors,./transientErrors).Changes
convex/ai/resilience.tsproviderOptions.google.thinkingConfig.thinkingBudget=0tothread.streamText()for Gemini; remove stale re-exportsconvex/ai/resilience.test.tsbuildByokErrorMessage,classifyByokError,withByokErrorSanitization,isTransientErrordirectly from source modulesconvex/ai/resilienceStreamFailure.test.tsthinkingBudget: 0providerOptions; Claude/OpenAI/OpenRouter calls do notTest plan
npx vitest run --project backend)resilienceStreamFailure.test.tsverify the fix is applied for Gemini and not for other providersresilience.tshttps://claude.ai/code/session_015HuaomY3nPah7idvmUGoJz
Generated by Claude Code
Summary by CodeRabbit
Updates
Refactor