shell_environment_policy.set variables are not available in Hooks
Nobody has claimed this yet.
- 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?
-
Configure a Stop Hook.
-
Run Codex with the following configuration: codex --config 'shell_environment_policy.set.TEST=hello'
-
In a Python script executed by a Skill, run: os.environ.get("TEST")
The result is hello. -
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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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