mirror of
https://github.com/HKUDS/nanobot.git
synced 2026-04-27 13:25:52 +00:00
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 <menglingao@xiaomi.com>
This commit is contained in:
parent
05fe7d4fb1
commit
3f8eafc89a
@ -21,6 +21,7 @@ if TYPE_CHECKING:
|
|||||||
|
|
||||||
_ALLOWED_MSG_KEYS = frozenset({
|
_ALLOWED_MSG_KEYS = frozenset({
|
||||||
"role", "content", "tool_calls", "tool_call_id", "name",
|
"role", "content", "tool_calls", "tool_call_id", "name",
|
||||||
|
"reasoning_content", "extra_content",
|
||||||
})
|
})
|
||||||
_ALNUM = string.ascii_letters + string.digits
|
_ALNUM = string.ascii_letters + string.digits
|
||||||
|
|
||||||
|
|||||||
@ -54,7 +54,7 @@ class Session:
|
|||||||
out: list[dict[str, Any]] = []
|
out: list[dict[str, Any]] = []
|
||||||
for message in sliced:
|
for message in sliced:
|
||||||
entry: dict[str, Any] = {"role": message["role"], "content": message.get("content", "")}
|
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:
|
if key in message:
|
||||||
entry[key] = message[key]
|
entry[key] = message[key]
|
||||||
out.append(entry)
|
out.append(entry)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user