Ensure executor injects CODEX_SESSION_ID

This commit is contained in:
Ilan Bigio
2025-10-20 14:46:27 -07:00
parent 9fb734e52c
commit 693a388c51
2 changed files with 7 additions and 7 deletions

View File

@@ -7,6 +7,7 @@ use std::time::Duration;
use super::backends::ExecutionMode;
use super::backends::backend_for_mode;
use super::cache::ApprovalCache;
use crate::codex::CODEX_SESSION_ID_ENV_VAR;
use crate::codex::Session;
use crate::error::CodexErr;
use crate::error::SandboxErr;
@@ -110,6 +111,11 @@ impl Executor {
.prepare(request.params, &request.mode, &config)
.map_err(ExecError::from)?;
request.params.env.insert(
CODEX_SESSION_ID_ENV_VAR.to_string(),
session.conversation_id().to_string(),
);
// Step 3: Decide sandbox placement, prompting for approval when needed.
let sandbox_decision = select_sandbox(
&request,

View File

@@ -9,7 +9,6 @@ use crate::apply_patch;
use crate::apply_patch::ApplyPatchExec;
use crate::apply_patch::InternalApplyPatchInvocation;
use crate::apply_patch::convert_apply_patch_to_protocol;
use crate::codex::CODEX_SESSION_ID_ENV_VAR;
use crate::codex::Session;
use crate::codex::TurnContext;
use crate::error::CodexErr;
@@ -50,7 +49,7 @@ pub(crate) const TELEMETRY_PREVIEW_TRUNCATION_NOTICE: &str =
// TODO(jif) break this down
pub(crate) async fn handle_container_exec_with_params(
tool_name: &str,
mut params: ExecParams,
params: ExecParams,
sess: Arc<Session>,
turn_context: Arc<TurnContext>,
turn_diff_tracker: SharedTurnDiffTracker,
@@ -135,11 +134,6 @@ pub(crate) async fn handle_container_exec_with_params(
turn_context.cwd.clone(),
);
params.env.insert(
CODEX_SESSION_ID_ENV_VAR.to_string(),
sess.conversation_id().to_string(),
);
let prepared_exec = PreparedExec::new(
exec_command_context,
params,