From 435530018b14e5ad24a36b45f3b568a4423ef42e Mon Sep 17 00:00:00 2001 From: rovle Date: Thu, 5 Mar 2026 00:59:35 -0800 Subject: [PATCH] fix(daytona): resolve cwd by detecting home directory inside the sandbox --- tools/environments/daytona.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tools/environments/daytona.py b/tools/environments/daytona.py index dc549302..a69785ba 100644 --- a/tools/environments/daytona.py +++ b/tools/environments/daytona.py @@ -35,9 +35,7 @@ class DaytonaEnvironment(BaseEnvironment): persistent_filesystem: bool = True, task_id: str = "default", ): - # Resolve ~ to Daytona's default user home (matches Docker's ~ -> /root pattern) - if cwd == "~": - cwd = "/home/daytona" + self._requested_cwd = cwd super().__init__(cwd=cwd, timeout=timeout) from daytona import ( @@ -86,6 +84,15 @@ class DaytonaEnvironment(BaseEnvironment): logger.info("Daytona: created sandbox %s for task %s", self._sandbox.id, task_id) + # Resolve cwd: detect actual home dir inside the sandbox + if self._requested_cwd in ("~", "/home/daytona"): + try: + home = self._sandbox.process.exec("echo $HOME").result.strip() + self.cwd = home or "/root" + except Exception: + self.cwd = "/root" + logger.info("Daytona: resolved cwd to %s", self.cwd) + def _ensure_sandbox_ready(self): """Restart sandbox if it was stopped (e.g., by a previous interrupt).""" self._sandbox.refresh_data()