-
Notifications
You must be signed in to change notification settings - Fork 5.3k
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]: Infinite Loop and Timeout Issue in SWE-Bench Evaluation Due to Context Overflow Handling in OpenHands Framework #6357
Comments
Proposed SolutionTo address the issue of infinite loops caused by context window exceeding errors, we suggest adding proper exception handling and state management when exceptions are raised. Specifically, after handling the exception, we need to ensure the agent’s state is properly updated to prevent the loop from continuing. The following solution outlines the steps:
Code ExampleOpenHands/openhands/controller/agent_controller.py Lines 693 to 698 in 1b6e444
# Save the ID of the first event in our truncated history for future reloading
if self.state.history:
self.state.start_id = self.state.history[0].id
# Don't add error event - let the agent retry with reduced context
await self._react_to_exception(e) # <-- Adding state handling here to prevent infinite loop
return
raise
` |
What exactly of the agent state do you think needs modified when context window error happens? Which attributes? I'm not sure what, in the agent state, could lead to an infinite loop. Maybe the missing information was relevant? But then resetting state wouldn't fix that. The proposed solution, to deal with the exception, puts the agent in ERROR state (which is not necessary IMO, and I think would end the Can you tell how exactly did you run, to get this issue? LLM, number of iterations, instance_id, would be useful to replicate. The full |
@yanrui27 would you think something like this is similar? #5887 (comment) Also sorry for shameless mention of similar things (a lot of things can lead to looping apparently?) #6612 |
Is there an existing issue for the same bug?
Describe the bug and reproduction steps
Description:
While using the OpenHands framework to evaluate SWE-Bench, I encountered an issue where the program enters an infinite loop and eventually times out when the conversation context exceeds the model’s maximum window size.
Problem:
This issue arises from a previously introduced fix that attempts to truncate the agent's history when the context window exceeds its limit. The fix proposed truncating the history roughly in half. However, the problem is that this approach doesn't correctly manage the agent's internal state after truncation, which causes the agent to enter an infinite loop. This loop persists until the program times out.
Steps to Reproduce:
Expected Behavior:
Additional Information:
Links to Relevant Issues:
Suggested Fix:
OpenHands Installation
Development workflow
OpenHands Version
0.20.0
Operating System
Linux
Logs, Errors, Screenshots, and Additional Context
No response
The text was updated successfully, but these errors were encountered: