-
Notifications
You must be signed in to change notification settings - Fork 5k
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
feat: Add LocalRuntime and rename EventStreamRuntime to DockerRuntime #5284
base: main
Are you sure you want to change the base?
Conversation
…ntime - Add new LocalRuntime implementation that runs action_execution_server directly on host - Rename EventStreamRuntime to LocalDockerRuntime for clarity - Move runtime implementations to dedicated directories - Update documentation to reflect runtime changes
- Update imports to use LocalDockerRuntime and LocalRuntime - Add LocalRuntime to get_runtime_classes() - Update _close_test_runtime to handle LocalDockerRuntime
- Add proper type hints for server_process - Fix stdout access safety - Fix async/await type hints - Improve error handling
… LocalDockerRuntime
New OpenHands update |
@openhands-agent This PR tests fail with
Fix this error. Keep your changes minimal. |
@openhands-agent We have done a lot to fix the original. This PR is doing these:
The PR is mostly finished now. It has only one detail that went wrong: instead of the name LocalDockerRuntime, we now want the name DockerRuntime. Find all occurrences and fix them. Additionally, look also for the name EventStreamRuntime, and if you find any, update it to the new name, DockerRuntime. |
… LocalDockerRuntime
@xingyaoww I've been continuing to test out this branch, and it's generally been working great. I just hit an issue though, and I'm not sure if it's related to this branch or not (note that I hadn't pulled your latest changes when this happened): Excerpt
Strangely, that grep command should return instantly, and does when I run it. Full logs
|
I just ran the same headless command again, I see the same timeout. I'll next update to your latest changes. |
Update: I pulled the latest changes from this PR, and I'm no longer seeing the timeouts 🙌 |
Thanks @scosenza! Super happy to see that this PR has been working well for you! Yeah those timeouts are existing runtime-related bugs that we are trying to fix & improve, but yeah, we do have some recent changes that improve the stability there that might help! I think this PR is probably ready for merge (as long as I figure out correct way to run these in CI 🥹 ) |
async def execute_action(self, action: Action) -> Observation: | ||
"""Execute an action by sending it to the server.""" | ||
if not self._runtime_initialized: | ||
return ErrorObservation('Runtime not initialized') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we raise an exception, rather than send an ErrorObs? It's not the kind of thing that an agent can fix, and it would end up in its context otherwise
return ErrorObservation('Runtime not initialized') | ||
|
||
if self.server_process is None or self.server_process.poll() is not None: | ||
return ErrorObservation('Server process died') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here?
except requests.exceptions.RequestException as e: | ||
return ErrorObservation(f'Failed to execute action: {e}') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
except requests.exceptions.RequestException as e: | |
return ErrorObservation(f'Failed to execute action: {e}') |
I wonder if maybe we don't need this? I think if there's an exception, it will fall to the controller, and there the reset
should do it if it's necessary 🤔
|
||
This is the default runtime used within OpenHands. | ||
|
||
### Local Runtime | ||
|
||
The Local Runtime is designed for direct execution on the local machine. Currently only supports running as `root`: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Local Runtime is designed for direct execution on the local machine. Currently only supports running as `root`: | |
The Local Runtime is designed for direct execution on the local machine. Currently only supports running as the local user: |
from typing import Callable | ||
|
||
|
||
class LogBuffer: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think maybe we don't need this class, it's actually become LogStreamer
now in main
, and this seems to be the older implementation - not in use, and it doesn't seem used by LocalRuntime either 🤔
async def execute_action(self, action: Action) -> Observation: | ||
"""Execute an action by sending it to the server.""" | ||
if not self._runtime_initialized: | ||
return ErrorObservation('Runtime not initialized') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return ErrorObservation('Runtime not initialized') | |
raise AgentRuntimeDisconnectedError('Runtime not initialized') |
"Smart Manoj" on Kaggle has made a version of OpenHands that works under the K-prize conditions (which includes no Docker container execution available) and it has actually solved one of the problems using a local LLM (Qwen 2.5 Instruct 32b). https://www.kaggle.com/code/smartmanoj/openhands-fork-offline-version Don't know if it is based on this issue's PR or not. |
On Mac, seems like it also needs:
Edited to add:
|
I had some fun today with this branch! For some reason, of course Haiku decided to do on local what it usually doesn't do on docker, because of course! 😂 It works great. I didn't actually have errors yet, so I didn't get to see issues with those ErrorObs, but I think there would be, because they're also missing tool_id, so I still think we should raise exceptions instead. But I had fun with the experiment, this is a really cool runtime and I love it! Note: we could add to documentation a note about Prompt Confirmation, because hey it's a feature that will prove incredibly useful, even for adventurous souls. |
This PR adds a new LocalRuntime implementation and renames EventStreamRuntime to LocalDockerRuntime for better clarity.
Changes
Benefits
Issue fixed: https://github.com/orgs/All-Hands-AI/projects/1?pane=issue&itemId=82616729&issue=All-Hands-AI%7COpenHands%7C3903
To run this PR locally, use the following command: