Why does the Agent need to write the code it removes

Why does the Agent need to write the code it removes, rather than just telling the tool to “remove lines 200-300”?

Up!

Hey, good request. Here are a few reasons why the agent prints the code it’s deleting instead of referring to line numbers:

  1. Line numbers aren’t reliable. The file might have changed between when the model read it and when the edit is applied, like another edit in the same run shifting lines. Matching by content is more reliable than “delete lines 200 to 300.”

  2. Context improves accuracy. By showing the surrounding or removed code, the model gives a clear anchor. The system can then match exactly which block to change, even in files with repeated patterns.

  3. That’s how LLMs work. Language models generate text step by step. They don’t have a built-in concept of “line numbers in a file” like a normal script. Outputting the relevant code is a natural way for the model to show what should be changed.

That said, the team is always improving how edits are applied to cut latency and token use, so this may change over time.

1 Like