fix: handle reasoning_content in OpenRouter thinking model responses#6014
fix: handle reasoning_content in OpenRouter thinking model responses#6014lireno wants to merge 1 commit into
Conversation
When using OpenRouter with thinking models (Anthropic Claude, Google Gemini), the API returns a reasoning_content field alongside content in streaming deltas and response messages. The OpenAI completion handlers were only checking the content field, causing empty responses and ValueError when reasoning_content contained the actual response text. This fix adds fallback to reasoning_content in both streaming and non-streaming paths (sync and async), gated with isinstance(str) checks for robustness with mock objects. Fixes crewAIInc#5537 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughOpenAI completion handling now supports models that emit ChangesOpenAI completion reasoning_content fallback
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 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
When using OpenRouter with thinking models (Anthropic Claude, Google Gemini), the API returns a reasoning_content field alongside content in streaming deltas and response messages. The OpenAI completion handlers were only checking the content field, causing empty responses and ValueError: Invalid response from LLM call - None or empty.
Changes
Testing
All 121 existing tests pass (OpenAI completions and OpenAI-compatible providers).
Fixes #5537
🤖 Generated with Claude Code
Summary by CodeRabbit