Add AGENT=codex environment variable to UNIFIED_EXEC_ENV
What variant of Codex are you using?
CLI (codex-rs)
What feature would you like to see?
Add AGENT=codex to the UNIFIED_EXEC_ENV array in codex-rs/core/src/unified_exec/process_manager.rs, so that spawned processes can detect they are running inside the Codex agent.
Other AI coding agents already follow this convention:
- Goose sets
AGENT=goose - Amp sets
AGENT=amp
This allows downstream tools, scripts, and MCP servers to detect which agent is driving them and adapt behavior accordingly (e.g., adjusting output format, disabling interactive prompts, or collecting telemetry).
Proposed diff:
-const UNIFIED_EXEC_ENV: [(&str, &str); 10] = [
+const UNIFIED_EXEC_ENV: [(&str, &str); 11] = [
("NO_COLOR", "1"),
("TERM", "dumb"),
("LANG", "C.UTF-8"),
@@ -63,6 +63,7 @@
("GIT_PAGER", "cat"),
("GH_PAGER", "cat"),
("CODEX_CI", "1"),
+ ("AGENT", "codex"),
];
The test unified_exec_env_injects_defaults also needs the new entry added to the expected HashMap.
Additional information
A working implementation with passing tests is available at: https://github.com/sw-square/codex/tree/add-agent-env-var
All existing process_manager unit tests pass and cargo clippy is clean.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗