From 7615bd36ca438801a72f685c4682c8b7c6a01b32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E6=BD=AE?= Date: Tue, 19 May 2026 18:54:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9mcp=E5=8D=8F=E8=AE=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routes/chat.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/routes/chat.py b/routes/chat.py index 18bf248..9fa6ebb 100644 --- a/routes/chat.py +++ b/routes/chat.py @@ -93,6 +93,7 @@ async def enhanced_generate_stream_response( chunk_id = 0 message_tag = "" current_tool_name = "" + current_is_ui_tool = False last_answer_first_char_duration_ms = None waiting_for_answer_first_char = False agent, checkpointer, sandbox = await init_agent(config) @@ -114,9 +115,12 @@ async def enhanced_generate_stream_response( chunk_args = tool_call_chunk.get("args") if isinstance(tool_call_chunk, dict) else getattr(tool_call_chunk, "args", None) if chunk_name: current_tool_name = chunk_name + current_is_ui_tool = False # Always output ui:// protocol tool calls even when tool_response is disabled - is_ui_tool = isinstance(chunk_args, str) and '"ui://' in (chunk_args or '') - if config.tool_response or is_ui_tool: + # Detect ui:// in chunk args; once detected, all subsequent chunks for this tool are UI + if isinstance(chunk_args, str) and '"ui://' in chunk_args: + current_is_ui_tool = True + if config.tool_response or current_is_ui_tool: if chunk_name: new_content = f"[{message_tag}] {chunk_name}\n" if chunk_args: