openai / openai/codex

Allow Specifying [shell_environment_policy.set] for Subagents

Open
#46,457 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

CLI config enhancement subagent
Dominant language
Rust
Stars
125k
Forks
19.4k
PR merge metrics
PR metrics pending

Description

What variant of Codex are you using?

CLI

What feature would you like to see?

Description

As a codex user with a custom workflow definition with various subagents that the root coordinator can spawn, I would like to be able to override shell environment variables that agents are provided with via their agent.toml configuration.

Use Cases

  • Granular Access Control and Security
    • The root coordinator might have high-level administrative keys, while individual sub-agents are scoped to restricted API keys or tokens specific to their domain, like database access or third-party integrations. This enforces the principle of least privilege.
  • Isolated Environments and Sandboxing
    • A code execution or testing sub-agent can be pointed to a staging or sandbox environment variable, preventing accidental changes to the root agent's production context.
  • Context and Persona Customization
    • Overriding variables like output directories or log verbosity per agent allows you to run specialized agents without polluting the global environment settings.

Example

In this generic example, suppose we have either a script that switches behavior based on the value of a MACHINE_ACTOR environment variable or some sort of service with different machine user accounts that have different permissions.

~/.codex/config.toml

[shell_environment_policy.set]
MACHINE_ACTOR = "coordinator"
SOME_SERVICE_API_TOKEN = "<token with some elevated permissions>"

~/.codex/agents/reviewer.toml

[shell_environment_policy.set]
# Spawned reviewer agents should have a different profile for some service
MACHINE_ACTOR = "reviewer"
SOME_SERVICE_API_TOKEN = "<token with subset of coordinator permissions>"
Additional information

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing how ~/.codex/config.toml and ~/.codex/agents/reviewer.toml are parsed and how shell_environment_policy is applied when a subagent is spawned. Implement per-agent values that override the coordinator's environment for that subagent without changing the coordinator's variables, then verify the example variables are scoped as described.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
58/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.