mirror of
https://github.com/nesquena/hermes-webui.git
synced 2026-05-27 12:10:40 +00:00
fix: preserve reasoning_content in API message whitelist
Providers like Xiaomi MiMo, DeepSeek, and Kimi require reasoning_content to be echoed back on every assistant message in multi-turn conversations with tool calls. Omitting it causes HTTP 400: 'The reasoning_content in the thinking mode must be passed back to the API.' The WebUI's _sanitize_messages_for_api() strips all fields not in _API_SAFE_MSG_KEYS before sending conversation history to the LLM API. reasoning_content was not in this whitelist, so it was silently dropped. The CLI path (run_agent.py) is unaffected because it has its own _copy_reasoning_content_for_api() logic that operates on raw message dicts without going through this filter. This is why the same session works from CLI but fails from WebUI with HTTP 400. The fix adds 'reasoning_content' to _API_SAFE_MSG_KEYS so the field passes through sanitization intact.
This commit is contained in:
+1
-1
@@ -266,7 +266,7 @@ from api.workspace import set_last_workspace
|
||||
# Fields that are safe to send to LLM provider APIs.
|
||||
# Everything else (attachments, timestamp, _ts, etc.) is display-only
|
||||
# metadata added by the webui and must be stripped before the API call.
|
||||
_API_SAFE_MSG_KEYS = {'role', 'content', 'tool_calls', 'tool_call_id', 'name', 'refusal'}
|
||||
_API_SAFE_MSG_KEYS = {'role', 'content', 'tool_calls', 'tool_call_id', 'name', 'refusal', 'reasoning_content'}
|
||||
|
||||
_NATIVE_IMAGE_MAX_BYTES = 20 * 1024 * 1024
|
||||
|
||||
|
||||
Reference in New Issue
Block a user