From 3f8eafc89ac225fed260ac1527fe3cd28ac5aae2 Mon Sep 17 00:00:00 2001 From: Lingao Meng Date: Sat, 4 Apr 2026 11:52:22 +0800 Subject: [PATCH] fix(provider): restore reasoning_content and extra_content in message sanitization reasoning_content and extra_content were accidentally dropped from _ALLOWED_MSG_KEYS. Also fix session/manager.py to include reasoning_content when building LLM messages from session history, so the field is not lost across turns. Without this fix, providers such as Kimi, emit reasoning_content in assistant messages will have it stripped on the next request, breaking multi-turn thinking mode. Fixes: https://github.com/HKUDS/nanobot/issues/2777 Signed-off-by: Lingao Meng --- nanobot/providers/openai_compat_provider.py | 1 + nanobot/session/manager.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/nanobot/providers/openai_compat_provider.py b/nanobot/providers/openai_compat_provider.py index 4fa057b90..132f05a28 100644 --- a/nanobot/providers/openai_compat_provider.py +++ b/nanobot/providers/openai_compat_provider.py @@ -21,6 +21,7 @@ if TYPE_CHECKING: _ALLOWED_MSG_KEYS = frozenset({ "role", "content", "tool_calls", "tool_call_id", "name", + "reasoning_content", "extra_content", }) _ALNUM = string.ascii_letters + string.digits diff --git a/nanobot/session/manager.py b/nanobot/session/manager.py index 95e3916b9..27df31405 100644 --- a/nanobot/session/manager.py +++ b/nanobot/session/manager.py @@ -54,7 +54,7 @@ class Session: out: list[dict[str, Any]] = [] for message in sliced: entry: dict[str, Any] = {"role": message["role"], "content": message.get("content", "")} - for key in ("tool_calls", "tool_call_id", "name"): + for key in ("tool_calls", "tool_call_id", "name", "reasoning_content"): if key in message: entry[key] = message[key] out.append(entry)