mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 07:21:23 +00:00
refactor(agents): reuse embedded block flush helper
This commit is contained in:
@@ -67,15 +67,7 @@ export function handleAgentEnd(ctx: EmbeddedPiSubscribeContext) {
|
||||
});
|
||||
}
|
||||
|
||||
if (ctx.params.onBlockReply) {
|
||||
if (ctx.blockChunker?.hasBuffered()) {
|
||||
ctx.blockChunker.drain({ force: true, emit: ctx.emitBlockChunk });
|
||||
ctx.blockChunker.reset();
|
||||
} else if (ctx.state.blockBuffer.length > 0) {
|
||||
ctx.emitBlockChunk(ctx.state.blockBuffer);
|
||||
ctx.state.blockBuffer = "";
|
||||
}
|
||||
}
|
||||
ctx.flushBlockReplyBuffer();
|
||||
|
||||
ctx.state.blockState.thinking = false;
|
||||
ctx.state.blockState.final = false;
|
||||
|
||||
@@ -201,13 +201,7 @@ export function handleMessageUpdate(
|
||||
}
|
||||
|
||||
if (evtType === "text_end" && ctx.state.blockReplyBreak === "text_end") {
|
||||
if (ctx.blockChunker?.hasBuffered()) {
|
||||
ctx.blockChunker.drain({ force: true, emit: ctx.emitBlockChunk });
|
||||
ctx.blockChunker.reset();
|
||||
} else if (ctx.state.blockBuffer.length > 0) {
|
||||
ctx.emitBlockChunk(ctx.state.blockBuffer);
|
||||
ctx.state.blockBuffer = "";
|
||||
}
|
||||
ctx.flushBlockReplyBuffer();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user