codex - 💡(How to fix) Fix Codex CLI fails to honor an explicitly required output file path in an automation flow. [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openai/codex#23460Fetched 2026-05-20 03:49:40
View on GitHub
Comments
1
Participants
2
Timeline
6
Reactions
0
Author
Timeline (top)
labeled ×4closed ×1commented ×1

Code Example

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.

---

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>`.

---

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.
RAW_BUFFERClick to expand / collapse

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

  1. 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.

  2. 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.
  1. Ask Codex to inspect repository changes (make sure to not pollute context too much) and write the generated result to that exact file.

  2. 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.

  3. Ask it What path were you instructed to write to?

  4. Observe it responding with the mutated path as what it was instructed to write to.

  5. 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

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING