From 2ffeb9295bdb4a5ef308498f60f45b2448ab48d2 Mon Sep 17 00:00:00 2001 From: lailoo Date: Wed, 11 Mar 2026 00:47:09 +0800 Subject: [PATCH] fix(subagent): preserve reasoning_content in assistant messages Subagent's _run_subagent() was dropping reasoning_content and thinking_blocks when building assistant messages for the conversation history. Providers like Deepseek Reasoner require reasoning_content on every assistant message when thinking mode is active, causing a 400 BadRequestError on the second LLM round-trip. Align with the main AgentLoop which already preserves these fields via ContextBuilder.add_assistant_message(). Closes #1834 --- nanobot/agent/subagent.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/nanobot/agent/subagent.py b/nanobot/agent/subagent.py index f9eda1f..308e67d 100644 --- a/nanobot/agent/subagent.py +++ b/nanobot/agent/subagent.py @@ -145,11 +145,19 @@ class SubagentManager: } for tc in response.tool_calls ] - messages.append({ + assistant_msg: dict[str, Any] = { "role": "assistant", "content": response.content or "", "tool_calls": tool_call_dicts, - }) + } + # Preserve reasoning_content for providers that require it + # (e.g. Deepseek Reasoner mandates this field on every + # assistant message when thinking mode is active). + if response.reasoning_content is not None: + assistant_msg["reasoning_content"] = response.reasoning_content + if response.thinking_blocks: + assistant_msg["thinking_blocks"] = response.thinking_blocks + messages.append(assistant_msg) # Execute tools for tool_call in response.tool_calls: