Add AGENT=codex environment variable to UNIFIED_EXEC_ENV

Resolved 💬 2 comments Opened Mar 4, 2026 by sw-square Closed Apr 3, 2026
💡 Likely answer: A maintainer (etraut-openai, contributor) responded on this thread — see the highlighted reply below.

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.

View original on GitHub ↗

2 Comments

sw-square · 5 months ago

Also CF https://github.com/agentsmd/agents.md/issues/136, which is an attempt to standardize this

etraut-openai contributor · 4 months ago

This feature request hasn't received enough upvotes, so closing.