fix: filter empty assistant messages in _save_turn instead of patching at send time
This commit is contained in:
@@ -451,6 +451,8 @@ class AgentLoop:
|
||||
for m in messages[skip:]:
|
||||
entry = {k: v for k, v in m.items() if k != "reasoning_content"}
|
||||
role, content = entry.get("role"), entry.get("content")
|
||||
if role == "assistant" and not content and not entry.get("tool_calls"):
|
||||
continue # skip empty assistant messages — they poison session context
|
||||
if role == "tool" and isinstance(content, str) and len(content) > self._TOOL_RESULT_MAX_CHARS:
|
||||
entry["content"] = content[:self._TOOL_RESULT_MAX_CHARS] + "\n... (truncated)"
|
||||
elif role == "user":
|
||||
|
||||
Reference in New Issue
Block a user