-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: ERROR: to_replace
appears more than once, please include enough lines to make code in to_replace
unique.
#3852
Comments
I am not sure what is the problem, but this really made me mad, because of the stupidness executing the same command 50 times! (in the background, while the user waiting and see nothing the browser prompt/conversation window!). |
Just to clarify, this text:
So the backend rejects this, because there are 2 or more possible replacements it can do, at line 3 or line 5. It's not clear which one the LLM intended, the first or the second. So we ask it to give a replacement text like "I want to replace this thing", which is unique in the file. |
On the second issue: can you please confirm that the log you show, from STEP 51, is actually as Gemini gives it? It includes multiple scroll down() and edits in the SAME code block of one single action? |
Logically: If you don't provide a function like "edit_file_by_replace_all" to replace "all" matched strings in the text. then (logically) you SHOULD replace first MATCH (everytime), this way the model will be able to remove all "duplicates" in the project code files by "iterating" over the string ... (replacing then checking then replacing again and so on .. LOGICALLY if you don't provide a way to replace all!) When you "ask" .. the model don't understand what are you asking for! or what are you want from it! so it keep trying as your error message is not logically expected at all .. and don't provide any instructions or clarifications to the model .. it's just you're wrong! (the model: Okay, should I try again!!, and here stuck in a loop.. while its following your instructions!!) |
Yes, 100% sure! |
Strange, I didn't replicate this. I just tried with |
You might be right that a "replace all" would help. I'm not sure, there is also a possibility that the models do better with fewer actions than more actions, and specially similar actions can be confusing rather than helpful. FWIW I've seen them forget parameters for one or another when they had something similar without parameters. CC @tobitege @xingyaoww Edited to add: actually, a "replace all" would also have another problem: the LLM doesn't necessarily know the full file, when it asks for replace. It sees currently 100 lines iirc, then scrolls down, as your log shows. So it wouldn't necessarily know all replacements to be made with a hypothetical "replace all". Same goes for the first match. I don't know, it seems to require a number of assumptions to be made by us.
I've seen this message work FWIW, the LLM can choose the next time more text to include. It depends on the LLM, a lot. Sadly it seems Gemini doesn't work well with it. There's another aspect here. According to your report, it kept trying the same thing, stuck in the same edits. Did you by any chance send feedback to us? You can use "thumbs down" (or "thumbs up") in the UI to send the trajectory of the current task. Please note that it does send it all, the history of actions and observations. It would be useful to dig into, to see what happens. If not, maybe you can attach a log? |
@enyst |
Do you have the link to the feedback you sent? |
@enyst |
@imeDevelopers In history, I see a lot of:
That looks like openhands did not succeed in some operations that need temporary files in its workspace. I'd suggest to check if the openhands user has permission to create files in its workspace. |
This issue is stale because it has been open for 30 days with no activity. Remove stale label or comment or this will be closed in 7 days. |
This issue was closed because it has been stalled for over 30 days with no activity. |
Is there an existing issue for the same bug?
Describe the bug
File editing background operations, the terminal prints "ERROR:
to_replace
appears more than once, please include enough lines to make code into_replace
unique."My logical question: Why do you f* telling the LLM to modify the files (executing
edit_file_by_replace
and other functions) only one by one?!just execute the functions the model asking to be executed "as needed". don't add dumb limits ..
the LLM logically want to execute function calls as a list, but you telling him every f* time to only execute one function! wtf!
the model "always" stuck in this case (it don't know what to do!) ..
ERROR:
to_replace
appears more than once, please include enough lines to make code into_replace
unique.just do the f* replace operation!
model: Gemini 1.5 Flash latest.
here's the terminal logs, take a look at how many it stuck: (I can't include it because of huge files contents), but it's the operation number 50!
ERROR:
to_replace
appears more than once, please include enough lines to make code into_replace
unique.Current OpenHands version
Installation and Configuration
.
Model and Agent
No response
Operating System
No response
Reproduction Steps
No response
Logs, Errors, Screenshots, and Additional Context
No response
The text was updated successfully, but these errors were encountered: