Skip to content
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 #5284

Merged
merged 110 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
149f60a
feat: Add LocalRuntime and rename EventStreamRuntime to LocalDockerRu…
openhands-agent Nov 26, 2024
39911f4
test: Add LocalRuntime to test configuration
openhands-agent Nov 26, 2024
1c9b6ca
fix: Fix mypy errors in LocalRuntime
openhands-agent Nov 26, 2024
52d6c60
Fix pr #5284: feat: Add LocalRuntime and rename EventStreamRuntime to…
openhands-agent Nov 26, 2024
000b749
Merge branch 'main' into add-local-runtime
enyst Nov 29, 2024
e1ac042
Fix pr #5284: feat: Add LocalRuntime and rename EventStreamRuntime to…
openhands-agent Nov 29, 2024
5ce262b
Delete openhands/runtime/impl/eventstream/__init__.py
enyst Nov 29, 2024
24f29c6
Delete openhands/runtime/impl/eventstream/eventstream_runtime.py
enyst Nov 29, 2024
910cc68
Update openhands/runtime/impl/modal/modal_runtime.py
enyst Nov 29, 2024
60839c4
Update openhands/runtime/impl/runloop/runloop_runtime.py
enyst Nov 29, 2024
c6aae8b
Update tests/runtime/conftest.py
enyst Nov 29, 2024
7fc2c87
Update tests/runtime/conftest.py
enyst Nov 29, 2024
3dec4cd
Update tests/runtime/conftest.py
enyst Nov 29, 2024
18987b8
Fix pr #5284: feat: Add LocalRuntime and rename EventStreamRuntime to…
openhands-agent Nov 29, 2024
0b1e1aa
Update openhands/runtime/__init__.py
enyst Nov 30, 2024
a136ab1
Update openhands/runtime/__init__.py
enyst Nov 30, 2024
af56cea
Merge branch 'main' into add-local-runtime
enyst Nov 30, 2024
e3560ae
Update openhands/runtime/README.md
xingyaoww Nov 30, 2024
598112c
Update openhands/runtime/README.md
xingyaoww Nov 30, 2024
f2c2311
Fix pr #5284: feat: Add LocalRuntime and rename EventStreamRuntime to…
openhands-agent Nov 30, 2024
fe1c50c
Merge branch 'main' into add-local-runtime
enyst Dec 1, 2024
724c1b0
Fix pr #5284: feat: Add LocalRuntime and rename EventStreamRuntime to…
openhands-agent Dec 1, 2024
9d5cc54
Merge commit '92b38dcea1bf08298cc21086cd29744e8b332566' into add-loca…
xingyaoww Dec 2, 2024
474984a
add local runtime test to ci
xingyaoww Dec 2, 2024
c78239a
tweak configs in local runtime
xingyaoww Dec 2, 2024
e24df6e
update logging
xingyaoww Dec 2, 2024
90a12e6
Update openhands/runtime/README.md
xingyaoww Dec 2, 2024
d609f47
Update openhands/runtime/README.md
xingyaoww Dec 2, 2024
b1a7699
xingyaoww Jan 4, 2025
fbd6ed1
Merge commit '8907fed78ed13b9b42bbf23b2b7f33c689b8da0a' into add-loca…
xingyaoww Jan 10, 2025
b3d634f
Merge branch 'main' into add-local-runtime
xingyaoww Jan 10, 2025
36f3ac1
remove extra
xingyaoww Jan 10, 2025
89df721
remove unncessary init
xingyaoww Jan 10, 2025
4938ce3
consolidate runtime startup command into an util function
xingyaoww Jan 10, 2025
d3370e6
wip
xingyaoww Jan 10, 2025
3876a00
consolidate runtime startup command into an util function
xingyaoww Jan 10, 2025
bef37fd
Merge commit '3876a00aa574d12075807268c0fd1427831b475a' into add-loca…
xingyaoww Jan 10, 2025
383baa6
wip
xingyaoww Jan 10, 2025
efe9622
replace run_as_openhands with more general run_as_user
xingyaoww Jan 10, 2025
7cb48e9
Revert "replace run_as_openhands with more general run_as_user"
xingyaoww Jan 10, 2025
e663fef
Merge commit 'f31ccad48bf8d2397839ea7a0cc7f0cb6a505262' into add-loca…
xingyaoww Jan 10, 2025
28bf3f8
add the ability to override user name
xingyaoww Jan 10, 2025
67612da
tweak
xingyaoww Jan 10, 2025
2d35f1a
got it somewhat working!
xingyaoww Jan 10, 2025
77ea88c
remove duplicate line
xingyaoww Jan 10, 2025
9d4300d
try fix command
xingyaoww Jan 10, 2025
16c6e52
fix import
xingyaoww Jan 10, 2025
37751ad
support using provided workspace base1
xingyaoww Jan 13, 2025
1873250
add dependency check;
xingyaoww Jan 13, 2025
424fcb7
rm local runtime test from ghcr-build
xingyaoww Jan 13, 2025
316b88a
add seprate ci for localruntime
xingyaoww Jan 13, 2025
b8770ad
tweak export git and save it to bashrc
xingyaoww Jan 13, 2025
41301ac
move localruntime test to unit test ci
xingyaoww Jan 13, 2025
7e37989
fix ci
xingyaoww Jan 13, 2025
7146d3b
fix gitconfig
xingyaoww Jan 13, 2025
d970bf3
fix action execution server for non localruntime
xingyaoww Jan 13, 2025
baf0adb
manually install playwright in ci
xingyaoww Jan 13, 2025
12e810e
tweak for local runtime
xingyaoww Jan 14, 2025
c1be6cb
try a different one
xingyaoww Jan 14, 2025
894afc5
another one
xingyaoww Jan 14, 2025
9163dd5
Merge branch 'main' into add-local-runtime
xingyaoww Jan 16, 2025
e91fd2b
use ubuntu 2204
xingyaoww Jan 16, 2025
8b3a6e9
Merge branch 'main' into add-local-runtime
xingyaoww Jan 16, 2025
d575e25
setup node
xingyaoww Jan 16, 2025
bf39cb8
remove node
xingyaoww Jan 16, 2025
4d6199f
tweak ver
xingyaoww Jan 16, 2025
b017f2e
revert to 2204
xingyaoww Jan 16, 2025
6f3735f
attempt to fix pclcs bug
xingyaoww Jan 16, 2025
b79c63e
move it up
xingyaoww Jan 16, 2025
45787ce
update ignored tests for localruntime;
xingyaoww Jan 17, 2025
0957aad
make localruntime tests not parallel
xingyaoww Jan 17, 2025
2cddda5
fix sandbox dir
xingyaoww Jan 17, 2025
8cb6276
add timeout for retry
xingyaoww Jan 17, 2025
164e10e
Merge branch 'main' into add-local-runtime
xingyaoww Jan 17, 2025
627549e
fix linter
xingyaoww Jan 18, 2025
6e009df
fix test
xingyaoww Jan 18, 2025
3560a8d
fix test browsing for localruntime
xingyaoww Jan 18, 2025
c051d71
tweak local runtime
xingyaoww Jan 20, 2025
039f061
now try to parallize localruntime tests
xingyaoww Jan 21, 2025
1e9076b
Merge commit '5b7fcfbe1ad07b9fbb6df995889f86ee29bdebbf' into add-loca…
xingyaoww Jan 21, 2025
83bccd4
try test bash first
xingyaoww Jan 21, 2025
94bec98
Merge branch 'main' into add-local-runtime
xingyaoww Jan 24, 2025
50e8566
Merge commit 'f3b8bad09fa0437c77bd49315b83fc33c6f43ae4' into add-loca…
xingyaoww Jan 28, 2025
89e4d6d
fix some tests for localruntime
xingyaoww Jan 28, 2025
aeb0ee5
try fix
xingyaoww Feb 1, 2025
c926e97
Merge branch 'main' into add-local-runtime
enyst Feb 1, 2025
2056c9b
attempt to fix git user/email
enyst Feb 1, 2025
9bb155c
fix replay
enyst Feb 1, 2025
3634062
fix user assert
enyst Feb 1, 2025
3ed1b48
Merge branch 'main' into add-local-runtime
enyst Feb 2, 2025
7c70d4b
add deps
enyst Feb 2, 2025
20632a8
Merge branch 'add-local-runtime' of github.com:All-Hands-AI/OpenHands…
enyst Feb 2, 2025
b2b8f15
poetry lock
enyst Feb 2, 2025
6592257
Merge commit 'ed680344271e61c797f1c5c1343a0de8735a200c' into add-loca…
xingyaoww Feb 5, 2025
c459daf
fix test bash
xingyaoww Feb 5, 2025
2f666e2
use temp dir for git operation test
xingyaoww Feb 5, 2025
035ed53
set git config
xingyaoww Feb 5, 2025
92aa08e
run in temp dir for git operation
xingyaoww Feb 5, 2025
46008f7
fix runtime tests
xingyaoww Feb 6, 2025
494bee2
simplify test
xingyaoww Feb 6, 2025
6bb65eb
remove manual clean up of tmp_dir
xingyaoww Feb 6, 2025
0246f33
remove local runtime tests
xingyaoww Feb 6, 2025
050c062
remove extra log buffer
xingyaoww Feb 6, 2025
ac562b6
add unit test with parallism again
xingyaoww Feb 6, 2025
218ef2a
Revert "add unit test with parallism again"
xingyaoww Feb 7, 2025
c76cb81
Merge commit '93d2e4a338adcaa8acaa602adad14364abca821f' into add-loca…
xingyaoww Feb 7, 2025
4c6a421
Update openhands/runtime/README.md
xingyaoww Feb 7, 2025
f25ce1c
Update openhands/runtime/impl/local/local_runtime.py
xingyaoww Feb 7, 2025
f33f691
address engel comment
xingyaoww Feb 7, 2025
350e1bb
add experimental feature text
xingyaoww Feb 7, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ghcr-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ jobs:
run: pipx install poetry
- name: Install Python dependencies using Poetry
run: make install-python-dependencies
- name: Run runtime tests
- name: Run docker runtime tests
run: |
# We install pytest-xdist in order to run tests across CPUs
poetry run pip install pytest-xdist
Expand Down
18 changes: 18 additions & 0 deletions openhands/runtime/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,27 @@ Key features:
- Real-time logging and debugging capabilities
- Direct access to the local file system
- Faster execution due to local resources
- Container isolation for security

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 the local user:

- Runs the action_execution_server directly on the host
- No Docker container overhead
- Direct access to local system resources
- Ideal for development and testing when Docker is not available or desired

Key features:
- Minimal setup required
- Direct access to local resources
- No container overhead
- Fastest execution speed

**Important: This runtime provides no isolation as it runs directly on the host machine. All actions are executed with the same permissions as the user running OpenHands. For secure execution with proper isolation, use the Docker Runtime instead.**

### Remote Runtime

The Remote Runtime is designed for execution in a remote environment:
Expand Down
3 changes: 3 additions & 0 deletions openhands/runtime/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
DockerRuntime,
)
from openhands.runtime.impl.e2b.sandbox import E2BBox
enyst marked this conversation as resolved.
Show resolved Hide resolved
from openhands.runtime.impl.local.local_runtime import LocalRuntime
from openhands.runtime.impl.modal.modal_runtime import ModalRuntime
from openhands.runtime.impl.remote.remote_runtime import RemoteRuntime
from openhands.runtime.impl.runloop.runloop_runtime import RunloopRuntime
Expand All @@ -21,6 +22,8 @@ def get_runtime_cls(name: str):
return ModalRuntime
elif name == 'runloop':
return RunloopRuntime
elif name == 'local':
return LocalRuntime
else:
raise ValueError(f'Runtime {name} not supported')

Expand Down
9 changes: 5 additions & 4 deletions openhands/runtime/action_execution_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@ class ActionRequest(BaseModel):


ROOT_GID = 0
INIT_COMMANDS = [
'git config --global user.name "openhands" && git config --global user.email "[email protected]" && alias git="git --no-pager"',
]

SESSION_API_KEY = os.environ.get('SESSION_API_KEY')
api_key_header = APIKeyHeader(name='X-Session-API-Key', auto_error=False)
Expand Down Expand Up @@ -163,6 +160,11 @@ async def _init_plugin(self, plugin: Plugin):
)

async def _init_bash_commands(self):
INIT_COMMANDS = [
'git config --file ./.git_config user.name "openhands" && git config --file ./.git_config user.email "[email protected]" && alias git="git --no-pager" && export GIT_CONFIG=$(pwd)/.git_config'
if os.environ.get('LOCAL_RUNTIME_MODE') == '1'
else 'git config --global user.name "openhands" && git config --global user.email "[email protected]" && alias git="git --no-pager"'
]
logger.debug(f'Initializing by running {len(INIT_COMMANDS)} bash commands...')
for command in INIT_COMMANDS:
action = CmdRunAction(command=command)
Expand All @@ -174,7 +176,6 @@ async def _init_bash_commands(self):
f'Init command outputs (exit code: {obs.exit_code}): {obs.content}'
)
assert obs.exit_code == 0

logger.debug('Bash init commands completed')

async def run_action(self, action) -> Observation:
Expand Down
Loading