Agent server image from env (#12003)

Co-authored-by: openhands <openhands@all-hands.dev>
This commit is contained in:
Tim O'Farrell 2025-12-13 08:16:41 -07:00 committed by GitHub
parent d772dd65a5
commit d57880f849
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 15 additions and 6 deletions

View File

@ -14,9 +14,9 @@ from openhands.app_server.sandbox.sandbox_spec_models import (
SandboxSpecInfo,
)
from openhands.app_server.sandbox.sandbox_spec_service import (
AGENT_SERVER_IMAGE,
SandboxSpecService,
SandboxSpecServiceInjector,
get_default_agent_server_image,
)
from openhands.app_server.services.injector import InjectorState
@ -34,7 +34,7 @@ def get_docker_client() -> docker.DockerClient:
def get_default_sandbox_specs():
return [
SandboxSpecInfo(
id=AGENT_SERVER_IMAGE,
id=get_default_agent_server_image(),
command=['--port', '8000'],
initial_env={
'OPENVSCODE_SERVER_ROOT': '/openhands/.openvscode-server',

View File

@ -10,9 +10,9 @@ from openhands.app_server.sandbox.sandbox_spec_models import (
SandboxSpecInfo,
)
from openhands.app_server.sandbox.sandbox_spec_service import (
AGENT_SERVER_IMAGE,
SandboxSpecService,
SandboxSpecServiceInjector,
get_default_agent_server_image,
)
from openhands.app_server.services.injector import InjectorState
@ -20,7 +20,7 @@ from openhands.app_server.services.injector import InjectorState
def get_default_sandbox_specs():
return [
SandboxSpecInfo(
id=AGENT_SERVER_IMAGE,
id=get_default_agent_server_image(),
command=['python', '-m', 'openhands.agent_server'],
initial_env={
# VSCode disabled for now

View File

@ -10,9 +10,9 @@ from openhands.app_server.sandbox.sandbox_spec_models import (
SandboxSpecInfo,
)
from openhands.app_server.sandbox.sandbox_spec_service import (
AGENT_SERVER_IMAGE,
SandboxSpecService,
SandboxSpecServiceInjector,
get_default_agent_server_image,
)
from openhands.app_server.services.injector import InjectorState
@ -20,7 +20,7 @@ from openhands.app_server.services.injector import InjectorState
def get_default_sandbox_specs():
return [
SandboxSpecInfo(
id=AGENT_SERVER_IMAGE,
id=get_default_agent_server_image(),
command=['/usr/local/bin/openhands-agent-server', '--port', '60000'],
initial_env={
'OPENVSCODE_SERVER_ROOT': '/openhands/.openvscode-server',

View File

@ -1,4 +1,5 @@
import asyncio
import os
from abc import ABC, abstractmethod
from openhands.app_server.errors import SandboxError
@ -57,3 +58,11 @@ class SandboxSpecServiceInjector(
DiscriminatedUnionMixin, Injector[SandboxSpecService], ABC
):
pass
def get_default_agent_server_image():
agent_server_image_repository = os.getenv('AGENT_SERVER_IMAGE_REPOSITORY')
agent_server_image_tag = os.getenv('AGENT_SERVER_IMAGE_TAG')
if agent_server_image_repository and agent_server_image_tag:
return f'{agent_server_image_repository}:{agent_server_image_tag}'
return AGENT_SERVER_IMAGE