mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 03:12:42 +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) {
|
ctx.flushBlockReplyBuffer();
|
||||||
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.state.blockState.thinking = false;
|
ctx.state.blockState.thinking = false;
|
||||||
ctx.state.blockState.final = false;
|
ctx.state.blockState.final = false;
|
||||||
|
|||||||
@@ -201,13 +201,7 @@ export function handleMessageUpdate(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (evtType === "text_end" && ctx.state.blockReplyBreak === "text_end") {
|
if (evtType === "text_end" && ctx.state.blockReplyBreak === "text_end") {
|
||||||
if (ctx.blockChunker?.hasBuffered()) {
|
ctx.flushBlockReplyBuffer();
|
||||||
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 = "";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user