fix(deepseek): more aggressive R1 fix and detailed error logging
Some checks failed
CI / Check (push) Has been cancelled
CI / Clippy (push) Has been cancelled
CI / Formatting (push) Has been cancelled
CI / Test (push) Has been cancelled
CI / Release Build (push) Has been cancelled

- Ensure assistant tool calls always have content: "" instead of null.
- Add debug-level logging of the full request body when DeepSeek returns 400.
- Improved R1 placeholder injection to include content sanitation.
This commit is contained in:
2026-03-05 19:11:46 +00:00
parent 1ddb5277e9
commit 6a324c08c7
2 changed files with 18 additions and 9 deletions

View File

@@ -65,10 +65,10 @@ pub async fn messages_to_openai_json(messages: &[UnifiedMessage]) -> Result<Vec<
msg["reasoning_content"] = serde_json::json!(reasoning);
}
// For assistant messages with tool_calls, content can be null
// For assistant messages with tool_calls, content can be empty string
if let Some(tool_calls) = &m.tool_calls {
if parts.is_empty() {
msg["content"] = serde_json::Value::Null;
msg["content"] = serde_json::json!("");
} else {
msg["content"] = serde_json::json!(parts);
}
@@ -143,10 +143,10 @@ pub async fn messages_to_openai_json_text_only(
msg["reasoning_content"] = serde_json::json!(reasoning);
}
// For assistant messages with tool_calls, content can be null
// For assistant messages with tool_calls, content can be empty string
if let Some(tool_calls) = &m.tool_calls {
if parts.is_empty() {
msg["content"] = serde_json::Value::Null;
msg["content"] = serde_json::json!("");
} else {
msg["content"] = serde_json::json!(parts);
}