From 56058287ddb26c105c37e87a4751f533a52a1a17 Mon Sep 17 00:00:00 2001 From: wizardchen Date: Thu, 7 May 2026 17:27:51 +0800 Subject: [PATCH] fix(agent): drop whitespace-only thinking events from the steps tree MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some LLMs (e.g. qwen3 series) emit blank lines like "\n\n" before tool calls. The backend faithfully forwards these as thought_chunk events because streamThinkingToEventBus only filters chunk.Content == "" and treats whitespace as content. The frontend then merges them into a thinking event whose content is non-empty in JS truthiness terms but visually empty, producing a "思考" card with a chevron and no text. Filter such events out at the end of buildFullEventList so neither the intermediate-steps tree nor the displayEvents fallback path renders them. --- .../src/views/chat/components/AgentStreamDisplay.vue | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/frontend/src/views/chat/components/AgentStreamDisplay.vue b/frontend/src/views/chat/components/AgentStreamDisplay.vue index d3b9168a..c1f488d0 100644 --- a/frontend/src/views/chat/components/AgentStreamDisplay.vue +++ b/frontend/src/views/chat/components/AgentStreamDisplay.vue @@ -1057,7 +1057,17 @@ const buildFullEventList = (stream: any[]) => { result.push(event); } - return result; + + // Drop thinking events whose content is whitespace-only. Some models emit + // "\n\n" before a tool call (see e.g. qwen3 emitting blank lines between + // [assistant] and tool_calls), which the backend faithfully forwards as + // thought_chunk events. Without this filter the tree shows an empty + // "思考" card with no text — confusing to the user. + return result.filter((e: any) => { + if (e.type !== 'thinking') return true; + const content = typeof e.content === 'string' ? e.content : ''; + return content.trim().length > 0; + }); }; // IDs of thinking events that should NOT be rendered in the intermediate-