Skip to content

Commit bf88147

Browse files
committed
Simplify write_file description
1 parent 2669d76 commit bf88147

File tree

1 file changed

+7
-44
lines changed

1 file changed

+7
-44
lines changed

packages/agent-runtime/src/tools/definitions/tool/write-file.ts

Lines changed: 7 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -6,62 +6,23 @@ const toolName = 'write_file'
66
export const writeFileTool = {
77
toolName,
88
description: `
9-
#### **IMPORTANT** Edit Snippet
9+
Create or replace a file with the given content.
1010
11-
Format the \`content\` parameter as an edit snippet that describes how you would like to modify the provided existing code.
11+
#### Edit Snippet
1212
13-
Edit snippets will be parsed by a less intelligent "fast-apply" model, so you MUST follow this format, otherwise the finetuned smaller model will not understand what to change. For example, do not include detailed instructions on how to apply code changes for the fast-apply model.
13+
Format the \`content\` parameter with the entire content of the file or as an edit snippet that describes how you would like to modify the provided existing code.
1414
15-
Abbreviate any sections of the code in your response that will remain the same with placeholder comments: "// ... existing code ...". Be descriptive in the comment. You MUST to use these in order to **MINIMIZE** the number of characters in the \`content\` parameter.
15+
You may abbreviate any sections of the code in your response that will remain the same with placeholder comments: "// ... existing code ...". Abbreviate as much as possible to save the user credits!
1616
17-
Make sure that you are abbreviating exactly where you believe the existing code will remain the same.
18-
Indicate the location and nature of the modifications (additions and deletions) with comments and ellipses.
19-
20-
Make sure that you preserve the indentation and code structure of exactly how you believe the final code will look like (do not output lines that will not be in the final code after they are merged).
21-
22-
##### **IMPORTANT** Deletion Comments
23-
24-
**CRITICAL FOR DELETIONS** If you plan on deleting a section, you MUST provide a comment giving the relevant context such that the code is understood to be removed. This is REQUIRED for the fast-apply model to understand what to delete.
25-
26-
Examples:
27-
28-
If the initial code is:
29-
\`\`\`Some code
30-
Block 1
31-
Block 2
32-
Block 3
33-
More code
34-
\`\`\`
35-
And if you want to delete code block 2, you MUST include a comment like:
36-
\`\`\`// existing code
37-
Block 1
38-
// Delete Block 2
39-
Block 3
40-
// rest of code
41-
\`\`\`
42-
43-
**YOU MUST ALWAYS INCLUDE DELETION COMMENTS** when removing **anything**: single lines, code blocks, functions, variables, or any other code elements. The fast-apply model cannot understand deletions without these explicit comments.
44-
45-
Merely omitting the code block may or may not work. In order to guarantee the deletion of the code, you must include a deletion comment.
17+
If you don't use any placeholder comments, the entire file will be replaced. E.g. don't write out a single function without using placeholder comments unless you want to replace the entire file with that function.
4618
4719
#### Additional Info
4820
4921
Prefer str_replace to write_file for most edits, including small-to-medium edits to a file, for deletions, or for editing large files (>1000 lines). Otherwise, prefer write_file for major edits throughout a file, or for creating new files.
5022
5123
Do not use this tool to delete or rename a file. Instead run a terminal command for that.
5224
53-
Notes for editing a file:
54-
- If you don't use any placeholder comments, the entire file will be replaced. E.g. don't write out a single function without using placeholder comments unless you want to replace the entire file with that function.
55-
- When editing a file, try not to change any user code that doesn't need to be changed. In particular, you must preserve pre-existing user comments exactly as they are.
56-
- You can also use this tool to create new files.
57-
- After you have written out a write_file block, the changes will be applied immediately. You can assume that the changes went through as intended. However, note that there are sometimes mistakes in the process of applying the edits you described in the write_file block, e.g. sometimes large portions of the file are deleted. If you notice that the changes did not go through as intended, based on further updates to the file, you can write out a new write_file block to fix the mistake.
58-
5925
Examples:
60-
${getToolCallString(toolName, {
61-
path: 'path/to/file',
62-
instructions: 'How the file is being updated',
63-
content: 'Your file content here',
64-
})}
6526
6627
Example 1 - Simple file creation:
6728
${getToolCallString(toolName, {
@@ -84,6 +45,8 @@ function foo() {
8445
doSomething();
8546
8647
// Delete the console.log line from here
48+
49+
doSomethingElse();
8750
}
8851
8952
// ... existing code ...`,

0 commit comments

Comments
 (0)