Skip to content

Commit f664385

Browse files
authored
🤖 refactor: make file edit tool warnings more prominent (#502)
## Problem Agents assume file edits succeed and proceed with dependent operations (commits, pushes, builds) before tool results return. During streaming, the agent generates optimistic text like "Now I'll push..." before edit results arrive. When asked later, the agent knows about the failure (it's in context), but the damage is done. ## Solution Move the critical warning to the **first line** of all file edit tool descriptions with a ⚠️ emoji: ``` ⚠️ CRITICAL: Always check tool results - edits WILL fail if old_string is not found or unique. Do not proceed with dependent operations (commits, pushes, builds) until confirming success. ``` Applied to: - `file_edit_replace_string` - `file_edit_replace_lines` - `file_edit_insert` ## Why This Helps Warnings buried mid-description are easy for streaming models to miss. By placing the warning **first** with a visual indicator, we increase the likelihood that agents will: 1. Pause before assuming success 2. Check tool results explicitly 3. Only proceed with dependent operations after confirmation _Generated with `cmux`_
1 parent 4ab5406 commit f664385

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/utils/tools/toolDefinitions.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ export const TOOL_DEFINITIONS = {
7070
},
7171
file_edit_replace_string: {
7272
description:
73-
"Apply one or more edits to a file by replacing exact text matches. All edits are applied sequentially. Each old_string must be unique in the file unless replace_count > 1 or replace_count is -1. " +
74-
`IMPORTANT: Edits may fail if old_string is not found or not unique. ${TOOL_EDIT_WARNING}`,
73+
"⚠️ CRITICAL: Always check tool results - edits WILL fail if old_string is not found or unique. Do not proceed with dependent operations (commits, pushes, builds) until confirming success.\n\n" +
74+
"Apply one or more edits to a file by replacing exact text matches. All edits are applied sequentially. Each old_string must be unique in the file unless replace_count > 1 or replace_count is -1.",
7575
schema: z.object({
7676
file_path: z.string().describe("The absolute path to the file to edit"),
7777
old_string: z
@@ -91,8 +91,8 @@ export const TOOL_DEFINITIONS = {
9191
},
9292
file_edit_replace_lines: {
9393
description:
94-
"Replace a range of lines in a file. Use this for line-based edits when you know the exact line numbers to modify. " +
95-
`IMPORTANT: Edits may fail if line numbers are invalid or file content has changed. ${TOOL_EDIT_WARNING}`,
94+
"⚠️ CRITICAL: Always check tool results - edits WILL fail if line numbers are invalid or file content has changed. Do not proceed with dependent operations (commits, pushes, builds) until confirming success.\n\n" +
95+
"Replace a range of lines in a file. Use this for line-based edits when you know the exact line numbers to modify.",
9696
schema: z.object({
9797
file_path: z.string().describe("The absolute path to the file to edit"),
9898
start_line: z.number().int().min(1).describe("1-indexed start line (inclusive) to replace"),

0 commit comments

Comments
 (0)