feat: daytona envs for state management (#9893)

Signed-off-by: Ivan Dagelic <dagelic.ivan@gmail.com>
This commit is contained in:
Ivan Dagelic 2025-07-25 17:49:10 +02:00 committed by GitHub
parent b5958b069e
commit 240017add1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -117,12 +117,17 @@ class DaytonaRuntime(ActionExecutionClient):
return env_vars
def _create_sandbox(self) -> Sandbox:
# Check if auto-stop should be disabled - otherwise have it trigger after 60 minutes
disable_auto_stop = os.getenv('DAYTONA_DISABLE_AUTO_STOP', 'false').lower() == 'true'
auto_stop_interval = 0 if disable_auto_stop else 60
sandbox_params = CreateSandboxFromSnapshotParams(
language='python',
snapshot=self.config.sandbox.runtime_container_image,
public=True,
env_vars=self._get_creation_env_vars(),
labels={OPENHANDS_SID_LABEL: self.sid},
auto_stop_interval=auto_stop_interval,
)
return self.daytona.create(sandbox_params)
@ -245,7 +250,14 @@ class DaytonaRuntime(ActionExecutionClient):
return
if self.sandbox:
self.sandbox.delete()
delete_on_close = os.getenv('DAYTONA_DELETE_ON_CLOSE', 'false').lower() == 'true'
if delete_on_close:
self.sandbox.delete()
else:
# Only stop if sandbox is currently started
if self._get_sandbox().state == 'started':
self.sandbox.stop()
@property
def vscode_url(self) -> str | None: