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
fix: preserve reasoning_content in conversation history for thinking models
Re-bin2931694eb893
diff --git a/README.md b/README.mdindex 326f253e6..d3dcaf7e4 100644--- a/README.md+++ b/README.md@@ -16,7 +16,7 @@⚡️ Delivers core agent functionality in just **~4,000** lines of code — **99% smaller** than Clawdbot's 430k+ lines.-📏 Real-time line count: **3,429 lines** (run `bash core_agent_lines.sh` to verify anytime)+📏 Real-time line count: **3,437 lines** (run `bash core_agent_lines.sh` to verify anytime)## 📢 Newsdiff --git a/nanobot/agent/context.py b/nanobot/agent/context.pyindex 3ea6c04f0..d80785416 100644--- a/nanobot/agent/context.py+++ b/nanobot/agent/context.py@@ -207,7 +207,8 @@ When remembering something, write to {workspace_path}/memory/MEMORY.md"""self,messages: list[dict[str, Any]],content: str | None,- tool_calls: list[dict[str, Any]] | None = None+ tool_calls: list[dict[str, Any]] | None = None,+ reasoning_content: str | None = None,) -> list[dict[str, Any]]:"""Add an assistant message to the message list.@@ -216,6 +217,7 @@ When remembering something, write to {workspace_path}/memory/MEMORY.md"""messages: Current message list.content: Message content.tool_calls: Optional tool calls.+ reasoning_content: Thinking output (Kimi, DeepSeek-R1, etc.).Returns:Updated message list.@@ -225,5 +227,9 @@ When remembering something, write to {workspace_path}/memory/MEMORY.md"""if tool_calls:msg["tool_calls"] = tool_calls+ # Thinking models reject history without this+ if reasoning_content:+ msg["reasoning_content"] = reasoning_content+messages.append(msg)return messagesdiff --git a/nanobot/agent/loop.py b/nanobot/agent/loop.pyindex a65f3a558..72ea86a2d 100644--- a/nanobot/agent/loop.py+++ b/nanobot/agent/loop.py@@ -213,7 +213,8 @@ class AgentLoop:for tc in response.tool_calls]messages = self.context.add_assistant_message(- messages, response.content, tool_call_dicts+ messages, response.content, tool_call_dicts,+ reasoning_content=response.reasoning_content,)# Execute tools@@ -317,7 +318,8 @@ class AgentLoop:for tc in response.tool_calls]messages = self.context.add_assistant_message(- messages, response.content, tool_call_dicts+ messages, response.content, tool_call_dicts,+ reasoning_content=response.reasoning_content,)for tool_call in response.tool_calls:diff --git a/nanobot/providers/base.py b/nanobot/providers/base.pyindex 08e44ac4c..c69c38be0 100644--- a/nanobot/providers/base.py+++ b/nanobot/providers/base.py@@ -20,6 +20,7 @@ class LLMResponse:tool_calls: list[ToolCallRequest] = field(default_factory=list)finish_reason: str = "stop"usage: dict[str, int] = field(default_factory=dict)+ reasoning_content: str | None = None # Kimi, DeepSeek-R1 etc.@propertydef has_tool_calls(self) -> bool:diff --git a/nanobot/providers/litellm_provider.py b/nanobot/providers/litellm_provider.pyindex 5e9c22f9a..621a71d87 100644--- a/nanobot/providers/litellm_provider.py+++ b/nanobot/providers/litellm_provider.py@@ -183,11 +183,14 @@ class LiteLLMProvider(LLMProvider):"total_tokens": response.usage.total_tokens,}+ reasoning_content = getattr(message, "reasoning_content", None)+return LLMResponse(content=message.content,tool_calls=tool_calls,finish_reason=choice.finish_reason or "stop",usage=usage,+ reasoning_content=reasoning_content,)def get_default_model(self) -> str: