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
@@ -1313,6 +1313,8 @@ export async function runEmbeddedPiAgent(params: {
|
||||
mediaUrls?: string[];
|
||||
audioAsVoice?: boolean;
|
||||
}) => void | Promise<void>;
|
||||
/** Flush pending block replies (e.g., before tool execution to preserve message boundaries). */
|
||||
onBlockReplyFlush?: () => void | Promise<void>;
|
||||
blockReplyBreak?: "text_end" | "message_end";
|
||||
blockReplyChunking?: BlockReplyChunking;
|
||||
onReasoningStream?: (payload: {
|
||||
@@ -1669,6 +1671,7 @@ export async function runEmbeddedPiAgent(params: {
|
||||
onToolResult: params.onToolResult,
|
||||
onReasoningStream: params.onReasoningStream,
|
||||
onBlockReply: params.onBlockReply,
|
||||
onBlockReplyFlush: params.onBlockReplyFlush,
|
||||
blockReplyBreak: params.blockReplyBreak,
|
||||
blockReplyChunking: params.blockReplyChunking,
|
||||
onPartialReply: params.onPartialReply,
|
||||
|
||||
Reference in New Issue
Block a user