Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 7 additions & 0 deletions automation/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,13 @@ async def lifespan(app: FastAPI):
logging.getLogger(noisy_logger).setLevel(logging.WARNING)

logger.info("Starting OpenHands Automations Service")
if settings.is_agent_server_mode:
logger.info(
"Execution backend: agent-server mode (%s)",
settings.agent_server_url,
)
else:
logger.info("Execution backend: Cloud sandbox mode")

# Create shared httpx client for auth (stored in app.state for DI)
app.state.http_client = create_http_client()
Expand Down
12 changes: 12 additions & 0 deletions automation/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,20 @@ class Settings(BaseSettings):
# Used by the OpenHands server when forwarding GitHub events
webhook_secret: str = ""

# --- Execution backend ---
# When set, the automation engine connects directly to this agent-server
# instead of provisioning Cloud sandboxes per run.
# This enables open source / self-hosted deployments.
agent_server_url: str | None = None
agent_server_api_key: str | None = None

model_config = {"env_prefix": "AUTOMATION_"}

@property
def is_agent_server_mode(self) -> bool:
"""True when configured to use a persistent agent-server."""
return self.agent_server_url is not None

@property
def base_path(self) -> str:
"""Route prefix derived from base_url path component + /api/automation.
Expand Down
4 changes: 3 additions & 1 deletion automation/dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def log_extra(sandbox_id: str | None = None) -> dict[str, Any]:
else:
effective_timeout = MAX_RUN_DURATION_SECONDS

# 5. Dispatch to sandbox (fire-and-forget)
# 5. Dispatch (fire-and-forget)
result = await dispatch_automation(
api_url=settings.openhands_api_base_url,
api_key=api_key,
Expand All @@ -201,6 +201,8 @@ def log_extra(sandbox_id: str | None = None) -> dict[str, Any]:
timeout=effective_timeout,
callback_url=callback_url,
run_id=run_id,
agent_server_url=settings.agent_server_url,
agent_server_api_key=settings.agent_server_api_key,
)

sandbox_extra = log_extra(sandbox_id=result.sandbox_id)
Expand Down
Loading
Loading