From 75e71d41af196b58dec171dd9e7a621910210b1f Mon Sep 17 00:00:00 2001 From: Hannes Rudolph Date: Wed, 7 May 2025 21:52:06 -0600 Subject: [PATCH] Clarify XML tool use formatting instructions (#3295) --- .../__snapshots__/system.test.ts.snap | 120 +++++++++--------- src/core/prompts/responses.ts | 10 +- src/core/prompts/sections/tool-use.ts | 10 +- 3 files changed, 70 insertions(+), 70 deletions(-) diff --git a/src/core/prompts/__tests__/__snapshots__/system.test.ts.snap b/src/core/prompts/__tests__/__snapshots__/system.test.ts.snap index 4aed3e9af5..b37a9a34ec 100644 --- a/src/core/prompts/__tests__/__snapshots__/system.test.ts.snap +++ b/src/core/prompts/__tests__/__snapshots__/system.test.ts.snap @@ -17,21 +17,21 @@ You have access to a set of tools that are executed upon the user's approval. Yo # Tool Use Formatting -Tool use is formatted using XML-style tags. The tool name is enclosed in opening and closing tags, and each parameter is similarly enclosed within its own set of tags. Here's the structure: +Tool uses are formatted using XML-style tags. The tool name itself becomes the XML tag name. Each parameter is enclosed within its own set of tags. Here's the structure: - + value1 value2 ... - + -For example: +For example, to use the read_file tool: src/main.js -Always adhere to this format for the tool use to ensure proper parsing and execution. +Always use the actual tool name as the XML tag name for proper parsing and execution. # Tools @@ -490,21 +490,21 @@ You have access to a set of tools that are executed upon the user's approval. Yo # Tool Use Formatting -Tool use is formatted using XML-style tags. The tool name is enclosed in opening and closing tags, and each parameter is similarly enclosed within its own set of tags. Here's the structure: +Tool uses are formatted using XML-style tags. The tool name itself becomes the XML tag name. Each parameter is enclosed within its own set of tags. Here's the structure: - + value1 value2 ... - + -For example: +For example, to use the read_file tool: src/main.js -Always adhere to this format for the tool use to ensure proper parsing and execution. +Always use the actual tool name as the XML tag name for proper parsing and execution. # Tools @@ -963,21 +963,21 @@ You have access to a set of tools that are executed upon the user's approval. Yo # Tool Use Formatting -Tool use is formatted using XML-style tags. The tool name is enclosed in opening and closing tags, and each parameter is similarly enclosed within its own set of tags. Here's the structure: +Tool uses are formatted using XML-style tags. The tool name itself becomes the XML tag name. Each parameter is enclosed within its own set of tags. Here's the structure: - + value1 value2 ... - + -For example: +For example, to use the read_file tool: src/main.js -Always adhere to this format for the tool use to ensure proper parsing and execution. +Always use the actual tool name as the XML tag name for proper parsing and execution. # Tools @@ -1436,21 +1436,21 @@ You have access to a set of tools that are executed upon the user's approval. Yo # Tool Use Formatting -Tool use is formatted using XML-style tags. The tool name is enclosed in opening and closing tags, and each parameter is similarly enclosed within its own set of tags. Here's the structure: +Tool uses are formatted using XML-style tags. The tool name itself becomes the XML tag name. Each parameter is enclosed within its own set of tags. Here's the structure: - + value1 value2 ... - + -For example: +For example, to use the read_file tool: src/main.js -Always adhere to this format for the tool use to ensure proper parsing and execution. +Always use the actual tool name as the XML tag name for proper parsing and execution. # Tools @@ -1965,21 +1965,21 @@ You have access to a set of tools that are executed upon the user's approval. Yo # Tool Use Formatting -Tool use is formatted using XML-style tags. The tool name is enclosed in opening and closing tags, and each parameter is similarly enclosed within its own set of tags. Here's the structure: +Tool uses are formatted using XML-style tags. The tool name itself becomes the XML tag name. Each parameter is enclosed within its own set of tags. Here's the structure: - + value1 value2 ... - + -For example: +For example, to use the read_file tool: src/main.js -Always adhere to this format for the tool use to ensure proper parsing and execution. +Always use the actual tool name as the XML tag name for proper parsing and execution. # Tools @@ -2506,21 +2506,21 @@ You have access to a set of tools that are executed upon the user's approval. Yo # Tool Use Formatting -Tool use is formatted using XML-style tags. The tool name is enclosed in opening and closing tags, and each parameter is similarly enclosed within its own set of tags. Here's the structure: +Tool uses are formatted using XML-style tags. The tool name itself becomes the XML tag name. Each parameter is enclosed within its own set of tags. Here's the structure: - + value1 value2 ... - + -For example: +For example, to use the read_file tool: src/main.js -Always adhere to this format for the tool use to ensure proper parsing and execution. +Always use the actual tool name as the XML tag name for proper parsing and execution. # Tools @@ -3035,21 +3035,21 @@ You have access to a set of tools that are executed upon the user's approval. Yo # Tool Use Formatting -Tool use is formatted using XML-style tags. The tool name is enclosed in opening and closing tags, and each parameter is similarly enclosed within its own set of tags. Here's the structure: +Tool uses are formatted using XML-style tags. The tool name itself becomes the XML tag name. Each parameter is enclosed within its own set of tags. Here's the structure: - + value1 value2 ... - + -For example: +For example, to use the read_file tool: src/main.js -Always adhere to this format for the tool use to ensure proper parsing and execution. +Always use the actual tool name as the XML tag name for proper parsing and execution. # Tools @@ -3598,21 +3598,21 @@ You have access to a set of tools that are executed upon the user's approval. Yo # Tool Use Formatting -Tool use is formatted using XML-style tags. The tool name is enclosed in opening and closing tags, and each parameter is similarly enclosed within its own set of tags. Here's the structure: +Tool uses are formatted using XML-style tags. The tool name itself becomes the XML tag name. Each parameter is enclosed within its own set of tags. Here's the structure: - + value1 value2 ... - + -For example: +For example, to use the read_file tool: src/main.js -Always adhere to this format for the tool use to ensure proper parsing and execution. +Always use the actual tool name as the XML tag name for proper parsing and execution. # Tools @@ -4113,21 +4113,21 @@ You have access to a set of tools that are executed upon the user's approval. Yo # Tool Use Formatting -Tool use is formatted using XML-style tags. The tool name is enclosed in opening and closing tags, and each parameter is similarly enclosed within its own set of tags. Here's the structure: +Tool uses are formatted using XML-style tags. The tool name itself becomes the XML tag name. Each parameter is enclosed within its own set of tags. Here's the structure: - + value1 value2 ... - + -For example: +For example, to use the read_file tool: src/main.js -Always adhere to this format for the tool use to ensure proper parsing and execution. +Always use the actual tool name as the XML tag name for proper parsing and execution. # Tools @@ -4663,21 +4663,21 @@ You have access to a set of tools that are executed upon the user's approval. Yo # Tool Use Formatting -Tool use is formatted using XML-style tags. The tool name is enclosed in opening and closing tags, and each parameter is similarly enclosed within its own set of tags. Here's the structure: +Tool uses are formatted using XML-style tags. The tool name itself becomes the XML tag name. Each parameter is enclosed within its own set of tags. Here's the structure: - + value1 value2 ... - + -For example: +For example, to use the read_file tool: src/main.js -Always adhere to this format for the tool use to ensure proper parsing and execution. +Always use the actual tool name as the XML tag name for proper parsing and execution. # Tools @@ -5127,21 +5127,21 @@ You have access to a set of tools that are executed upon the user's approval. Yo # Tool Use Formatting -Tool use is formatted using XML-style tags. The tool name is enclosed in opening and closing tags, and each parameter is similarly enclosed within its own set of tags. Here's the structure: +Tool uses are formatted using XML-style tags. The tool name itself becomes the XML tag name. Each parameter is enclosed within its own set of tags. Here's the structure: - + value1 value2 ... - + -For example: +For example, to use the read_file tool: src/main.js -Always adhere to this format for the tool use to ensure proper parsing and execution. +Always use the actual tool name as the XML tag name for proper parsing and execution. # Tools @@ -5508,21 +5508,21 @@ You have access to a set of tools that are executed upon the user's approval. Yo # Tool Use Formatting -Tool use is formatted using XML-style tags. The tool name is enclosed in opening and closing tags, and each parameter is similarly enclosed within its own set of tags. Here's the structure: +Tool uses are formatted using XML-style tags. The tool name itself becomes the XML tag name. Each parameter is enclosed within its own set of tags. Here's the structure: - + value1 value2 ... - + -For example: +For example, to use the read_file tool: src/main.js -Always adhere to this format for the tool use to ensure proper parsing and execution. +Always use the actual tool name as the XML tag name for proper parsing and execution. # Tools diff --git a/src/core/prompts/responses.ts b/src/core/prompts/responses.ts index 314387171a..dc6e08c8a0 100644 --- a/src/core/prompts/responses.ts +++ b/src/core/prompts/responses.ts @@ -184,15 +184,15 @@ const formatImagesIntoBlocks = (images?: string[]): Anthropic.ImageBlockParam[] const toolUseInstructionsReminder = `# Reminder: Instructions for Tool Use -Tool uses are formatted using XML-style tags. The tool name is enclosed in opening and closing tags, and each parameter is similarly enclosed within its own set of tags. Here's the structure: +Tool uses are formatted using XML-style tags. The tool name itself becomes the XML tag name. Each parameter is enclosed within its own set of tags. Here's the structure: - + value1 value2 ... - + -For example: +For example, to use the attempt_completion tool: @@ -200,4 +200,4 @@ I have completed the task... -Always adhere to this format for all tool uses to ensure proper parsing and execution.` +Always use the actual tool name as the XML tag name for proper parsing and execution.` diff --git a/src/core/prompts/sections/tool-use.ts b/src/core/prompts/sections/tool-use.ts index e5671871ce..b75e4dad92 100644 --- a/src/core/prompts/sections/tool-use.ts +++ b/src/core/prompts/sections/tool-use.ts @@ -7,19 +7,19 @@ You have access to a set of tools that are executed upon the user's approval. Yo # Tool Use Formatting -Tool use is formatted using XML-style tags. The tool name is enclosed in opening and closing tags, and each parameter is similarly enclosed within its own set of tags. Here's the structure: +Tool uses are formatted using XML-style tags. The tool name itself becomes the XML tag name. Each parameter is enclosed within its own set of tags. Here's the structure: - + value1 value2 ... - + -For example: +For example, to use the read_file tool: src/main.js -Always adhere to this format for the tool use to ensure proper parsing and execution.` +Always use the actual tool name as the XML tag name for proper parsing and execution.` }