openai / openai/codex

shell_environment_policy.set variables are not available in Hooks

Open
#40,325 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug CLI config hooks
Dominant language
Rust
Stars
125k
Forks
19.4k
PR merge metrics
PR metrics pending

Description

What version of Codex CLI is running?

0.144.6

What subscription do you have?

Free

Which model were you using?

No response

What platform is your computer?

No response

What terminal emulator and version are you using (if applicable)?

No response

Codex doctor report

What issue are you seeing?

When I use --config to set an environment variable through shell_environment_policy.set, the variable is available in the Turn execution environment and in Python scripts executed by a Skill. However, the same environment variable is not available in a Stop Hook.

For example, os.environ.get("TEST") returns hello in a Python script executed by a Skill, but returns an empty value when called from the Python script used by the Stop Hook.

What steps can reproduce the bug?
  1. Configure a Stop Hook.

  2. Run Codex with the following configuration: codex --config 'shell_environment_policy.set.TEST=hello'

  3. In a Python script executed by a Skill, run: os.environ.get("TEST")
    The result is hello.

  4. In the Python script executed by the Stop Hook, run: os.environ.get("TEST")
    The result is empty.

What is the expected behavior?

I would expect environment variables configured through shell_environment_policy.set to also be available in Hooks, including Stop Hooks.

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

Reproduce the issue with codex --config 'shell_environment_policy.set.TEST=hello', checking TEST in both a Skill's Python script and the configured Stop Hook script. Trace how shell_environment_policy.set is applied to Turn and Hook execution environments; done means the configured variable is available in the Stop Hook as well.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.