From 56f7be6c7fd57c75dd611601e616e8981b41f93f Mon Sep 17 00:00:00 2001 From: daniel-lxs Date: Tue, 2 Dec 2025 14:58:19 -0500 Subject: [PATCH] fix: add explicit native toolProtocol check for parallel subtask queuing --- src/core/tools/NewTaskTool.ts | 7 +++++-- src/core/tools/__tests__/newTaskTool.spec.ts | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/core/tools/NewTaskTool.ts b/src/core/tools/NewTaskTool.ts index 233d5d81e2..77ef97223b 100644 --- a/src/core/tools/NewTaskTool.ts +++ b/src/core/tools/NewTaskTool.ts @@ -147,13 +147,16 @@ export class NewTaskTool extends BaseTool<"new_task"> { task.checkpointSave(true) } - // Queue this new_task if there are: + // Queue this new_task if using native tool protocol AND there are: // 1. Multiple new_task blocks (to execute sequentially), OR // 2. Any remaining tool blocks after this one (so they can execute before delegation) + // NOTE: XML protocol processes tools one at a time, so this condition is always false for XML. + // We add an explicit check for clarity and defensive safety. + const isNativeToolProtocol = toolProtocol === "native" const newTaskBlockCount = countNewTaskBlocks(task) const hasRemainingTools = hasRemainingToolBlocks(task) - if (newTaskBlockCount > 1 || hasRemainingTools) { + if (isNativeToolProtocol && (newTaskBlockCount > 1 || hasRemainingTools)) { task.pendingSubtasks.push({ toolCallId: toolCallId ?? "", message: unescapedMessage, diff --git a/src/core/tools/__tests__/newTaskTool.spec.ts b/src/core/tools/__tests__/newTaskTool.spec.ts index 0b9df1d6aa..0b4fbb9614 100644 --- a/src/core/tools/__tests__/newTaskTool.spec.ts +++ b/src/core/tools/__tests__/newTaskTool.spec.ts @@ -775,7 +775,7 @@ describe("newTaskTool parallel execution", () => { handleError: vi.fn(), pushToolResult: mockPushToolResult, removeClosingTag: vi.fn((_: string, v?: string) => v ?? ""), - toolProtocol: "xml", + toolProtocol: "native", // Native protocol is required for parallel tool execution toolCallId: "tool-1", }) @@ -802,7 +802,7 @@ describe("newTaskTool parallel execution", () => { handleError: vi.fn(), pushToolResult: mockPushToolResult, removeClosingTag: vi.fn((_: string, v?: string) => v ?? ""), - toolProtocol: "xml", + toolProtocol: "native", // Native protocol is required for parallel tool execution toolCallId: "tool-2", })