fix(agent): drop whitespace-only thinking events from the steps tree

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.
This commit is contained in:
wizardchen
2026-05-07 17:27:51 +08:00
committed by lyingbug
parent 921e4c015a
commit 56058287dd
@@ -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-