OpenHands icon indicating copy to clipboard operation
OpenHands copied to clipboard

[Bug]: CodeAct repeatedly edits the wrong file

Open rbren opened this issue 1 year ago • 2 comments

Is there an existing issue for the same bug?

  • [X] I have checked the troubleshooting document at https://opendevin.github.io/OpenDevin/modules/usage/troubleshooting
  • [X] I have checked the existing issues.

Describe the bug

I'm asking CodeAct to repeatedly switch between editing two related files. Often File A is open, then CodeAct sends an edit command intended for File B. This usually happens when I issue a new instruction.

It'd be neat to show/emphasize the currently open file in CodeAct's prompt.

Side note: maybe we should just stop making open a thing, and put filenames directly into the commands? The agent has to look back over previous commands to determine current state, instead of just having a deterministic instruction it can write.

Current Version

Main, as of `0ecba83e53c6f2abfb0fdbaf134842a0298234f6`

Installation and Configuration

docker run

Model and Agent

gpt-4-turbo, CodeAct

Reproduction Steps

repeatedly prompt codeact to edit different files

Logs, Errors, Screenshots, and Additional Context

Screenshot 2024-05-18 at 3 40 18 PM

rbren avatar May 18 '24 19:05 rbren

Side note: maybe we should just stop making open a thing, and put filenames directly into the commands?

I also had the same wonder when I saw SWE agent commands. Apparently LLM often forgets that it needs to open a file before edits it.

li-boxuan avatar May 18 '24 21:05 li-boxuan

Yep! I think we should plan for one major iteration of the existing file operations now that we have a good way of comparing the performance.

xingyaoww avatar May 21 '24 06:05 xingyaoww

I vote for including the file name as the first parameter supplied by the AI to the edit command, as suggested above by rbren.

(This mix-up happened a bunch of times on the very first day that I used OpenDevin.)

edwardbrazier avatar Jun 09 '24 09:06 edwardbrazier

I'd take this up since I'm already on the agentskills with append_file and get to the edit_file changes for this PR afterwards.

cc @rbren @xingyaoww

tobitege avatar Jun 09 '24 09:06 tobitege

I encountered something funny with this symptom recently. The agent was trying to edit a javascript file but it forgot to open it. Since the last file it opened was an HTML file, the agent simply wrote javascript code to HTML file. When it browsed the webpage, it saw those javascript code printed out - and it thought that meant the code had been working!

li-boxuan avatar Jun 09 '24 17:06 li-boxuan

Proposal: right now open_file serves more as a list_file (like cat) and shouldn't be required prior to edit_file?

tobitege avatar Jun 09 '24 17:06 tobitege

right now open_file serves more as a list_file (like cat) and shouldn't be required prior to edit_file?

+1

li-boxuan avatar Jun 09 '24 17:06 li-boxuan

@tobitege i've been thinking about the same thing too -- feel free to starts a PR and add "filepath" to the edit command!

xingyaoww avatar Jun 10 '24 13:06 xingyaoww

@tobitege i've been thinking about the same thing too -- feel free to starts a PR and add "filepath" to the edit command!

Already done, waiting for review: https://github.com/OpenDevin/OpenDevin/pull/2346

tobitege avatar Jun 10 '24 14:06 tobitege