codex - 💡(How to fix) Fix Codex CLI tends to add and remove blank lines when patching files [4 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#21121Fetched 2026-05-05 05:53:18
View on GitHub
Comments
4
Participants
2
Timeline
10
Reactions
0
Author
Timeline (top)
commented ×4labeled ×3mentioned ×1subscribed ×1

Fix Action

Fix / Workaround

Whatever patch tool is being used by Codex when rewriting files has a habit of adding or removing blank lines at the ends of files, seemingly at random. I've gotten to the point where my prompts and AGENTS files repeatedly say things like "double check that you don't modify blank lines at the ends of files". I suspect this is a bug in the tool the agent is using and not in the main part of the agent itself, but that's a guess.

RAW_BUFFERClick to expand / collapse

What version of Codex CLI is running?

codex-cli 0.128.0

What subscription do you have?

Pro

Which model were you using?

GPT 5.5

What platform is your computer?

No response

What terminal emulator and version are you using (if applicable)?

Terminal.app

What issue are you seeing?

Whatever patch tool is being used by Codex when rewriting files has a habit of adding or removing blank lines at the ends of files, seemingly at random. I've gotten to the point where my prompts and AGENTS files repeatedly say things like "double check that you don't modify blank lines at the ends of files". I suspect this is a bug in the tool the agent is using and not in the main part of the agent itself, but that's a guess.

What steps can reproduce the bug?

Modify a lot of files, look at the diffs, notice that blank lines get removed or sometimes added to the ends of files without much rhyme or reason.

What is the expected behavior?

No response

Additional information

No response

extent analysis

TL;DR

The issue can be mitigated by manually reviewing and adjusting file modifications made by the Codex CLI to ensure blank lines at the ends of files are preserved as intended.

Guidance

  • Investigate the patch tool used by Codex CLI for file rewriting to identify if it has any configuration options or known issues related to handling blank lines.
  • Compare the diffs of modified files to understand the pattern of blank line additions or removals, which might help in pinpointing the cause.
  • Consider implementing a post-processing step to review and adjust the modified files for unwanted blank line changes before proceeding with further operations.
  • If the issue persists, report the problem with detailed examples to the Codex CLI support or community for further assistance.

Notes

The exact cause of the issue is not clear without more information about the patch tool or the specific operations being performed by the Codex CLI. Therefore, these suggestions are aimed at mitigating the symptoms rather than providing a definitive fix.

Recommendation

Apply workaround: Manually review and adjust file modifications, as the root cause of the issue is not immediately clear and may require further investigation or support from the Codex CLI developers.

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

codex - 💡(How to fix) Fix Codex CLI tends to add and remove blank lines when patching files [4 comments, 2 participants]