Merge PR #277: fix: handle None message content across codebase

Fixes #276. Replace msg.get('content', '') with msg.get('content') or ''
in 4 vulnerable message-processing paths.
This commit is contained in:
teknium1 2026-03-02 02:42:35 -08:00
commit 7a11ff95a9
4 changed files with 4 additions and 4 deletions

View file

@ -81,7 +81,7 @@ class _CodexCompletionsAdapter:
input_msgs: List[Dict[str, Any]] = []
for msg in messages:
role = msg.get("role", "user")
content = msg.get("content", "")
content = msg.get("content") or ""
if role == "system":
instructions = content
else:

2
cli.py
View file

@ -1285,7 +1285,7 @@ class HermesCLI:
for i, msg in enumerate(self.conversation_history, 1):
role = msg.get("role", "unknown")
content = msg.get("content", "")
content = msg.get("content") or ""
if role == "user":
print(f"\n [You #{i}]")

View file

@ -442,7 +442,7 @@ class HonchoSessionManager:
for msg in messages:
ts = msg.get("timestamp", "?")
role = msg.get("role", "unknown")
content = msg.get("content", "")
content = msg.get("content") or ""
lines.append(f"[{ts}] {role}: {content}")
lines.append("")

View file

@ -3441,7 +3441,7 @@ class AIAgent:
self._codex_incomplete_retries += 1
interim_msg = self._build_assistant_message(assistant_message, finish_reason)
interim_has_content = bool(interim_msg.get("content", "").strip())
interim_has_content = bool((interim_msg.get("content") or "").strip())
interim_has_reasoning = bool(interim_msg.get("reasoning", "").strip()) if isinstance(interim_msg.get("reasoning"), str) else False
if interim_has_content or interim_has_reasoning: