fix: flush block reply coalescer on tool boundaries
When block streaming is enabled with verbose=off, tool blocks are hidden but their boundary information was lost. Text segments before and after tool execution would get coalesced into a single message because the coalescer had no signal that a tool had executed between them. This adds an onBlockReplyFlush callback that fires on tool_execution_start, allowing the block reply pipeline to flush pending text before the tool runs. This preserves natural message boundaries even when tools are hidden. Fixes the issue where: text → [hidden tool] → text → rendered as one merged message Now correctly renders as: text → [hidden tool] → text → two separate messages Co-diagnosed-by: Krill (Discord assistant)
This commit is contained in:
committed by
Peter Steinberger
parent
d4d15c8a71
commit
c64bcd047b
@@ -643,6 +643,12 @@ export async function runReplyAgent(params: {
|
||||
blockReplyPipeline?.enqueue(blockPayload);
|
||||
}
|
||||
: undefined,
|
||||
onBlockReplyFlush:
|
||||
blockStreamingEnabled && blockReplyPipeline
|
||||
? async () => {
|
||||
await blockReplyPipeline.flush({ force: true });
|
||||
}
|
||||
: undefined,
|
||||
shouldEmitToolResult,
|
||||
onToolResult: opts?.onToolResult
|
||||
? (payload) => {
|
||||
|
||||
Reference in New Issue
Block a user