From fffe4d60f385c6ca6a4c3a71ea84a9d42d5f4a76 Mon Sep 17 00:00:00 2001 From: Abhinav Vedmala Date: Thu, 28 May 2026 21:30:27 -0700 Subject: [PATCH] Trim session env file runtime churn --- codex-rs/core/src/tasks/user_shell.rs | 4 +- codex-rs/core/src/tools/runtimes/mod.rs | 70 +++++++++++-------- codex-rs/core/src/tools/runtimes/mod_tests.rs | 65 ++++++----------- codex-rs/core/src/tools/runtimes/shell.rs | 8 +-- .../tools/runtimes/shell/unix_escalation.rs | 4 +- .../core/src/tools/runtimes/unified_exec.rs | 15 ++-- 6 files changed, 75 insertions(+), 91 deletions(-) diff --git a/codex-rs/core/src/tasks/user_shell.rs b/codex-rs/core/src/tasks/user_shell.rs index 80895a9fb1..ebcc9c23cd 100644 --- a/codex-rs/core/src/tasks/user_shell.rs +++ b/codex-rs/core/src/tasks/user_shell.rs @@ -20,7 +20,7 @@ use crate::session::TurnInput; use crate::session::turn_context::TurnContext; use crate::state::TaskKind; use crate::tools::format_exec_output_str; -use crate::tools::runtimes::maybe_wrap_shell_command_with_runtime_env; +use crate::tools::runtimes::maybe_wrap_shell_lc_with_snapshot; use crate::turn_timing::now_unix_timestamp_ms; use crate::user_shell_command::user_shell_command_record_item; use codex_protocol::exec_output::ExecToolCallOutput; @@ -148,7 +148,7 @@ pub(crate) async fn execute_user_shell_command( exec_env_map.remove(PROXY_GIT_SSH_COMMAND_ENV_KEY); } } - let exec_command = maybe_wrap_shell_command_with_runtime_env( + let exec_command = maybe_wrap_shell_lc_with_snapshot( &display_command, session_shell.as_ref(), #[allow(deprecated)] diff --git a/codex-rs/core/src/tools/runtimes/mod.rs b/codex-rs/core/src/tools/runtimes/mod.rs index c6007043e9..45e1754da9 100644 --- a/codex-rs/core/src/tools/runtimes/mod.rs +++ b/codex-rs/core/src/tools/runtimes/mod.rs @@ -22,6 +22,7 @@ use codex_sandboxing::SandboxCommand; use codex_sandboxing::SandboxType; use codex_utils_absolute_path::AbsolutePathBuf; use std::collections::HashMap; +#[cfg(unix)] use std::path::Path; pub(crate) mod apply_patch; @@ -138,15 +139,18 @@ pub(crate) fn disable_powershell_profile_for_elevated_windows_sandbox( command } -/// POSIX-only wrapper for commands produced by `Shell::derive_exec_args` when a -/// login-shell snapshot must be sourced before the user script: +/// POSIX-only helper: for commands produced by `Shell::derive_exec_args` +/// for Bash/Zsh/sh of the form `[shell_path, "-lc", "