Codex fails append to a file if code is large
What version of Codex is running?
0.88.0
What subscription do you have?
Pro
Which model were you using?
GPT 5.2 xhigh
What platform is your computer?
_No response_
What terminal emulator and version are you using (if applicable)?
_No response_
What issue are you seeing?
1398 +
1399 +}
1400 +
1401 +}
1402 +
✘ Failed to apply patch
└ execution error: Io(Os { code: 206, kind: InvalidFilename, message: "The filename or extension is too long." })
• I'm examining error code 206, which may arise if a file path is too long with os functions. But I wonder if it's
happening because of a temporary file name being too long. It's unlikely. Instead, I might create a file using the
Set-Content command, even though applying patches is standard for single file edits. Since that's failing, I could
use another method like Out-File or Set-Content with here-strings. However, the command might exceed length limits,
so I should consider using functions.exec_command to run a python command for writing the file content, possibly
even utilizing the base64 option.
Then it takes extra steps to append the generated code to a file..
What steps can reproduce the bug?
Let Codex try to apply a huge chunk of code at once.
What is the expected behavior?
It should be applying already generated code with no issues.
Additional information
_No response_
17 Comments
If you're able to repro this, please use the
/feedbackslash command to upload your logs and session details, then post your thread ID here.It looks like this is because we're passing the full patch to the tool, and this is overflow the length limit imposed by
CreateProcesson Windows. We'll need to think about the best way to fix this. Thanks for reporting the problem.I'm encountering this reasonably frequently, causing codex to spin its wheels while it tries alternatives and wasting time and tokens in the process. Are there any good workarounds?
Still occurs with GPT 5.4 xhigh + Codex (v0.111.0)
@etraut-openai This is getting annoying. Still not fixed is crazy. You guys didn't do anything about this. My tokens getting wasted because of this...
✘ Failed to apply patch
└ execution error: Io(Os { code: 206, kind: InvalidFilename, message: "The filename or extension is too long." })
@BlackShadow, it's unlikely we will have time to look into this any time soon. We're prioritizing bug reports that are impacting thousands or tens of thousands of users. By comparison, only you and a one other user have reported seeing this problem.
The Codex CLI source is available in this repo. If you'd like to do some work to diagnose the problem, you're welcome to clone the Codex repo and work with Codex to debug the issue. If you can pinpoint the problem, include your analysis below in this thread.
This problem can be reproduced 100%, as long as more than 10 large files are fully output at once, or when making Coedx perform large-scale feature refactoring, it is highly likely to occur!
This issue exists in both the Coedx app and Codex CLI!
Using WSL will solve this problem, but at the same time, it will introduce more other issues, such as network related issues, conflicts with Git in Windows, or other conflicts, so it is not possible to simply switch to the WSL backend to solve all problems.
No one is mentioning it now, it's probably just that you're pretending not to see it. This problem will arise as long as the code is extensively modified.
This issue leads to a speed drop of over ten times during large-scale modifications, multiple times higher quota consumption, and doubled context usage
Same issue on Windows.
bruhhh still have same issues windows
Yes, is the description correct
@etraut-openai
I don't know why you guys still insisting on not fixing this issue while many people already raised their voices about this issue. I just got "Failed to applied patch" 3 times in 20 min session of Codex...
This is an ACTUAL serious issue that wastes users Tokens and needs urgent fix...
Unless OpenAI willing to give me my money back on the wasted tokens, you guys can skip fixing this issue. At this point we're being ripped off.
<img width="191" height="30" alt="Image" src="https://github.com/user-attachments/assets/f8018eac-a67c-416f-9dab-d5d07a8157d0" /> fix this shit asap
👋
<img width="845" height="394" alt="Image" src="https://github.com/user-attachments/assets/85a594a9-c431-4378-b8c8-4cdf1acd0b84" />
Still happening
As others mentioned, issue is easy to reproduce and happening very often, as long as it usually happens with large files, these misfires are costing significant amount of tokens. There are at least several similar tickets created.
<img width="956" height="142" alt="Image" src="https://github.com/user-attachments/assets/c65d4219-30b9-42c1-aadf-d8fe4eb4cfe1" />
Has this serious problem not been fixed yet? I feel that AI is not powerful enough. The products of the three major AI companies are not as stable and timely as those of traditional software vendors