Implementation:OpenHands OpenHands DaytonaRuntime Init
| Knowledge Sources | |
|---|---|
| Domains | Cloud_Infrastructure, Runtime_Management |
| Last Updated | 2026-02-11 21:00 GMT |
Overview
Concrete tool for authenticating with the Daytona cloud sandbox provider and initializing a runtime instance, provided by the OpenHands third-party runtime layer.
Description
DaytonaRuntime.__init__ constructs a fully authenticated Daytona runtime instance. It extracts the Daytona API key, server URL, and target from the provided OpenHandsConfig, creates a DaytonaConfig object, and initializes the Daytona SDK client. The constructor also accepts session identifiers, plugin requirements, environment variables, and callback hooks that are passed through to the base class ActionExecutionClient.
DaytonaRuntime is one of four third-party runtime implementations in OpenHands. The others follow the same pattern:
- E2BRuntime (e2b_runtime.py:L43-81) authenticates via the E2B API key set as an environment variable.
- ModalRuntime (modal_runtime.py:L48-119) authenticates using Modal API token ID and secret.
- RunloopRuntime (runloop_runtime.py:L31-68) authenticates using a Runloop API key passed to the Runloop client.
All four runtimes inherit from ActionExecutionClient and share the same constructor signature, enabling the orchestrator to instantiate any provider interchangeably.
Usage
Use DaytonaRuntime.__init__ when creating a new agent session that requires a Daytona-hosted cloud sandbox. The constructor is called by the runtime factory or orchestrator, passing in the global configuration and session-specific parameters.
Code Reference
Source Location
- Repository: OpenHands
- File:
third_party/runtime/impl/daytona/daytona_runtime.py - Lines: L36-88
Signature
class DaytonaRuntime(ActionExecutionClient):
def __init__(
self,
config: OpenHandsConfig,
event_stream: EventStream,
sid: str = "default",
plugins: list[PluginRequirement] | None = None,
env_vars: dict[str, str] | None = None,
status_callback: Callable | None = None,
attach_to_existing: bool = False,
headless_mode: bool = True,
user_id: str | None = None,
git_provider_tokens: PROVIDER_TOKEN_TYPE | None = None,
):
Import
from third_party.runtime.impl.daytona.daytona_runtime import DaytonaRuntime
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| config | OpenHandsConfig | Yes | Global configuration object containing Daytona API key, server URL, target, and sandbox settings |
| event_stream | EventStream | Yes | Event stream for publishing and subscribing to runtime events |
| sid | str | No | Session identifier, defaults to "default" |
| plugins | None | No | List of plugin requirements to install in the sandbox |
| env_vars | None | No | Additional environment variables to inject into the sandbox |
| status_callback | None | No | Callback function invoked on runtime status changes |
| attach_to_existing | bool | No | If True, attach to an existing sandbox instead of creating a new one |
| headless_mode | bool | No | If True, run without interactive UI elements, defaults to True |
| user_id | None | No | User identifier for multi-tenant isolation |
| git_provider_tokens | None | No | Git provider authentication tokens for repository access within the sandbox |
Outputs
| Name | Type | Description |
|---|---|---|
| instance | DaytonaRuntime | A fully initialized DaytonaRuntime instance with an authenticated Daytona client ready for sandbox creation |
Usage Examples
Basic Usage
from third_party.runtime.impl.daytona.daytona_runtime import DaytonaRuntime
runtime = DaytonaRuntime(
config=openhands_config,
event_stream=event_stream,
sid="session-001",
env_vars={"MY_VAR": "value"},
headless_mode=True,
)
# The runtime now holds an authenticated Daytona client.
# Call runtime.connect() to create and start the sandbox.
await runtime.connect()