Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,11 @@ describe("presentAssistantMessage - Image Handling in Native Tool Calling", () =

const textBlocks = mockTask.userMessageContent.filter((item: any) => item.type === "text")
expect(textBlocks.length).toBeGreaterThan(0)
expect(textBlocks.some((b: any) => String(b.text).includes("XML tool calls are no longer supported"))).toBe(
true,
)
expect(
textBlocks.some((b: any) =>
String(b.text).includes("does not fully support OpenAI's function/tool calling"),
),
).toBe(true)
// Should not proceed to execute tool or add images as tool output.
expect(mockTask.userMessageContent.some((item: any) => item.type === "image")).toBe(false)
})
Expand Down Expand Up @@ -331,9 +333,11 @@ describe("presentAssistantMessage - Image Handling in Native Tool Calling", () =
await presentAssistantMessage(mockTask)

const textBlocks = mockTask.userMessageContent.filter((item: any) => item.type === "text")
expect(textBlocks.some((b: any) => String(b.text).includes("XML tool calls are no longer supported"))).toBe(
true,
)
expect(
textBlocks.some((b: any) =>
String(b.text).includes("does not fully support OpenAI's function/tool calling"),
),
).toBe(true)
// Ensure no tool_result blocks were added
expect(mockTask.userMessageContent.some((item: any) => item.type === "tool_result")).toBe(false)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,11 @@ describe("presentAssistantMessage - Unknown Tool Handling", () => {
// Should not execute tool; should surface a clear error message.
const textBlocks = mockTask.userMessageContent.filter((item: any) => item.type === "text")
expect(textBlocks.length).toBeGreaterThan(0)
expect(textBlocks.some((b: any) => String(b.text).includes("XML tool calls are no longer supported"))).toBe(
true,
)
expect(
textBlocks.some((b: any) =>
String(b.text).includes("does not fully support OpenAI's function/tool calling"),
),
).toBe(true)

// Verify consecutiveMistakeCount was incremented
expect(mockTask.consecutiveMistakeCount).toBe(1)
Expand Down
8 changes: 6 additions & 2 deletions src/core/assistant-message/presentAssistantMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,9 @@ export async function presentAssistantMessage(cline: Task) {
// fail fast with a clear error.
if (containsXmlToolMarkup(content)) {
const errorMessage =
"XML tool calls are no longer supported. Remove any XML tool markup (e.g. <read_file>...</read_file>) and use native tool calling instead."
"The model is outputting XML-formatted tool calls instead of using native function calling. " +
"This typically happens when your API provider does not fully support OpenAI's function/tool calling feature. " +
"Please verify that your API provider supports native tool calling, or try using a different provider."
cline.consecutiveMistakeCount++
await cline.say("error", errorMessage)
cline.userMessageContent.push({ type: "text", text: errorMessage })
Expand All @@ -335,7 +337,9 @@ export async function presentAssistantMessage(cline: Task) {
const toolCallId = (block as any).id as string | undefined
if (!toolCallId) {
const errorMessage =
"Invalid tool call: missing tool_use.id. XML tool calls are no longer supported. Remove any XML tool markup (e.g. <read_file>...</read_file>) and use native tool calling instead."
"Invalid tool call: the model's tool call is missing a required ID. " +
"This typically happens when your API provider does not fully support OpenAI's function/tool calling feature. " +
"Please verify that your API provider supports native tool calling, or try using a different provider."
// Record a tool error for visibility/telemetry. Use the reported tool name if present.
try {
if (
Expand Down
3 changes: 2 additions & 1 deletion src/core/tools/BaseTool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ export abstract class BaseTool<TName extends ToolName> {
})()
if (paramsText.includes("<") && paramsText.includes(">")) {
throw new Error(
"XML tool calls are no longer supported. Use native tool calling (nativeArgs) instead.",
"The model is outputting XML-formatted tool calls instead of using native function calling. " +
"This typically happens when your API provider does not fully support OpenAI's function/tool calling feature.",
)
}
throw new Error("Tool call is missing native arguments (nativeArgs).")
Expand Down
Loading