Your lightweight open-source personal agent.
Python agent-frameworkai-agentai-agentschatbotchatopsdiscord-botllm-agentsllmslocal-llmmcpmodel-context-protocolmulti-agentopenai-compatibleopenclawpersonal-ai-assistantpythonself-hostedtelegram-bot-ai-assistantwebuiworkflow-automation
style: trim verbose comments in _sanitize_messages
Re-bin5cc019bf1a53
diff --git a/nanobot/providers/litellm_provider.py b/nanobot/providers/litellm_provider.pyindex 4fe44f7c8..edeb5c678 100644--- a/nanobot/providers/litellm_provider.py+++ b/nanobot/providers/litellm_provider.py@@ -12,9 +12,7 @@ from nanobot.providers.base import LLMProvider, LLMResponse, ToolCallRequestfrom nanobot.providers.registry import find_by_model, find_gateway-# Keys that are part of the OpenAI chat-completion message schema.-# Anything else (e.g. reasoning_content, timestamp) is stripped before sending-# to avoid "Unrecognized chat message" errors from strict providers like StepFun.+# Standard OpenAI chat-completion message keys; extras (e.g. reasoning_content) are stripped for strict providers._ALLOWED_MSG_KEYS = frozenset({"role", "content", "tool_calls", "tool_call_id", "name"})@@ -155,13 +153,7 @@ class LiteLLMProvider(LLMProvider):@staticmethoddef _sanitize_messages(messages: list[dict[str, Any]]) -> list[dict[str, Any]]:- """Strip non-standard keys from messages for strict providers.-- Some providers (e.g. StepFun via OpenRouter) reject messages that- contain extra keys like ``reasoning_content``. This method keeps- only the keys defined in the OpenAI chat-completion schema and- ensures every assistant message has a ``content`` key.- """+ """Strip non-standard keys and ensure assistant messages have a content key."""sanitized = []for msg in messages:clean = {k: v for k, v in msg.items() if k in _ALLOWED_MSG_KEYS}