From e210af44183f42d3aa9c89e2daec533f52d257fc Mon Sep 17 00:00:00 2001 From: MUHAMMAD SALMAN HUSSAIN <160324527+mshsheikh@users.noreply.github.com> Date: Fri, 12 Jun 2026 00:52:01 +0500 Subject: [PATCH 1/3] fix(mounts): resolve rclone remote names consistently - Use `RcloneMountPattern.resolve_remote_name()` when building the per-session config path and when launching/unmounting rclone processes. - This keeps `apply()` and `unapply()` aligned on the same remote name, preserves deterministic naming when no explicit remote_name is provided, and removes the current dead wiring around pattern-level name resolution. - The change is intentionally limited to name resolution and does not alter mount semantics. --- src/agents/sandbox/entries/mounts/patterns.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/agents/sandbox/entries/mounts/patterns.py b/src/agents/sandbox/entries/mounts/patterns.py index e9f6a3751a..8aa2f873a0 100644 --- a/src/agents/sandbox/entries/mounts/patterns.py +++ b/src/agents/sandbox/entries/mounts/patterns.py @@ -753,7 +753,7 @@ async def _start_rclone_server( tool="rclone serve nfs", context={"type": config.mount_type}, ) - cmd: list[str] = ["rclone", "serve", "nfs", f"{config.remote_name}:{config.remote_path}"] + cmd: list[str] = ["rclone", "serve", "nfs", f"{remote_name}:{config.remote_path}"] cmd.extend(["--addr", nfs_addr]) cmd.extend(["--config", sandbox_path_str(config_path)]) if config.read_only: @@ -784,7 +784,7 @@ async def _start_rclone_client( cmd: list[str] = [ "rclone", "mount", - f"{config.remote_name}:{config.remote_path}", + f"{remote_name}:{config.remote_path}", sandbox_path_str(path), ] if config.read_only: @@ -900,6 +900,11 @@ async def apply( context={"type": rclone_config.mount_type}, ) session_id_str = session_id.hex + remote_name = self.resolve_remote_name( + session_id=session_id_str, + remote_kind=rclone_config.remote_kind, + mount_type=rclone_config.mount_type, + ) # Keep generated rclone config under the workspace root so `session.mkdir()` / # `session.write()` can handle it without special-casing absolute paths. config_dir = posix_path_as_path( @@ -965,6 +970,16 @@ async def unapply( shell=False, ) + session_id = getattr(session.state, "session_id", None) + if session_id is None: + remote_name = rclone_config.remote_name + else: + remote_name = self.resolve_remote_name( + session_id=session_id.hex, + remote_kind=rclone_config.remote_kind, + mount_type=rclone_config.mount_type, + ) + await session.exec( "sh", "-lc", From 9646e6dba4c8a62344e3f853c7479c2025ee0b0c Mon Sep 17 00:00:00 2001 From: MUHAMMAD SALMAN HUSSAIN <160324527+mshsheikh@users.noreply.github.com> Date: Fri, 12 Jun 2026 01:37:03 +0500 Subject: [PATCH 2/3] fix(mounts): pass resolved rclone remote name through apply and teardown - Thread the resolved rclone remote name through `_start_rclone_server()`, `_start_rclone_client()`, and `unapply()` so mount creation and cleanup use the same identifier. - This fixes the regression introduced by the name-resolution change, prevents the helper NameError, and keeps teardown aligned with the process started during `apply()`. - No public API changes. --- src/agents/sandbox/entries/mounts/patterns.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/agents/sandbox/entries/mounts/patterns.py b/src/agents/sandbox/entries/mounts/patterns.py index 8aa2f873a0..70a40bcbb8 100644 --- a/src/agents/sandbox/entries/mounts/patterns.py +++ b/src/agents/sandbox/entries/mounts/patterns.py @@ -739,6 +739,7 @@ async def _start_rclone_server( *, config: RcloneMountConfig, config_path: Path, + remote_name: str, nfs_addr: str, ) -> None: nfs_check = await session.exec( @@ -778,6 +779,7 @@ async def _start_rclone_client( path: Path, config: RcloneMountConfig, config_path: Path, + remote_name: str, nfs_addr: str | None = None, ) -> None: if self.mode == "fuse": @@ -929,6 +931,7 @@ async def apply( session, config=rclone_config, config_path=command_config_path, + remote_name=remote_name, nfs_addr=nfs_addr, ) await self._start_rclone_client( @@ -936,6 +939,7 @@ async def apply( path=path, config=rclone_config, config_path=command_config_path, + remote_name=remote_name, nfs_addr=nfs_addr, ) else: @@ -945,6 +949,7 @@ async def apply( path=path, config=rclone_config, config_path=command_config_path, + remote_name=remote_name, ) async def unapply( @@ -985,7 +990,7 @@ async def unapply( "-lc", ( "pkill -f -- " - f"'rclone (mount|serve nfs) {rclone_config.remote_name}:' >/dev/null 2>&1 || true" + f"'rclone (mount|serve nfs) {remote_name}:' >/dev/null 2>&1 || true" ), shell=False, ) From 6eb295b28065bc709b4d8a7900d291a0a598bbd0 Mon Sep 17 00:00:00 2001 From: MUHAMMAD SALMAN HUSSAIN <160324527+mshsheikh@users.noreply.github.com> Date: Fri, 12 Jun 2026 01:55:48 +0500 Subject: [PATCH 3/3] fix(mounts): align rclone launch and teardown with config remote name - Pass the configured rclone remote name through the helper launch path and reuse it in `unapply()` so mount setup and cleanup target the same remote. - This keeps the current config-file-based adapter path working without changing user-facing behavior. --- src/agents/sandbox/entries/mounts/patterns.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/agents/sandbox/entries/mounts/patterns.py b/src/agents/sandbox/entries/mounts/patterns.py index 70a40bcbb8..c823fc0605 100644 --- a/src/agents/sandbox/entries/mounts/patterns.py +++ b/src/agents/sandbox/entries/mounts/patterns.py @@ -902,17 +902,13 @@ async def apply( context={"type": rclone_config.mount_type}, ) session_id_str = session_id.hex - remote_name = self.resolve_remote_name( - session_id=session_id_str, - remote_kind=rclone_config.remote_kind, - mount_type=rclone_config.mount_type, - ) + remote_name = rclone_config.remote_name # Keep generated rclone config under the workspace root so `session.mkdir()` / # `session.write()` can handle it without special-casing absolute paths. config_dir = posix_path_as_path( coerce_posix_path(f".sandbox-rclone-config/{session_id_str}") ) - config_path = config_dir / f"{rclone_config.remote_name}.conf" + config_path = config_dir / f"{remote_name}.conf" await session.mkdir(path, parents=True) await session.mkdir(config_dir, parents=True) session.register_persist_workspace_skip_path(config_dir)