- AI
- Artificial Intelligence
What a file-editing benchmark reveals about the hidden cost of successful agent runs
In our work on agent systems for clients, we often see a cost that success metrics miss. An agent delivers exactly what was requested, but getting there can take surprisingly much work. Each extra round of searching, tool use, and verification can add time or model cost. File editing is an easy place to overlook this, especially when the change is small enough to make in a few keystrokes.
In one test run, we gave Gemini a fictional airship maintenance handbook and asked it to change the time allowed for an initial envelope inspection from 30 to 45 minutes. In a text editor, you’d find the right section, select 30, and type 45. Simple, isn’t it? Gemini changed exactly those two digits, but the run log showed seven tool calls and eight model requests.
When you select a number in an editor, the selection tells the editor exactly which characters to replace. You can see the result as soon as you type. An agent has to express the location in a form its tool accepts, then inspect the tool’s response or read the file again to see what happened.
A model can recognize the right number in a passage. If the editor expects a line and column, the model still has to work out the character offset. The text arrives as tokens, each of which can span several characters, so recognizing a value and locating it by character position are different tasks.
Search and replace lets the text itself serve as the address. The model can provide “Allow 30 minutes for the initial assessment.” and a version with 45. If the same sentence appears in both the cabin and envelope sections, the model can include the section heading to narrow the match. It then has to reproduce that context exactly as well.
We used EdiBench to see how different editing interfaces shape the work between the first search and the final check.
We started with the tools built into Goose 1.57.0. Its edit tool takes an old passage and a new one, and applies the replacement when the file contains exactly one match for the old passage. We kept the command line available so the model could choose an approach, including writing a Python script. How Goose 1.57.0 checks for matches
In the opening example, Gemini searched the 226-line handbook twice around the Envelope inspection heading, adding line numbers on the second pass. It then checked the file type and searched separately for the phrase containing 30 minutes. The actual replacement was its fifth tool call. To verify the edit, Gemini ran git diff. The command failed, so Gemini used grep to display the section again. The finished file matched the reference byte for byte.
We counted model requests and tool calls separately because one model response can ask Goose to perform several actions. Gemini requested one action at a time in this run, and after the final grep, Goose made one more model request to get the final response.
Gemini tried Git in all 12 attempts with the built-in tools. In a software repository, git status and git diff are useful ways to see which files changed and what changed in them. Our test handbook lived in an ordinary directory outside a repository, so the Git command failed each time, and Gemini went back to reading the file.
We prepared three versions of the fictional English-language handbook for the number replacement. One had ten lines, another had 226, and a third repeated the target sentence in eight sections. We added three more tasks. One replaced a paragraph spanning several lines, one made two separate edits, and one renamed a term in nine places while keeping the old name in an archived quotation.
We prepared an expected file for every task. Each attempt started in a fresh directory with the original handbook.txt. EdiBench compared the finished file with its reference byte for byte and separately checked the directory for unexpected additions. That let us catch differences as small as a missing newline at the end of the file, which is easy to miss when reading the text.
We started with GPT-6 Luna, Claude Haiku 5.5, and Gemini 3.5 Flash, which we already had access to through LiteLLM. We broadened the comparison with DeepSeek V4 Flash and added Qwen3.5-9B to see how a smaller model with tool-calling support handled the same edits.
For each Goose configuration, every model attempted all six tasks twice, starting from the original file each time. That gave us 60 attempts per configuration and 300 attempts across five complete runs of the handbook benchmark.
With the built-in tools, models used edit in 27 of 30 attempts at the number replacement. For the nine renames with an archived quotation to preserve, they used a Python script in seven of ten attempts. A script makes it easy to set the search boundary and replace every match in one pass.
In one attempt, GPT-6 Luna found the start of the archived quotation and made all nine replacements before it. The new term was longer, so writing the edits shifted the quotation’s position. The final check in the script still counted occurrences up to the old boundary and failed, even though the file already matched the reference. To confirm the result without writing again, the model had to find the quotation’s new starting position.
Overall, 58 of 60 files matched their references with the built-in tools. Both mismatches came from Qwen. In one attempt, it missed an occurrence during the rename. In the other, it lost the file’s final newline.
We tried Hashline next because it gives the model a way to address a line as soon as it reads the file. The same address also lets the editor check that the line still contains the text the model saw.
Hashline attaches a short address to every line it returns. Here’s how the same handbook’s Envelope inspection section starts.
147:95|Envelope inspection
148:77|
149:73|Allow 30 minutes for the initial assessment.The pair 149:73 before the vertical bar is the anchor. It combines the line number, 149, and a short hash of the line’s contents, 73. To change the number, the model copies the anchor into a SWAP command and supplies the replacement line with a + prefix.
SWAP 149:73:
+Allow 45 minutes for the initial assessment.Hashline uses the line number to find the target and the hash to check its contents before writing. If the hash differs, the tool can reject the edit. The agent can then reread the file to get the current anchor.
We chose the Rust implementation because it ships with an MCP server. Goose could start it with hashline mcp and receive both the read and edit tools and their descriptions. We kept the built-in edit and command line available, leaving the choice of tool to the model. Hashline’s Rust implementation
Before the handbook benchmark, we tested Hashline on short Python files in EdiBench. In one task, GPT-6 Luna had to change base_delay from 30 to 45. It found the right line, but the tool description lacked a complete patch example. The model put the old and new lines into the command with an arrow between them.
SWAP 6:85| base_delay = 30 => base_delay = 45Hashline treated everything after | as the replacement text, wrote it into the file, and returned OK. The anchor pointed to the right line. The command itself put invalid Python on that line.
We expanded the instructions Hashline exposes through MCP, adding format rules and five complete calls to the description of the patch argument. The examples showed where the anchor goes and how to separate it from the replacement text. When we reran the Python tasks, GPT-6 Luna stopped using the arrow form. We submitted the changes in a pull request, and they were merged into the project’s main branch.
For the handbook, we used Hashline 0.9.20 with the revised tool descriptions. This time, Gemini read the file, applied the patch shown above, and read it again to verify it. Both configurations produced a byte-for-byte match. With Hashline, Gemini got there in three tool calls and four model requests, down from seven calls and eight requests with the built-in tools.
In a rename task, Qwen supplied an incorrect hash, and Hashline rejected the patch. Qwen reread the file, copied the current anchor, and tried the edit again.
Hashline matched 58 of 60 reference files overall, the same count as the built-in tools. Qwen’s two mismatches came on different tasks this time.
We then tested apply_patch from OpenAI’s Codex CLI. Its format resembles a Git diff, and it locates edits using the file's text. OpenAI described the format in its GPT-4.1 materials.
With Goose’s built-in edit, any surrounding lines needed to locate a match have to appear in both the old and new passages. A patch lists that context once. It can also carry edits to several sections in one call. Each block supplies its own context, leaving the intervening text alone.
In the patch that changes 30 to 45, the section heading and surrounding lines identify the intended passage in handbook.txt.
*** Begin Patch
*** Update File: handbook.txt
@@
Envelope inspection
-Allow 30 minutes for the initial assessment.
+Allow 45 minutes for the initial assessment.
Record the findings on the service sheet.
*** End PatchThe *** Update File: handbook.txt line identifies the file. The @@ marker opens an edit block. The line prefixed with - is removed, and the line prefixed with + takes its place. The heading and the instruction to record the findings start with a space and stay in the file. Together with the old sentence, they give the tool enough context to find the envelope section even when other sections also mention 30 minutes.
We connected Codex’s apply_patch to Goose 1.57.0 through MCP and initially let the models choose their editing tool, as we had with Hashline. They called the new tool in only two of 21 attempts in a partial run. For the full runs, we turned off the built-in edit and write tools and added a system instruction to make edits through apply_patch. The command line remained available for reading, searching, and verification. Models called apply_patch in all 60 attempts in each full run.
The resemblance to Git mattered in the first run. Gemini sent headers such as @@ -3,44 +4,44 @@, which a unified diff uses to describe line ranges before and after a change. Here, apply_patch interpreted the text after the opening @@ as context to locate in the file. The handbook contained no such text, so the tool rejected the patch before making any change.
For the second run, we changed only the description of the patch argument. An example with two edits in one file showed how to start each block with its own @@ line and where to put the space, -, and + prefixes. We also described how to recover from a rejection by rereading the relevant passage and building a patch from the current text. The parser, available tools, tasks, and limits were the same in both runs.
The tool rejected the first patch in 22 attempts with the original description and in nine with the revised one. Gemini accounted for eight first-patch rejections in its 12 attempts with the original description. With the revised description, all 12 of its first patches were accepted. Rejections caused by line-range headers disappeared in the second run.
With the revised description, 53 of 60 files matched their references, up from 49. The second run used 386 model requests, down from 441, including reads, retries, and verification.
Finally, we tried edit_file from Filesystem MCP. Like the built-in edit, it takes old and new text. Its edits array can carry multiple replacements, each with oldText and newText fields, and the server applies them in order within one file. With dryRun: true, the tool previews what would change without writing to disk. Filesystem MCP documentation
Qwen received the same 30-to-45-minute edit in Envelope inspection, this time in the version of the handbook where the sentence appeared in other sections as well. It started with a preview and included the right heading in oldText, but supplied Initial assessment time: 30 minutes underneath. The handbook used different wording, so the server returned an error and showed the closest passage.
Qwen copied the sentence from the file and immediately requested a write, leaving out the heading. Goose’s built-in edit would have rejected that ambiguous match. Filesystem MCP’s edit_file took the first match, which put the 45 minutes in Cabin inspection.
After reading the file again, Qwen sent two replacements in one edits array. The first restored the original 30 minutes in the cabin section. The second included the Envelope inspection heading in the search text so it would change the number in the right place. The server wrote both changes in one call, and the result matched the reference.
For the full run with Filesystem MCP 2.2.0, we again turned off Goose’s built-in edit and write. The models were instructed to make edits through edit_file and could use the command line to read and verify files.
Of the 60 final files, 59 matched their references. Qwen changed the cabin value on three attempts and repaired it within the same attempt twice. On the third, the 45 minutes stayed in the cabin section.
The models called edit_file in all 60 attempts and used a preview in five of them. They successfully applied multiple replacements in a single call 18 times, most often on the task that renamed nine occurrences while preserving the archived quotation.
| Goose configuration | Exact files | Model requests | Tool calls | Total time (s) | Model cost (USD) |
|---|---|---|---|---|---|
| Built-in tools | 58/60 | 322 | 281 | 804 | 0.319 |
| Hashline, revised descriptions | 58/60 | 254 | 194 | 920 | 0.325 |
| apply_patch, original description | 49/60 | 441 | 401 | 1,425 | 0.465 |
| apply_patch, revised description | 53/60 | 386 | 345 | 1,643 | 0.330 |
| Filesystem MCP edit_file | 59/60 | 321 | 273 | 849 | 0.273 |
The totals cover the entire run, including searches, checks, failed calls, and retries. Qwen accounted for 22 of the 23 files that differed from their references. Across the other four models, four configurations produced 48 exact files out of 48. The original apply_patch configuration produced 47 out of 48.
Hashline used about one-fifth fewer model requests than Goose’s built-in tools, even as total run time rose from 804 to 920 seconds. The two-digit edit shows how some of those requests can disappear. With the anchor already in the read response, Gemini could copy it into the patch, apply the change, and verify the result in four model requests instead of eight.
The runs took place in different windows, and the configurations differed in tool availability and instructions. The figures describe the workflows we tested in Goose. For our own agent workflows, we plan to try Hashline in day-to-day use and continue improving the Rust implementation.
Get actionable insights for your product