From 18ad1fe1563616c86d6fef579628251d42bce1f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E6=BD=AE?= Date: Mon, 18 May 2026 12:43:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96ask=5Fuser?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- routes/chat.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/routes/chat.py b/routes/chat.py index 5511cfe..ad90592 100644 --- a/routes/chat.py +++ b/routes/chat.py @@ -92,6 +92,7 @@ async def enhanced_generate_stream_response( logger.info(f"Starting agent stream response") chunk_id = 0 message_tag = "" + current_tool_name = "" last_answer_first_char_duration_ms = None waiting_for_answer_first_char = False agent, checkpointer, sandbox = await init_agent(config) @@ -108,10 +109,13 @@ async def enhanced_generate_stream_response( if msg.tool_call_chunks: message_tag = "TOOL_CALL" waiting_for_answer_first_char = False - if config.tool_response: - for tool_call_chunk in msg.tool_call_chunks: - chunk_name = tool_call_chunk.get("name") if isinstance(tool_call_chunk, dict) else getattr(tool_call_chunk, "name", None) - chunk_args = tool_call_chunk.get("args") if isinstance(tool_call_chunk, dict) else getattr(tool_call_chunk, "args", None) + for tool_call_chunk in msg.tool_call_chunks: + chunk_name = tool_call_chunk.get("name") if isinstance(tool_call_chunk, dict) else getattr(tool_call_chunk, "name", None) + 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 + # Always output ask_user tool calls even when tool_response is disabled + if config.tool_response or current_tool_name == 'ask_user': if chunk_name: new_content = f"[{message_tag}] {chunk_name}\n" if chunk_args: