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:
commit
7a11ff95a9
4 changed files with 4 additions and 4 deletions
|
|
@ -81,7 +81,7 @@ class _CodexCompletionsAdapter:
|
||||||
input_msgs: List[Dict[str, Any]] = []
|
input_msgs: List[Dict[str, Any]] = []
|
||||||
for msg in messages:
|
for msg in messages:
|
||||||
role = msg.get("role", "user")
|
role = msg.get("role", "user")
|
||||||
content = msg.get("content", "")
|
content = msg.get("content") or ""
|
||||||
if role == "system":
|
if role == "system":
|
||||||
instructions = content
|
instructions = content
|
||||||
else:
|
else:
|
||||||
|
|
|
||||||
2
cli.py
2
cli.py
|
|
@ -1285,7 +1285,7 @@ class HermesCLI:
|
||||||
|
|
||||||
for i, msg in enumerate(self.conversation_history, 1):
|
for i, msg in enumerate(self.conversation_history, 1):
|
||||||
role = msg.get("role", "unknown")
|
role = msg.get("role", "unknown")
|
||||||
content = msg.get("content", "")
|
content = msg.get("content") or ""
|
||||||
|
|
||||||
if role == "user":
|
if role == "user":
|
||||||
print(f"\n [You #{i}]")
|
print(f"\n [You #{i}]")
|
||||||
|
|
|
||||||
|
|
@ -442,7 +442,7 @@ class HonchoSessionManager:
|
||||||
for msg in messages:
|
for msg in messages:
|
||||||
ts = msg.get("timestamp", "?")
|
ts = msg.get("timestamp", "?")
|
||||||
role = msg.get("role", "unknown")
|
role = msg.get("role", "unknown")
|
||||||
content = msg.get("content", "")
|
content = msg.get("content") or ""
|
||||||
lines.append(f"[{ts}] {role}: {content}")
|
lines.append(f"[{ts}] {role}: {content}")
|
||||||
|
|
||||||
lines.append("")
|
lines.append("")
|
||||||
|
|
|
||||||
|
|
@ -3441,7 +3441,7 @@ class AIAgent:
|
||||||
self._codex_incomplete_retries += 1
|
self._codex_incomplete_retries += 1
|
||||||
|
|
||||||
interim_msg = self._build_assistant_message(assistant_message, finish_reason)
|
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
|
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:
|
if interim_has_content or interim_has_reasoning:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue