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
This commit is contained in:
@@ -145,11 +145,19 @@ class SubagentManager:
|
|||||||
}
|
}
|
||||||
for tc in response.tool_calls
|
for tc in response.tool_calls
|
||||||
]
|
]
|
||||||
messages.append({
|
assistant_msg: dict[str, Any] = {
|
||||||
"role": "assistant",
|
"role": "assistant",
|
||||||
"content": response.content or "",
|
"content": response.content or "",
|
||||||
"tool_calls": tool_call_dicts,
|
"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
|
# Execute tools
|
||||||
for tool_call in response.tool_calls:
|
for tool_call in response.tool_calls:
|
||||||
|
|||||||
Reference in New Issue
Block a user