diff --git a/src/core/assistant-message/__tests__/presentAssistantMessage-parallel-tools.spec.ts b/src/core/assistant-message/__tests__/presentAssistantMessage-parallel-tools.spec.ts index 3d2f58539e..0ec2f4447a 100644 --- a/src/core/assistant-message/__tests__/presentAssistantMessage-parallel-tools.spec.ts +++ b/src/core/assistant-message/__tests__/presentAssistantMessage-parallel-tools.spec.ts @@ -237,6 +237,7 @@ describe("presentAssistantMessage - Parallel Tool Execution Timing", () => { // Even if the tool executed, userMessageContentReady should NOT be true // because the stream hasn't completed yet (more content may arrive) // Note: The fix specifically checks both conditions + expect(mockTask.userMessageContentReady).toBe(false) }) it("should handle mcp_tool_use blocks the same as tool_use blocks", async () => { diff --git a/src/core/assistant-message/presentAssistantMessage.ts b/src/core/assistant-message/presentAssistantMessage.ts index 7520b87df1..03fe0039e4 100644 --- a/src/core/assistant-message/presentAssistantMessage.ts +++ b/src/core/assistant-message/presentAssistantMessage.ts @@ -1029,7 +1029,8 @@ export async function presentAssistantMessage(cline: Task) { // CRITICAL: For parallel tool execution, we must verify all tool results // are collected before signaling ready. Without this check, the message // queue could proceed before all tool_result blocks are in userMessageContent. - if (areAllToolResultsCollected(cline)) { + // Also verify the stream is complete - more content may still arrive. + if (cline.didCompleteReadingStream && areAllToolResultsCollected(cline)) { cline.userMessageContentReady = true // Will allow `pWaitFor` to continue. } }