Skip to content

Commit a8922e0

Browse files
hannesrudolphellipsis-dev[bot]mrubens
authored
Improve tool descriptions to guide proper file editing tool selection (#3943)
* Improve tool descriptions to guide proper file editing tool selection ### Problem LLMs were frequently choosing `write_to_file` for file edits instead of more appropriate tools like `apply_diff`, `insert_content`, or `search_and_replace`. This was likely because the tool descriptions made it seem like files needed to be reconstructed rather than edited. ### Changes Made **write_to_file tool description:** - Clarified primary use cases: **creating new files** or **complete rewrites when intentionally required** - Changed opening from "write full content" to "write content" to reduce emphasis on full reconstruction - Updated parameter description to be more specific about when complete content is needed **apply_diff tool description:** - Enhanced description to emphasize "targeted modifications" and "precise, surgical edits" - Clarified that multiple search/replace operations can be performed in a single call - Removed misleading "only a single operation allowed" restriction - Better positioned as the preferred tool for making several targeted changes efficiently ### Impact These changes should guide LLMs toward: - Using `write_to_file` primarily for new files or intentional complete rewrites - Using `apply_diff` for targeted edits and modifications to existing files - Better understanding of when each tool is most appropriate The updated descriptions maintain necessary technical details while providing clearer guidance on tool selection without being overly prescriptive. * Update src/core/prompts/tools/write-to-file.ts Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> * Update src/core/prompts/tools/write-to-file.ts Co-authored-by: Matt Rubens <[email protected]> * Update src/core/prompts/tools/write-to-file.ts Co-authored-by: Matt Rubens <[email protected]> --------- Co-authored-by: ellipsis-dev[bot] <65095814+ellipsis-dev[bot]@users.noreply.github.com> Co-authored-by: Matt Rubens <[email protected]>
1 parent 20e7f11 commit a8922e0

File tree

3 files changed

+28
-32
lines changed

3 files changed

+28
-32
lines changed

src/core/diff/strategies/multi-search-replace.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,8 @@ export class MultiSearchReplaceDiffStrategy implements DiffStrategy {
9191

9292
getToolDescription(args: { cwd: string; toolOptions?: { [key: string]: string } }): string {
9393
return `## apply_diff
94-
Description: Request to replace existing code using a search and replace block.
95-
This tool allows for precise, surgical replaces to files by specifying exactly what content to search for and what to replace it with.
96-
The tool will maintain proper indentation and formatting while making changes.
97-
Only a single operation is allowed per tool use.
94+
Description: Request to apply targeted modifications to an existing file by searching for specific sections of content and replacing them. This tool is ideal for precise, surgical edits when you know the exact content to change. It helps maintain proper indentation and formatting.
95+
You can perform multiple distinct search and replace operations within a single \`apply_diff\` call by providing multiple SEARCH/REPLACE blocks in the \`diff\` parameter. This is the preferred way to make several targeted changes to one file efficiently.
9896
The SEARCH section must exactly match existing content including whitespace and indentation.
9997
If you're not confident in the exact content to search for, use the read_file tool first to get the exact content.
10098
When applying the diffs, be extra careful to remember to change any closing brackets or other syntax that may be affected by the diff farther down in the file.

0 commit comments

Comments
 (0)