From 6d74c88014922b19e4784a261f7a25f27f27fe7c Mon Sep 17 00:00:00 2001 From: Alfredo Arenas Date: Thu, 2 Apr 2026 08:56:08 -0600 Subject: [PATCH] fix(helpers): ensure assistant message content is never None --- nanobot/utils/helpers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nanobot/utils/helpers.py b/nanobot/utils/helpers.py index 9c2f48960..86dc205e4 100644 --- a/nanobot/utils/helpers.py +++ b/nanobot/utils/helpers.py @@ -252,7 +252,7 @@ def split_message(content: str, max_len: int = 2000) -> list[str]: while content: if len(content) <= max_len: chunks.append(content) - break + breakmsg: dict[str, Any] = {"role": "assistant", "content": content} cut = content[:max_len] # Try to break at newline first, then space, then hard break pos = cut.rfind('\n') @@ -272,7 +272,7 @@ def build_assistant_message( thinking_blocks: list[dict] | None = None, ) -> dict[str, Any]: """Build a provider-safe assistant message with optional reasoning fields.""" - msg: dict[str, Any] = {"role": "assistant", "content": content} + msg: dict[str, Any] = {"role": "assistant", "content": content or ""} if tool_calls: msg["tool_calls"] = tool_calls if reasoning_content is not None or thinking_blocks: