fix(agent-ui): reset streamed text at generation boundaries in agent chat (#10664)

One agent turn runs several internal LLM generations (tool selection,
reasoning, final answer) that all emit stream_event deltas over the same
per-agent SSE channel. The chat page accumulated every 'content' delta
into a single live bubble and ignored the 'done' boundary events, so the
internal generations' text (e.g. the English tool-selection rationale)
merged with — and visually corrupted — the streamed final answer.

Reset the accumulated content/reasoning on 'done': each generation gets
a clean live bubble, and the authoritative full answer still arrives via
the final json_message event as before.

Signed-off-by: Stefan Walcz <stefan.walcz@walcz.de>
This commit is contained in:
walcz-de
2026-07-17 15:26:50 +02:00
committed by GitHub
parent 3f8806b0b2
commit 6ccb1130d8

View File

@@ -221,7 +221,14 @@ export default function AgentChat() {
return updated
})
} else if (data.type === 'done') {
// Content will be finalized by json_message event
// One agent turn runs several internal LLM generations (tool
// selection, reasoning, final answer) over the same SSE channel;
// 'done' marks the boundary between them. Reset the accumulated
// text so an internal generation's output doesn't merge into the
// next one's bubble — the final json_message carries the
// authoritative full answer anyway.
setStreamContent('')
setStreamReasoning('')
}
} catch (_err) {
// ignore