fix(litellm): preserve reasoning content in history using convertToR1Format#892
fix(litellm): preserve reasoning content in history using convertToR1Format#892daewoongoh wants to merge 3 commits into
Conversation
…Format - Map 'preserveReasoning' and 'reasoningEffort' from LiteLLM proxy response - Use 'convertToR1Format' with 'mergeToolResultText: true' when 'preserveReasoning' is enabled to prevent reasoning drop - Append 'reasoning_effort' parameter for supported models Signed-off-by: daewoongoh <dw.oh@samsung.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughLiteLLM model metadata now carries reasoning settings; ChangesLiteLLM reasoning support
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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 |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
- Add none, minimal, xhigh, max options to reasoning_effort parameter typecast - Add test coverage for preserveReasoning and reasoningEffort in fetcher and handler Signed-off-by: daewoongoh <dw.oh@samsung.com>
7fa8ac9 to
3d87abf
Compare
|
P1: Respect the user’s reasoning-effort settings for LiteLLM
Please resolve the effective effort through the shared model-parameter / |
Related GitHub Issue
Closes: #891
Description
This PR fixes an issue where reasoning blocks were lost in multi-turn conversations when using reasoning-capable models through the LiteLLM provider.
Changes made:
preserveReasoningandreasoningEffortfrom the LiteLLM proxy response (ModelInfo).convertToR1FormatwithmergeToolResultText: truewhenpreserveReasoningis enabled. This accurately merges tool results with subsequent user texts to prevent strict APIs (like DeepSeek) from dropping thereasoning_content.LiteLLMHandlerto ensure a clean fallback toconvertToOpenAiMessageswhen the flag is absent or disabled.lite-llm.spec.tsverifying thatconvertToR1Formatcorrectly merges tool results and preserves the reasoning blocks for LiteLLM models.Test Procedure
deepseek-reasoner(or any model supportingpreserveReasoning).reasoning_contentremains intact in the assistant's message history.pnpm --filter=zoo-code test -- -t "preserve reasoning when preserveReasoning is true").Pre-Submission Checklist
Documentation Updates
Get in Touch
hehegwk_23849
Summary by CodeRabbit