fix(web): save assistant content with reasoning

This commit is contained in:
JOJO 2025-11-18 10:53:14 +08:00
parent d809ec7136
commit 41bc56491f

View File

@ -3090,12 +3090,6 @@ async def handle_task_with_sender(terminal: WebTerminal, message, sender, client
'content': f'⚠️ 修改操作存在未完成的内容:{error_message}' 'content': f'⚠️ 修改操作存在未完成的内容:{error_message}'
}) })
text_streaming = False
text_started = False
text_has_content = False
full_response = ""
# 保存思考内容(如果这是第一次迭代且有思考) # 保存思考内容(如果这是第一次迭代且有思考)
if web_terminal.thinking_mode and web_terminal.api_client.current_task_first_call: if web_terminal.thinking_mode and web_terminal.api_client.current_task_first_call:
web_terminal.api_client.current_task_thinking = current_thinking or "" web_terminal.api_client.current_task_thinking = current_thinking or ""
@ -3158,6 +3152,12 @@ async def handle_task_with_sender(terminal: WebTerminal, message, sender, client
reasoning_content=current_thinking or None reasoning_content=current_thinking or None
) )
# 为下一轮迭代重置流状态标志,但保留 full_response 供上面保存使用
text_streaming = False
text_started = False
text_has_content = False
full_response = ""
if append_result["handled"] and append_result.get("tool_content"): if append_result["handled"] and append_result.get("tool_content"):
tool_call_id = append_result.get("tool_call_id") or f"append_{int(time.time() * 1000)}" tool_call_id = append_result.get("tool_call_id") or f"append_{int(time.time() * 1000)}"
system_notice = format_tool_result_notice("append_to_file", tool_call_id, append_result["tool_content"]) system_notice = format_tool_result_notice("append_to_file", tool_call_id, append_result["tool_content"])