[Bug] deepseek-v4-flash lacks multi-turn reasoning_content handling — fails after tool calls
Summary
deepseek-v4-flash defaults to thinking mode enabled. When the agent performs tool calls, DeepSeek returns reasoning_content that MUST be preserved in subsequent requests. LibreFang's OpenAI driver does NOT preserve it for V4 Flash — only for deepseek-reasoner/R1 and Kimi.
Result: agent works for simple messages, but as soon as a tool is called, subsequent requests fail with 400/500 errors. Agent becomes unusable until session reset.
Reproduce
- Configure an agent with model
deepseek-v4-flash
- Send simple messages → ✅ works
- Send a message that triggers a tool call (e.g.,
memory_search, ask_agent, shell_exec)
- All subsequent messages → ❌ 500 / "Sorry, something went wrong"
Switching to deepseek-chat (V3, no thinking mode) or deepseek-reasoner (R1, handled) works fine.
Root cause
In crates/librefang-llm-drivers/src/drivers/openai.rs:
1. is_deepseek_reasoner() — only matches R1, not V4 Flash:
fn is_deepseek_reasoner(&self, model: &str) -> bool {
let m = model.to_lowercase();
m.contains("deepseek-reasoner") || m.contains("deepseek-r1")
// deepseek-v4-flash is NOT matched
}
2. reasoning_content is set to None for V4 Flash:
reasoning_content: if is_deepseek_r {
None // R1: strips it (correct)
} else if has_tool_calls
&& self.kimi_needs_reasoning_content(...) {
Some(String::new()) // Kimi: empty string (correct)
} else {
None // V4 Flash: ignored → BUG
},
3. thinking mode is never disabled for V4 Flash:
thinking: if self.kimi_needs_reasoning_content(&request.model) {
Some(serde_json::json!({"type": "disabled"})) // only Kimi
} else {
None // V4 Flash: thinking ON → BUG
},
Per DeepSeek API docs:
"for turns that do perform tool calls, the reasoning_content must be fully passed back to the API in all subsequent requests. If your code does not correctly pass back reasoning_content, the API will return a 400 error."
Expected behavior
Either:
- Pass
reasoning_content back to DeepSeek API after tool calls (like Kimi does)
- Or disable thinking mode via
thinking: {"type": "disabled"} for V4 Flash
Workaround
Use deepseek-chat (V3) which has no thinking mode, or deepseek-v4-pro.
Environment
- LibreFang: v2026.5.8-beta.10
- Model: deepseek-v4-flash
[Bug]
deepseek-v4-flashlacks multi-turnreasoning_contenthandling — fails after tool callsSummary
deepseek-v4-flashdefaults to thinking mode enabled. When the agent performs tool calls, DeepSeek returnsreasoning_contentthat MUST be preserved in subsequent requests. LibreFang's OpenAI driver does NOT preserve it for V4 Flash — only fordeepseek-reasoner/R1 and Kimi.Result: agent works for simple messages, but as soon as a tool is called, subsequent requests fail with 400/500 errors. Agent becomes unusable until session reset.
Reproduce
deepseek-v4-flashmemory_search,ask_agent,shell_exec)Switching to
deepseek-chat(V3, no thinking mode) ordeepseek-reasoner(R1, handled) works fine.Root cause
In
crates/librefang-llm-drivers/src/drivers/openai.rs:1.
is_deepseek_reasoner()— only matches R1, not V4 Flash:2.
reasoning_contentis set toNonefor V4 Flash:3.
thinkingmode is never disabled for V4 Flash:Per DeepSeek API docs:
Expected behavior
Either:
reasoning_contentback to DeepSeek API after tool calls (like Kimi does)thinking: {"type": "disabled"}for V4 FlashWorkaround
Use
deepseek-chat(V3) which has no thinking mode, ordeepseek-v4-pro.Environment