fix(agent-ui): reset streamed text at generation boundaries in agent chat#10664
fix(agent-ui): reset streamed text at generation boundaries in agent chat#10664walcz-de wants to merge 1 commit into
Conversation
…chat 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>
|
Verified this against the streaming path: cogito emits a StreamEventDone at the end of every LLM call, and the dispatcher forwards it as a 'done' stream_event, so one agent turn does produce several content segments on the same channel. On master the UI only resets the accumulated text on the final json_message, so intermediate-generation text really does bleed into the final answer bubble. Resetting streamContent/streamReasoning at the 'done' boundary is the right minimal fix, and leaving streamToolCalls untouched is correct since the tool activity list is cleared by json_message. Only side effect is a brief empty live bubble between the last 'done' and the json_message, which is fine given the authoritative answer arrives right after. CI is green and the branch is mergeable. @mudler this looks good to merge. |
What
One agent turn runs several internal LLM generations (tool selection, reasoning, final answer) that all emit
stream_eventdeltas over the same per-agent SSE channel. The agent chat page accumulates everycontentdelta into a single live bubble and ignores thedoneboundary events — so the internal generations' text (e.g. the English tool-selection rationale) merges with, and visually corrupts, the streamed final answer.Fix
Reset the accumulated content/reasoning when a
donestream event arrives: each generation gets a clean live bubble. The authoritative full answer still arrives via the finaljson_messageevent exactly as before, so no information is lost.Related server-side ordering fix: mudler/LocalAGI#483 (SSE broadcast worker pool scrambles delta order).
🤖 Generated with Claude Code
https://claude.ai/code/session_01KYp5FnAfsdGb6yjLmv8Mge