OpenHands icon indicating copy to clipboard operation
OpenHands copied to clipboard

[Bug]: Agent (Devstral) file modification frequently fails

Open matty-fortune opened this issue 6 months ago • 2 comments

Is there an existing issue for the same bug? (If one exists, thumbs up or comment on the issue instead).

  • [x] I have checked the existing issues.

Describe the bug and reproduction steps

When the agent is trying to make modifications to a file, it frequently encounters an error ERROR: No replacement was performed, old_str ... did not appear verbatim in ... even though what it's doing seems to be as intended. It could be an issue with line breaks or something more subtle. Sometimes the agent is eventually able to work around the issue by deleting and recreating the file, but it usually never recovers.

OpenHands Installation

Docker command in README

OpenHands Version

docker.all-hands.dev/all-hands-ai/runtime:0.41-nikolaik

Operating System

MacOS

matty-fortune avatar Jun 06 '25 18:06 matty-fortune

Same issue, almost same setup — using codestral via API

asci avatar Jun 09 '25 16:06 asci

It must be something simple but I haven't yet had time to continue trying to fix it.

matty-fortune avatar Jun 11 '25 15:06 matty-fortune

I have a similar issue, endless failing replacement loop. In my case, it looks like LLM has old file state cached, and it tries to replace a string that doesn't exist any more. Is there a way to tell it "clear the cache, read file again"?

glukki avatar Jun 24 '25 01:06 glukki

I can't really get the simplest tasks to work, because all file editing fails with mentioned error message. in some rare cases the agent starts writing shell scripts to edit files (and killing its whole content), but most of the time it just starts looping and not getting to any solution. Is there something i can test? Some information which could help resolving this issue?

EDIT: i feel like it has something to do with line breaks, since single line edits almost always work and some file operations seem to add an awful lot of line breaks. It recreated a file to work around the problem and went from ~150 lines to ~1000 lines, most of them being empty. So i guess the proposed MR should fix this...

sovddude avatar Jul 10 '25 14:07 sovddude

Same issue here and the worst part is that the agent creates a brand new file and replaces the existing, often changing things that should not be changed.

kostadinstoilov avatar Aug 10 '25 14:08 kostadinstoilov

Will be completed when #10502 is merged!

ryanhoangt avatar Aug 20 '25 16:08 ryanhoangt