From c0b5d8d24a16d937db2cd9064e24886e0e94960a Mon Sep 17 00:00:00 2001 From: jif-oai Date: Thu, 9 Apr 2026 17:30:18 +0100 Subject: [PATCH] Skip local shell snapshots for remote unified exec (#17217) ## Summary - detect remote exec-server sessions in the unified-exec runtime - bypass the local shell-snapshot bootstrap only for those remote sessions - preserve existing local snapshot wrapping, PowerShell UTF-8 prefixing, sandbox orchestration, and zsh-fork handling ## Why The shell snapshot file is currently captured and stored next to Core. If Core wraps a remote command with `. /path/to/local/snapshot`, the process starts on the executor and tries to source a path from the orchestrator filesystem. This keeps remote commands from receiving that known-local path until shell snapshots are captured/restored on the executor side. ## Validation - `just fmt` - `git diff --check` - `cargo test -p codex-core --lib tools::runtimes::tests` Co-authored-by: Codex --- .../core/src/tools/runtimes/unified_exec.rs | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/codex-rs/core/src/tools/runtimes/unified_exec.rs b/codex-rs/core/src/tools/runtimes/unified_exec.rs index 86b6163b8..fd12607c1 100644 --- a/codex-rs/core/src/tools/runtimes/unified_exec.rs +++ b/codex-rs/core/src/tools/runtimes/unified_exec.rs @@ -202,13 +202,22 @@ impl<'a> ToolRuntime for UnifiedExecRunt ) -> Result { let base_command = &req.command; let session_shell = ctx.session.user_shell(); - let command = maybe_wrap_shell_lc_with_snapshot( - base_command, - session_shell.as_ref(), - &req.cwd, - &req.explicit_env_overrides, - &req.env, - ); + let environment_is_remote = ctx + .turn + .environment + .as_ref() + .is_some_and(|environment| environment.is_remote()); + let command = if environment_is_remote { + base_command.to_vec() + } else { + maybe_wrap_shell_lc_with_snapshot( + base_command, + session_shell.as_ref(), + &req.cwd, + &req.explicit_env_overrides, + &req.env, + ) + }; let command = if matches!(session_shell.shell_type, ShellType::PowerShell) { prefix_powershell_script_with_utf8(&command) } else {