Expose the session ID to shell commands (#37848)

## What changed

- Set `CODEX_SESSION_ID` to the shared root-session ID for shell tool calls,
  unified exec processes, and user shell commands.
- Preserve `CODEX_SESSION_ID` when restoring a shell snapshot, alongside the
  existing runtime-owned environment variables.

GitOrigin-RevId: 5228867d25507105c7edf11607a8298958c3b917
This commit is contained in:
jif
2026-08-10 17:02:19 +00:00
committed by copyberry
parent 4996cf05af
commit 97729885d4
7 changed files with 18 additions and 0 deletions
@@ -18,6 +18,7 @@ use crate::exec_env::CODEX_THREAD_ID_ENV_VAR;
use crate::exec_env::create_env;
use crate::exec_env::inject_apply_patch_env;
use crate::exec_env::inject_permission_profile_env;
use crate::exec_env::inject_session_id_env;
use crate::exec_policy::ExecApprovalRequest;
use crate::sandboxing::ExecOptions;
use crate::sandboxing::ExecRequest;
@@ -1160,6 +1161,7 @@ impl UnifiedExecProcessManager {
CODEX_THREAD_ID_ENV_VAR.to_string(),
context.session.thread_id.to_string(),
);
inject_session_id_env(&mut env, context.session.session_id());
inject_apply_patch_env(&mut env, &turn.config.features);
let active_permission_profile = request.turn_environment.active_permission_profile();
inject_permission_profile_env(&mut env, active_permission_profile.as_ref());