Skip to content

Commit 24bec99

Browse files
committed
fix: restore presentAssistantMessage for all partial blocks
PR #9542 added a condition that only called presentAssistantMessage() if there was at least one non-tool_use partial block. This broke XML protocol because XML tools are parsed from the text stream (not via native events), and when only a malformed tool_use was the partial block, presentAssistantMessage was never called, causing a hang. This commit restores the original behavior that works for both protocols.
1 parent aaf4317 commit 24bec99

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/core/task/Task.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2940,9 +2940,11 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
29402940
this.assistantMessageContent = parsedBlocks
29412941
}
29422942

2943-
// Only present partial blocks that were just completed (from XML parsing)
2944-
// Native tool blocks were already presented during streaming, so don't re-present them
2945-
if (partialBlocks.length > 0 && partialBlocks.some((block) => block.type !== "tool_use")) {
2943+
// Present any partial blocks that were just completed
2944+
// For XML protocol: includes both text and tool_use blocks parsed from the text stream
2945+
// For native protocol: tool_use blocks were already presented during streaming via
2946+
// tool_call_partial events, but we still need to present them if they exist (e.g., malformed)
2947+
if (partialBlocks.length > 0) {
29462948
// If there is content to update then it will complete and
29472949
// update `this.userMessageContentReady` to true, which we
29482950
// `pWaitFor` before making the next request.

0 commit comments

Comments
 (0)