From 5cc019bf1a53df1fd2ff1e50cd40b4e358804a4f Mon Sep 17 00:00:00 2001 From: Re-bin Date: Fri, 20 Feb 2026 11:27:21 +0000 Subject: [PATCH] style: trim verbose comments in _sanitize_messages --- nanobot/providers/litellm_provider.py | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/nanobot/providers/litellm_provider.py b/nanobot/providers/litellm_provider.py index 4fe44f7..edeb5c6 100644 --- a/nanobot/providers/litellm_provider.py +++ b/nanobot/providers/litellm_provider.py @@ -12,9 +12,7 @@ from nanobot.providers.base import LLMProvider, LLMResponse, ToolCallRequest from 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): @staticmethod def _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}