I have explored ways to make agent file edits reliable without requiring an LLM to retype large amounts of existing text. These ideas range from checking edits against remembered file content to experiments with line tags and ranges, and I later described finding a solution to the old/new editing problem. This work connects to my broader exploration of coding agent interfaces.
I judged the harness remembering the old view of the file as likely the best solution to the editing problem.
In this approach, I would ask the LLM for lines or ranges and fail the edit if the range no longer matches the old content.
I said I had finally found the solution I wanted to the old/new editing problem.
I described the solution as one that works extremely well and is quite elegant.
I said the solution cannot be implemented without building something like DwarfStar.
I experimented with edit line tags, first, then harness-side memorization of what the agent saw.
I tried these experiments to avoid the LLM having to retype sometime a huge amount of text in the old="" field of the edit tool.
I said the experiments surprisingly worked.
Despite @mitsuhiko's warning about LLMs sticking to tool usage learned during training, I reported that DeepSeek v4 Flash was able to use tags and line ranges.
I later qualified the successful DeepSeek v4 Flash line-range edit as “Probably it was just luck.”
I believe DS4F did some RL for line ranges in a way or the other, but I presented that as a possibility rather than a firm conclusion.
I warned that if you replace line 40:48 with 2 lines, the offsets will change, which may confuse the model during later edits.
I said that if you add an insert after/before tool, DS4F basically never use it even when it is more convenient, and that the win is very small.
Given this situation, I proposed “Context manipulation” rather than relying on an insert-before/after tool.
I explain the [upto] usage in the system prompt, but later as soon as the LLM wrote an old="" field that is already unique, I inject [upto] in the sampled text forcing the sampler to choose it.
At this point, I said: the LLM have no choice and continue.
I said it seems consistently able to write the right tail to anchor the old to the right range.
Since the LLM is inside the agent, I can use that to detect lack of anchoring ASAP.
I proposed that, if there is no match, I stop the LLM before it even starts writing.
After stopping it, I would ask the LLM to retry the tool call and make sure there is a unique match.
I also require that there is a match at all before the LLM retries the tool call.