Expose the Codex version to commands and turn metadata (#42395)

## What changed

- Set `CODEX_VERSION` to the running package version in user shell and unified
  exec environments, overriding stale shell-policy or snapshot values.
- Add the reserved `codex_version` field to MCP turn metadata.

## Testing

- Cover version propagation through shell policies, shell snapshots, unified
  exec, and MCP metadata.

GitOrigin-RevId: 7846c70d668176530b1f467293b749dc9ddd79a0
This commit is contained in:
jif
2026-09-03 00:17:19 +00:00
committed by copyberry
parent 91608236ea
commit 9bb1ea035f
11 changed files with 74 additions and 17 deletions
+2 -2
View File
@@ -15,7 +15,7 @@ use crate::exec::StdoutStream;
use crate::exec::execute_exec_request;
use crate::exec_env::create_env;
use crate::exec_env::inject_apply_patch_env;
use crate::exec_env::inject_session_id_env;
use crate::exec_env::inject_session_env;
use crate::sandboxing::ExecRequest;
use crate::session::TurnInput;
use crate::session::turn_context::TurnContext;
@@ -166,7 +166,7 @@ pub(crate) async fn execute_user_shell_command(
let shell_snapshot_location = turn_environment.shell_snapshot(&cwd);
let shell_environment_policy = turn_environment.shell_environment_policy();
let mut exec_env_map = create_env(shell_environment_policy, Some(session.thread_id));
inject_session_id_env(&mut exec_env_map, session.session_id());
inject_session_env(&mut exec_env_map, session.session_id());
inject_apply_patch_env(&mut exec_env_map, &turn_context.config.features);
if exec_env_map.contains_key(PROXY_ACTIVE_ENV_KEY) {
strip_managed_proxy_env(&mut exec_env_map);