diff --git a/src/core/assistant-message/presentAssistantMessage.ts b/src/core/assistant-message/presentAssistantMessage.ts index 519a1dc0fa..d7a3d83125 100644 --- a/src/core/assistant-message/presentAssistantMessage.ts +++ b/src/core/assistant-message/presentAssistantMessage.ts @@ -481,10 +481,12 @@ export async function presentAssistantMessage(cline: Task) { const toolCallId = (block as any).id const toolProtocol = toolCallId ? TOOL_PROTOCOL.NATIVE : TOOL_PROTOCOL.XML - // Check experimental setting for multiple native tool calls + // Check if parallel tool calls are enabled + // This should match the parallelToolCallsEnabled flag passed to the API const provider = cline.providerRef.deref() const state = await provider?.getState() - const isMultipleNativeToolCallsEnabled = experiments.isEnabled( + // Use the same logic as Task.ts to determine if parallel tool calls are enabled + const parallelToolCallsEnabled = experiments.isEnabled( state?.experiments ?? {}, EXPERIMENT_IDS.MULTIPLE_NATIVE_TOOL_CALLS, ) @@ -545,18 +547,18 @@ export async function presentAssistantMessage(cline: Task) { } // For XML protocol: Only one tool per message is allowed - // For native protocol with experimental flag enabled: Multiple tools can be executed in sequence - // For native protocol with experimental flag disabled: Single tool per message (default safe behavior) + // For native protocol with parallel tool calls enabled: Multiple tools can be executed in sequence + // For native protocol with parallel tool calls disabled: Single tool per message (default safe behavior) if (toolProtocol === TOOL_PROTOCOL.XML) { // Once a tool result has been collected, ignore all other tool // uses since we should only ever present one tool result per // message (XML protocol only). cline.didAlreadyUseTool = true - } else if (toolProtocol === TOOL_PROTOCOL.NATIVE && !isMultipleNativeToolCallsEnabled) { - // For native protocol with experimental flag disabled, enforce single tool per message + } else if (toolProtocol === TOOL_PROTOCOL.NATIVE && !parallelToolCallsEnabled) { + // For native protocol with parallel tool calls disabled, enforce single tool per message cline.didAlreadyUseTool = true } - // If toolProtocol is NATIVE and isMultipleNativeToolCallsEnabled is true, + // If toolProtocol is NATIVE and parallelToolCallsEnabled is true, // allow multiple tool calls in sequence (don't set didAlreadyUseTool) }