mirror of
https://github.com/openai/codex.git
synced 2026-09-15 12:08:01 +00:00
Add session id env var for shell commands
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user