Skip to content

Commit 20655ee

Browse files
committed
refactor: improve tool-use-guidelines numbering logic
- Replace subsequentNumbers object with array-based approach - Use automatic incrementing with itemNumber++ for sequential numbering - Build guidelines as an array and join at the end - Fix potential numbering issues with conditional logic - Update tests and snapshots to match new format As suggested by daniel-lxs in PR #4340
1 parent 20c4426 commit 20655ee

File tree

3 files changed

+27
-32
lines changed

3 files changed

+27
-32
lines changed

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

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,6 @@ Example:
385385
386386
1. In <thinking> tags, assess what information you already have and what information you need to proceed with the task.
387387
2. Choose the most appropriate tool based on the task and the tool descriptions provided. Assess if you need additional information to proceed, and which of the available tools would be most effective for gathering this information. For example using the list_files tool is more effective than running a command like \`ls\` in the terminal. It's critical that you think about each available tool and use the one that best fits the current step in the task.
388-
389388
3. If multiple actions are needed, use one tool at a time per message to accomplish the task iteratively, with each tool use being informed by the result of the previous tool use. Do not assume the outcome of any tool use. Each step must be informed by the previous step's result.
390389
4. Formulate your tool use using the XML format specified for each tool.
391390
5. After each tool use, the user will respond with the result of that tool use. This result will provide you with the necessary information to continue your task or make further decisions. This response may include:
@@ -880,7 +879,6 @@ Example:
880879
881880
1. In <thinking> tags, assess what information you already have and what information you need to proceed with the task.
882881
2. Choose the most appropriate tool based on the task and the tool descriptions provided. Assess if you need additional information to proceed, and which of the available tools would be most effective for gathering this information. For example using the list_files tool is more effective than running a command like \`ls\` in the terminal. It's critical that you think about each available tool and use the one that best fits the current step in the task.
883-
884882
3. If multiple actions are needed, use one tool at a time per message to accomplish the task iteratively, with each tool use being informed by the result of the previous tool use. Do not assume the outcome of any tool use. Each step must be informed by the previous step's result.
885883
4. Formulate your tool use using the XML format specified for each tool.
886884
5. After each tool use, the user will respond with the result of that tool use. This result will provide you with the necessary information to continue your task or make further decisions. This response may include:
@@ -1375,7 +1373,6 @@ Example:
13751373
13761374
1. In <thinking> tags, assess what information you already have and what information you need to proceed with the task.
13771375
2. Choose the most appropriate tool based on the task and the tool descriptions provided. Assess if you need additional information to proceed, and which of the available tools would be most effective for gathering this information. For example using the list_files tool is more effective than running a command like \`ls\` in the terminal. It's critical that you think about each available tool and use the one that best fits the current step in the task.
1378-
13791376
3. If multiple actions are needed, use one tool at a time per message to accomplish the task iteratively, with each tool use being informed by the result of the previous tool use. Do not assume the outcome of any tool use. Each step must be informed by the previous step's result.
13801377
4. Formulate your tool use using the XML format specified for each tool.
13811378
5. After each tool use, the user will respond with the result of that tool use. This result will provide you with the necessary information to continue your task or make further decisions. This response may include:
@@ -1923,7 +1920,6 @@ Example:
19231920
19241921
1. In <thinking> tags, assess what information you already have and what information you need to proceed with the task.
19251922
2. Choose the most appropriate tool based on the task and the tool descriptions provided. Assess if you need additional information to proceed, and which of the available tools would be most effective for gathering this information. For example using the list_files tool is more effective than running a command like \`ls\` in the terminal. It's critical that you think about each available tool and use the one that best fits the current step in the task.
1926-
19271923
3. If multiple actions are needed, use one tool at a time per message to accomplish the task iteratively, with each tool use being informed by the result of the previous tool use. Do not assume the outcome of any tool use. Each step must be informed by the previous step's result.
19281924
4. Formulate your tool use using the XML format specified for each tool.
19291925
5. After each tool use, the user will respond with the result of that tool use. This result will provide you with the necessary information to continue your task or make further decisions. This response may include:
@@ -2470,7 +2466,6 @@ Example:
24702466
24712467
1. In <thinking> tags, assess what information you already have and what information you need to proceed with the task.
24722468
2. Choose the most appropriate tool based on the task and the tool descriptions provided. Assess if you need additional information to proceed, and which of the available tools would be most effective for gathering this information. For example using the list_files tool is more effective than running a command like \`ls\` in the terminal. It's critical that you think about each available tool and use the one that best fits the current step in the task.
2473-
24742469
3. If multiple actions are needed, use one tool at a time per message to accomplish the task iteratively, with each tool use being informed by the result of the previous tool use. Do not assume the outcome of any tool use. Each step must be informed by the previous step's result.
24752470
4. Formulate your tool use using the XML format specified for each tool.
24762471
5. After each tool use, the user will respond with the result of that tool use. This result will provide you with the necessary information to continue your task or make further decisions. This response may include:
@@ -3037,7 +3032,6 @@ Example:
30373032
30383033
1. In <thinking> tags, assess what information you already have and what information you need to proceed with the task.
30393034
2. Choose the most appropriate tool based on the task and the tool descriptions provided. Assess if you need additional information to proceed, and which of the available tools would be most effective for gathering this information. For example using the list_files tool is more effective than running a command like \`ls\` in the terminal. It's critical that you think about each available tool and use the one that best fits the current step in the task.
3040-
30413035
3. If multiple actions are needed, use one tool at a time per message to accomplish the task iteratively, with each tool use being informed by the result of the previous tool use. Do not assume the outcome of any tool use. Each step must be informed by the previous step's result.
30423036
4. Formulate your tool use using the XML format specified for each tool.
30433037
5. After each tool use, the user will respond with the result of that tool use. This result will provide you with the necessary information to continue your task or make further decisions. This response may include:
@@ -3623,7 +3617,6 @@ Example:
36233617
36243618
1. In <thinking> tags, assess what information you already have and what information you need to proceed with the task.
36253619
2. Choose the most appropriate tool based on the task and the tool descriptions provided. Assess if you need additional information to proceed, and which of the available tools would be most effective for gathering this information. For example using the list_files tool is more effective than running a command like \`ls\` in the terminal. It's critical that you think about each available tool and use the one that best fits the current step in the task.
3626-
36273620
3. If multiple actions are needed, use one tool at a time per message to accomplish the task iteratively, with each tool use being informed by the result of the previous tool use. Do not assume the outcome of any tool use. Each step must be informed by the previous step's result.
36283621
4. Formulate your tool use using the XML format specified for each tool.
36293622
5. After each tool use, the user will respond with the result of that tool use. This result will provide you with the necessary information to continue your task or make further decisions. This response may include:
@@ -4118,7 +4111,6 @@ Example:
41184111
41194112
1. In <thinking> tags, assess what information you already have and what information you need to proceed with the task.
41204113
2. Choose the most appropriate tool based on the task and the tool descriptions provided. Assess if you need additional information to proceed, and which of the available tools would be most effective for gathering this information. For example using the list_files tool is more effective than running a command like \`ls\` in the terminal. It's critical that you think about each available tool and use the one that best fits the current step in the task.
4121-
41224114
3. If multiple actions are needed, use one tool at a time per message to accomplish the task iteratively, with each tool use being informed by the result of the previous tool use. Do not assume the outcome of any tool use. Each step must be informed by the previous step's result.
41234115
4. Formulate your tool use using the XML format specified for each tool.
41244116
5. After each tool use, the user will respond with the result of that tool use. This result will provide you with the necessary information to continue your task or make further decisions. This response may include:
@@ -4704,7 +4696,6 @@ Example:
47044696
47054697
1. In <thinking> tags, assess what information you already have and what information you need to proceed with the task.
47064698
2. Choose the most appropriate tool based on the task and the tool descriptions provided. Assess if you need additional information to proceed, and which of the available tools would be most effective for gathering this information. For example using the list_files tool is more effective than running a command like \`ls\` in the terminal. It's critical that you think about each available tool and use the one that best fits the current step in the task.
4707-
47084699
3. If multiple actions are needed, use one tool at a time per message to accomplish the task iteratively, with each tool use being informed by the result of the previous tool use. Do not assume the outcome of any tool use. Each step must be informed by the previous step's result.
47094700
4. Formulate your tool use using the XML format specified for each tool.
47104701
5. After each tool use, the user will respond with the result of that tool use. This result will provide you with the necessary information to continue your task or make further decisions. This response may include:
@@ -5205,7 +5196,6 @@ Example:
52055196
52065197
1. In <thinking> tags, assess what information you already have and what information you need to proceed with the task.
52075198
2. Choose the most appropriate tool based on the task and the tool descriptions provided. Assess if you need additional information to proceed, and which of the available tools would be most effective for gathering this information. For example using the list_files tool is more effective than running a command like \`ls\` in the terminal. It's critical that you think about each available tool and use the one that best fits the current step in the task.
5208-
52095199
3. If multiple actions are needed, use one tool at a time per message to accomplish the task iteratively, with each tool use being informed by the result of the previous tool use. Do not assume the outcome of any tool use. Each step must be informed by the previous step's result.
52105200
4. Formulate your tool use using the XML format specified for each tool.
52115201
5. After each tool use, the user will respond with the result of that tool use. This result will provide you with the necessary information to continue your task or make further decisions. This response may include:
@@ -5588,7 +5578,6 @@ Example:
55885578
55895579
1. In <thinking> tags, assess what information you already have and what information you need to proceed with the task.
55905580
2. Choose the most appropriate tool based on the task and the tool descriptions provided. Assess if you need additional information to proceed, and which of the available tools would be most effective for gathering this information. For example using the list_files tool is more effective than running a command like \`ls\` in the terminal. It's critical that you think about each available tool and use the one that best fits the current step in the task.
5591-
55925581
3. If multiple actions are needed, use one tool at a time per message to accomplish the task iteratively, with each tool use being informed by the result of the previous tool use. Do not assume the outcome of any tool use. Each step must be informed by the previous step's result.
55935582
4. Formulate your tool use using the XML format specified for each tool.
55945583
5. After each tool use, the user will respond with the result of that tool use. This result will provide you with the necessary information to continue your task or make further decisions. This response may include:
@@ -6165,7 +6154,6 @@ Example:
61656154
61666155
1. In <thinking> tags, assess what information you already have and what information you need to proceed with the task.
61676156
2. Choose the most appropriate tool based on the task and the tool descriptions provided. Assess if you need additional information to proceed, and which of the available tools would be most effective for gathering this information. For example using the list_files tool is more effective than running a command like \`ls\` in the terminal. It's critical that you think about each available tool and use the one that best fits the current step in the task.
6168-
61696157
3. If multiple actions are needed, use one tool at a time per message to accomplish the task iteratively, with each tool use being informed by the result of the previous tool use. Do not assume the outcome of any tool use. Each step must be informed by the previous step's result.
61706158
4. Formulate your tool use using the XML format specified for each tool.
61716159
5. After each tool use, the user will respond with the result of that tool use. This result will provide you with the necessary information to continue your task or make further decisions. This response may include:
@@ -6702,7 +6690,6 @@ Example:
67026690
67036691
1. In <thinking> tags, assess what information you already have and what information you need to proceed with the task.
67046692
2. Choose the most appropriate tool based on the task and the tool descriptions provided. Assess if you need additional information to proceed, and which of the available tools would be most effective for gathering this information. For example using the list_files tool is more effective than running a command like \`ls\` in the terminal. It's critical that you think about each available tool and use the one that best fits the current step in the task.
6705-
67066693
3. If multiple actions are needed, use one tool at a time per message to accomplish the task iteratively, with each tool use being informed by the result of the previous tool use. Do not assume the outcome of any tool use. Each step must be informed by the previous step's result.
67076694
4. Formulate your tool use using the XML format specified for each tool.
67086695
5. After each tool use, the user will respond with the result of that tool use. This result will provide you with the necessary information to continue your task or make further decisions. This response may include:

src/core/prompts/sections/__tests__/tool-use-guidelines.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ describe("getToolUseGuidelinesSection", () => {
3333
expect(guidelines).toContain("1. In <thinking> tags")
3434
expect(guidelines).toContain("2. **IMPORTANT:")
3535
expect(guidelines).toContain("3. Choose the most appropriate tool")
36-
expect(guidelines).toContain("3. If multiple actions are needed")
37-
expect(guidelines).toContain("4. Formulate your tool use")
38-
expect(guidelines).toContain("5. After each tool use")
39-
expect(guidelines).toContain("6. ALWAYS wait for user confirmation")
36+
expect(guidelines).toContain("4. If multiple actions are needed")
37+
expect(guidelines).toContain("5. Formulate your tool use")
38+
expect(guidelines).toContain("6. After each tool use")
39+
expect(guidelines).toContain("7. ALWAYS wait for user confirmation")
4040
})
4141
})
4242

0 commit comments

Comments
 (0)