Files
kandev/apps/backend
João Salavisa 1806b87e7e fix(lifecycle): don't split streaming messages on subagent tool calls (#1756)
* fix(lifecycle): don't split streaming messages on subagent tool calls

A subagent's internal tool calls (ParentToolCallID set) stream on the same
session concurrently with the parent agent's own text. Flushing the message
buffer on those events closed the parent's in-flight streaming message, so
each subagent tool call started a new message row — splitting one logical
message mid-sentence and breaking markdown (e.g. **bold** spans rendered as
literal asterisks) across the fragments.

Only flush on top-level tool calls; subagent-internal ones leave the parent's
streaming segment open.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* refactor(lifecycle): drop dead flush-text branch in tool call handler

flushMessageBuffer always publishes remaining content through the streaming
path and returns "", so the event.Text / history-append branch could never
execute. Call it directly instead of through a helper carrying dead code.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: Kandev Agent <agent@kandev.dev>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
2026-07-17 14:31:28 +01:00
..