fix: sanitize messages and ensure 'content' for strict LLM providers

- Strip non-standard keys like 'reasoning_content' before sending to LLM
- Always include 'content' key in assistant messages (required by StepFun)
- Add _sanitize_messages to LiteLLMProvider to prevent 400 BadRequest errors
This commit is contained in:
Ivan
2026-02-18 11:57:58 +03:00
parent ce4f00529e
commit e44f14379a
2 changed files with 28 additions and 4 deletions
+3 -3
View File
@@ -227,9 +227,9 @@ To recall past events, grep {workspace_path}/memory/HISTORY.md"""
"""
msg: dict[str, Any] = {"role": "assistant"}
# Omit empty content — some backends reject empty text blocks
if content:
msg["content"] = content
# Always include content — some providers (e.g. StepFun) reject
# assistant messages that omit the key entirely.
msg["content"] = content
if tool_calls:
msg["tool_calls"] = tool_calls