shell_environment_policy.set variables are not available in Hooks
Open 💬 1 comment Opened Aug 24, 2026 by qnnn
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_
1 Comment
Also true for
PreToolUsegates.I have a guard that checks tool calls for unwanted targets, dynamically based on the value of an env variable (hook is shared and different targets for different people).