Skip to content

Commit 75e71d4

Browse files
Clarify XML tool use formatting instructions (#3295)
1 parent 57e5b6d commit 75e71d4

File tree

3 files changed

+70
-70
lines changed

3 files changed

+70
-70
lines changed

src/core/prompts/__tests__/__snapshots__/system.test.ts.snap

Lines changed: 60 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,21 @@ You have access to a set of tools that are executed upon the user's approval. Yo
1717
1818
# Tool Use Formatting
1919
20-
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:
20+
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:
2121
22-
<tool_name>
22+
<actual_tool_name>
2323
<parameter1_name>value1</parameter1_name>
2424
<parameter2_name>value2</parameter2_name>
2525
...
26-
</tool_name>
26+
</actual_tool_name>
2727
28-
For example:
28+
For example, to use the read_file tool:
2929
3030
<read_file>
3131
<path>src/main.js</path>
3232
</read_file>
3333
34-
Always adhere to this format for the tool use to ensure proper parsing and execution.
34+
Always use the actual tool name as the XML tag name for proper parsing and execution.
3535
3636
# Tools
3737
@@ -490,21 +490,21 @@ You have access to a set of tools that are executed upon the user's approval. Yo
490490
491491
# Tool Use Formatting
492492
493-
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:
493+
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:
494494
495-
<tool_name>
495+
<actual_tool_name>
496496
<parameter1_name>value1</parameter1_name>
497497
<parameter2_name>value2</parameter2_name>
498498
...
499-
</tool_name>
499+
</actual_tool_name>
500500
501-
For example:
501+
For example, to use the read_file tool:
502502
503503
<read_file>
504504
<path>src/main.js</path>
505505
</read_file>
506506
507-
Always adhere to this format for the tool use to ensure proper parsing and execution.
507+
Always use the actual tool name as the XML tag name for proper parsing and execution.
508508
509509
# Tools
510510
@@ -963,21 +963,21 @@ You have access to a set of tools that are executed upon the user's approval. Yo
963963
964964
# Tool Use Formatting
965965
966-
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:
966+
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:
967967
968-
<tool_name>
968+
<actual_tool_name>
969969
<parameter1_name>value1</parameter1_name>
970970
<parameter2_name>value2</parameter2_name>
971971
...
972-
</tool_name>
972+
</actual_tool_name>
973973
974-
For example:
974+
For example, to use the read_file tool:
975975
976976
<read_file>
977977
<path>src/main.js</path>
978978
</read_file>
979979
980-
Always adhere to this format for the tool use to ensure proper parsing and execution.
980+
Always use the actual tool name as the XML tag name for proper parsing and execution.
981981
982982
# Tools
983983
@@ -1436,21 +1436,21 @@ You have access to a set of tools that are executed upon the user's approval. Yo
14361436
14371437
# Tool Use Formatting
14381438
1439-
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:
1439+
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:
14401440
1441-
<tool_name>
1441+
<actual_tool_name>
14421442
<parameter1_name>value1</parameter1_name>
14431443
<parameter2_name>value2</parameter2_name>
14441444
...
1445-
</tool_name>
1445+
</actual_tool_name>
14461446
1447-
For example:
1447+
For example, to use the read_file tool:
14481448
14491449
<read_file>
14501450
<path>src/main.js</path>
14511451
</read_file>
14521452
1453-
Always adhere to this format for the tool use to ensure proper parsing and execution.
1453+
Always use the actual tool name as the XML tag name for proper parsing and execution.
14541454
14551455
# Tools
14561456
@@ -1965,21 +1965,21 @@ You have access to a set of tools that are executed upon the user's approval. Yo
19651965
19661966
# Tool Use Formatting
19671967
1968-
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:
1968+
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:
19691969
1970-
<tool_name>
1970+
<actual_tool_name>
19711971
<parameter1_name>value1</parameter1_name>
19721972
<parameter2_name>value2</parameter2_name>
19731973
...
1974-
</tool_name>
1974+
</actual_tool_name>
19751975
1976-
For example:
1976+
For example, to use the read_file tool:
19771977
19781978
<read_file>
19791979
<path>src/main.js</path>
19801980
</read_file>
19811981
1982-
Always adhere to this format for the tool use to ensure proper parsing and execution.
1982+
Always use the actual tool name as the XML tag name for proper parsing and execution.
19831983
19841984
# Tools
19851985
@@ -2506,21 +2506,21 @@ You have access to a set of tools that are executed upon the user's approval. Yo
25062506
25072507
# Tool Use Formatting
25082508
2509-
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:
2509+
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:
25102510
2511-
<tool_name>
2511+
<actual_tool_name>
25122512
<parameter1_name>value1</parameter1_name>
25132513
<parameter2_name>value2</parameter2_name>
25142514
...
2515-
</tool_name>
2515+
</actual_tool_name>
25162516
2517-
For example:
2517+
For example, to use the read_file tool:
25182518
25192519
<read_file>
25202520
<path>src/main.js</path>
25212521
</read_file>
25222522
2523-
Always adhere to this format for the tool use to ensure proper parsing and execution.
2523+
Always use the actual tool name as the XML tag name for proper parsing and execution.
25242524
25252525
# Tools
25262526
@@ -3035,21 +3035,21 @@ You have access to a set of tools that are executed upon the user's approval. Yo
30353035
30363036
# Tool Use Formatting
30373037
3038-
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:
3038+
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:
30393039
3040-
<tool_name>
3040+
<actual_tool_name>
30413041
<parameter1_name>value1</parameter1_name>
30423042
<parameter2_name>value2</parameter2_name>
30433043
...
3044-
</tool_name>
3044+
</actual_tool_name>
30453045
3046-
For example:
3046+
For example, to use the read_file tool:
30473047
30483048
<read_file>
30493049
<path>src/main.js</path>
30503050
</read_file>
30513051
3052-
Always adhere to this format for the tool use to ensure proper parsing and execution.
3052+
Always use the actual tool name as the XML tag name for proper parsing and execution.
30533053
30543054
# Tools
30553055
@@ -3598,21 +3598,21 @@ You have access to a set of tools that are executed upon the user's approval. Yo
35983598
35993599
# Tool Use Formatting
36003600
3601-
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:
3601+
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:
36023602
3603-
<tool_name>
3603+
<actual_tool_name>
36043604
<parameter1_name>value1</parameter1_name>
36053605
<parameter2_name>value2</parameter2_name>
36063606
...
3607-
</tool_name>
3607+
</actual_tool_name>
36083608
3609-
For example:
3609+
For example, to use the read_file tool:
36103610
36113611
<read_file>
36123612
<path>src/main.js</path>
36133613
</read_file>
36143614
3615-
Always adhere to this format for the tool use to ensure proper parsing and execution.
3615+
Always use the actual tool name as the XML tag name for proper parsing and execution.
36163616
36173617
# Tools
36183618
@@ -4113,21 +4113,21 @@ You have access to a set of tools that are executed upon the user's approval. Yo
41134113
41144114
# Tool Use Formatting
41154115
4116-
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:
4116+
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:
41174117
4118-
<tool_name>
4118+
<actual_tool_name>
41194119
<parameter1_name>value1</parameter1_name>
41204120
<parameter2_name>value2</parameter2_name>
41214121
...
4122-
</tool_name>
4122+
</actual_tool_name>
41234123
4124-
For example:
4124+
For example, to use the read_file tool:
41254125
41264126
<read_file>
41274127
<path>src/main.js</path>
41284128
</read_file>
41294129
4130-
Always adhere to this format for the tool use to ensure proper parsing and execution.
4130+
Always use the actual tool name as the XML tag name for proper parsing and execution.
41314131
41324132
# Tools
41334133
@@ -4663,21 +4663,21 @@ You have access to a set of tools that are executed upon the user's approval. Yo
46634663
46644664
# Tool Use Formatting
46654665
4666-
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:
4666+
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:
46674667
4668-
<tool_name>
4668+
<actual_tool_name>
46694669
<parameter1_name>value1</parameter1_name>
46704670
<parameter2_name>value2</parameter2_name>
46714671
...
4672-
</tool_name>
4672+
</actual_tool_name>
46734673
4674-
For example:
4674+
For example, to use the read_file tool:
46754675
46764676
<read_file>
46774677
<path>src/main.js</path>
46784678
</read_file>
46794679
4680-
Always adhere to this format for the tool use to ensure proper parsing and execution.
4680+
Always use the actual tool name as the XML tag name for proper parsing and execution.
46814681
46824682
# Tools
46834683
@@ -5127,21 +5127,21 @@ You have access to a set of tools that are executed upon the user's approval. Yo
51275127
51285128
# Tool Use Formatting
51295129
5130-
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:
5130+
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:
51315131
5132-
<tool_name>
5132+
<actual_tool_name>
51335133
<parameter1_name>value1</parameter1_name>
51345134
<parameter2_name>value2</parameter2_name>
51355135
...
5136-
</tool_name>
5136+
</actual_tool_name>
51375137
5138-
For example:
5138+
For example, to use the read_file tool:
51395139
51405140
<read_file>
51415141
<path>src/main.js</path>
51425142
</read_file>
51435143
5144-
Always adhere to this format for the tool use to ensure proper parsing and execution.
5144+
Always use the actual tool name as the XML tag name for proper parsing and execution.
51455145
51465146
# Tools
51475147
@@ -5508,21 +5508,21 @@ You have access to a set of tools that are executed upon the user's approval. Yo
55085508
55095509
# Tool Use Formatting
55105510
5511-
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:
5511+
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:
55125512
5513-
<tool_name>
5513+
<actual_tool_name>
55145514
<parameter1_name>value1</parameter1_name>
55155515
<parameter2_name>value2</parameter2_name>
55165516
...
5517-
</tool_name>
5517+
</actual_tool_name>
55185518
5519-
For example:
5519+
For example, to use the read_file tool:
55205520
55215521
<read_file>
55225522
<path>src/main.js</path>
55235523
</read_file>
55245524
5525-
Always adhere to this format for the tool use to ensure proper parsing and execution.
5525+
Always use the actual tool name as the XML tag name for proper parsing and execution.
55265526
55275527
# Tools
55285528

src/core/prompts/responses.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -184,20 +184,20 @@ const formatImagesIntoBlocks = (images?: string[]): Anthropic.ImageBlockParam[]
184184

185185
const toolUseInstructionsReminder = `# Reminder: Instructions for Tool Use
186186
187-
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:
187+
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:
188188
189-
<tool_name>
189+
<actual_tool_name>
190190
<parameter1_name>value1</parameter1_name>
191191
<parameter2_name>value2</parameter2_name>
192192
...
193-
</tool_name>
193+
</actual_tool_name>
194194
195-
For example:
195+
For example, to use the attempt_completion tool:
196196
197197
<attempt_completion>
198198
<result>
199199
I have completed the task...
200200
</result>
201201
</attempt_completion>
202202
203-
Always adhere to this format for all tool uses to ensure proper parsing and execution.`
203+
Always use the actual tool name as the XML tag name for proper parsing and execution.`

src/core/prompts/sections/tool-use.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@ You have access to a set of tools that are executed upon the user's approval. Yo
77
88
# Tool Use Formatting
99
10-
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:
10+
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:
1111
12-
<tool_name>
12+
<actual_tool_name>
1313
<parameter1_name>value1</parameter1_name>
1414
<parameter2_name>value2</parameter2_name>
1515
...
16-
</tool_name>
16+
</actual_tool_name>
1717
18-
For example:
18+
For example, to use the read_file tool:
1919
2020
<read_file>
2121
<path>src/main.js</path>
2222
</read_file>
2323
24-
Always adhere to this format for the tool use to ensure proper parsing and execution.`
24+
Always use the actual tool name as the XML tag name for proper parsing and execution.`
2525
}

0 commit comments

Comments
 (0)