Compare commits

...

1 Commits

Author SHA1 Message Date
abarron-oai
0f28702e30 Add session id env var for shell commands 2026-02-03 10:55:04 -08:00
2 changed files with 7 additions and 0 deletions

View File

@@ -4,6 +4,8 @@ use crate::config::types::ShellEnvironmentPolicyInherit;
use std::collections::HashMap;
use std::collections::HashSet;
pub const CODEX_SESSION_ID_ENV_VAR: &str = "CODEX_SESSION_ID";
/// Construct an environment map based on the rules in the specified policy. The
/// resulting map can be passed directly to `Command::envs()` after calling
/// `env_clear()` to ensure no unintended variables are leaked to the spawned

View File

@@ -5,6 +5,7 @@ use std::sync::Arc;
use crate::codex::TurnContext;
use crate::exec::ExecParams;
use crate::exec_env::CODEX_SESSION_ID_ENV_VAR;
use crate::exec_env::create_env;
use crate::exec_policy::ExecApprovalRequest;
use crate::function_tool::FunctionCallError;
@@ -238,6 +239,10 @@ impl ShellHandler {
if !dependency_env.is_empty() {
exec_params.env.extend(dependency_env);
}
exec_params
.env
.entry(CODEX_SESSION_ID_ENV_VAR.to_string())
.or_insert_with(|| session.conversation_id.to_string());
// Approval policy guard for explicit escalation in non-OnRequest modes.
if exec_params