fix(agent): force flush remaining text before call tools (#134)

This commit is contained in:
斬風千雪
2026-02-26 23:59:49 +08:00
committed by GitHub
parent dfcfc4aff4
commit d4ad1597e3
+14
View File
@@ -499,6 +499,20 @@ export const createAgent = (
break
}
case 'tool-call':
// Flush any remaining buffered content before ending the text stream.
const remainder = attachmentsExtractor.flushRemainder()
if (remainder.visibleText) {
yield {
type: 'text_delta',
delta: remainder.visibleText,
}
}
if (remainder.attachments.length) {
yield {
type: 'attachment_delta',
attachments: remainder.attachments,
}
}
yield {
type: 'tool_call_start',
toolName: chunk.toolName,