Codex CLI fails to honor an explicitly required output file path in an automation flow.
What version of Codex CLI is running?
codex-cli 0.131.0
What subscription do you have?
pro
Which model were you using?
gpt-5.3-codex-spark
What platform is your computer?
Linux 7.0.3-arch1-2 x86_64 unknown
What terminal emulator and version are you using (if applicable)?
_No response_
Codex doctor report
What issue are you seeing?
When Codex CLI is used in a non-interactive automation flow to generate commit messages and write it to an exact output file it repeatedly hallucinates a different path 4 out 5 times.
user:
Generate a concise commit message for the current repository changes.
[repository path redacted]
[changed files redacted]
Write exactly one commit message to this file:
<EXPECTED_OUTPUT_FILE>
NEVER USE A DIFFERENT PATH. DOUBLE AND TRIPLE CHECK THAT THIS IS THE PATH YOU USED: <EXPECTED_OUTPUT_FILE> DO NOT
ASSUME OR MAKE UP YOUR OWN PATH.
The only file you may write is the output file listed above.
Write only the commit message to the output file.
codex:
I’ll inspect the exact requested diff first, then check any untracked file contents, and write a single conventional
commit message to `<MUTATED_OUTPUT_FILE>`.
exec
... > <MUTATED_OUTPUT_FILE>
exited 1:
zsh:1: no such file or directory: <MUTATED_OUTPUT_FILE>
codex
The target directory didn’t exist, so I’ll create `<MUTATED_OUTPUT_DIRECTORY>` and write the same commit message there
without touching any repo files.
exec
mkdir -p <MUTATED_OUTPUT_DIRECTORY> && ... > <MUTATED_OUTPUT_FILE>
succeeded
codex
Done. I wrote the commit message to `<MUTATED_OUTPUT_FILE>`.
In the real log, <EXPECTED_OUTPUT_FILE> and <MUTATED_OUTPUT_FILE> differed by one character in the temporary directory name. Codex was explicitly instructed to write only to <EXPECTED_OUTPUT_FILE>, but it announced, created, wrote to, and confirmed success for <MUTATED_OUTPUT_FILE> instead.
Some times it announces it will use the <EXPECTED_OUTPUT_FILE> but still ends up using tools with <MUTATED_OUTPUT_FILE>
What steps can reproduce the bug?
Uploaded thread: 019e3f99-f591-7c82-b990-966c39bc38de
- Run Codex CLI in a temporary directory with an instruction that requires writing exactly one artifact file to a path containing a distinctive directory name.
- Include strong path constraints in the prompt, for example:
Write exactly one commit message to this file: <FILE>
NEVER USE A DIFFERENT PATH. DOUBLE AND TRIPLE CHECK THAT THIS IS
THE PATH YOU USED: <FILE> DO NOT ASSUME OR MAKE UP YOUR OWN PATH.
- Ask Codex to inspect repository changes (make sure to not pollute context too much) and write the generated result to that exact file.
- Observe that Codex mutate the required path (
SOME_FOLDER/file.txt->SOME_FOLD/file.txt), attempt to write to the mutated path, create the mutated directory after the first write fails, and then report success at the mutated path.
- Ask it
What path were you instructed to write to?
- Observe it responding with the mutated path as what it was instructed to write to.
- Validate that token-usage was low to keep context pollution out of the picture.
What is the expected behavior?
_No response_
Additional information
_No response_
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗