DesktopCommanderMCP icon indicating copy to clipboard operation
DesktopCommanderMCP copied to clipboard

Observation: edit block takes a lot of token to repeat code that needs to be replaced

Open xCatG opened this issue 7 months ago • 2 comments

I wouldn't call this a bug but more like asking for opinions; I observed that when editing block because LLM need to spit out the exact block that needs to be replaced, it caused a lot of wasted tokens while doing so.

However LLMs are also very bad at generating proper diff format due to they can't count correctly, so I don't have any alternatives to suggest. Do you know any methods for code replacement that is more accurate yet doesn't need to repeat tokens that need to be deleted?

xCatG avatar Apr 12 '25 03:04 xCatG

You are correct. For that reason its prompted to use full file rewrites if it intends to rewrite a lsrge block. Line based and diff based and even regex based replace are way less reliable for reasons you mentioned.

Models are good at writing text in that sense.

wonderwhy-er avatar Apr 12 '25 05:04 wonderwhy-er

The shorter the chat, the more accurate Claude is at being able to do diff block edits. I restart new chats as often as possible as soon as a minor task is complete. It saves tokens and stops me running out of tokens before the five hour window expires.

fezzzza avatar May 06 '25 18:05 fezzzza