You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(deepseek): preserve reasoning_content for V4 thinking-mode multi-turn
DeepSeek V4 models enable thinking mode by default and stream chain-of-thought as `reasoning_content`. Per the API contract, any assistant turn that produced a tool call must have its `reasoning_content` echoed back on subsequent turns, otherwise the server returns a 400 error. The OpenAI-compatible provider path was not preserving reasoning in multi-turn tool flows, causing all interactions with V4 to fail.
## Changes
1. **openai_compat.rs stream loop**: Now opens a dedicated Thinking block (index usize::MAX - 100) on first reasoning delta and closes it before text/tool_calls/finish_reason. This ensures reasoning deltas are properly accumulated instead of being silently dropped.
2. **openai_compat.rs message building**: Only includes reasoning_content for providers that require it (currently DeepSeek V4). Added `requires_reasoning_roundtrip` quirk flag to gate this inclusion. Prevents wasting tokens on providers that ignore the field (OpenAI, Groq, Azure, etc.).
3. **Provider registration**: DeepSeek provider explicitly sets `requires_reasoning_roundtrip: true`.
This implementation is based on PR #111 (Kuberwastaken/claurst#111) which identified and fixed the issue. Research shows this requirement is unique to DeepSeek V4; no other major LLM provider has this multi-turn reasoning round-trip requirement.
0 commit comments