Patch fails on special characters

Resolved 💬 9 comments Opened Dec 14, 2025 by shakilkhan496 Closed Jan 15, 2026
💡 Likely answer: A maintainer (github-actions[bot], contributor) responded on this thread — see the highlighted reply below.

What version of the VS Code extension are you using?

latest

What subscription do you have?

chatgpt plus

Which IDE are you using?

VS Code

What platform is your computer?

Microsoft Windows NT 10.0.26120.0 x64 Microsoft Windows NT 10.0.26120.0 AMD64

What issue are you seeing?

Codex sometimes do very struggles to patch on long file code, so it takes a long time to respond in Windows PowerShell mode

What steps can reproduce the bug?

try to edit a large file with codex

What is the expected behavior?

it should patch properly

Additional information

The issue is that it generates correct code, but it fails when applying a patch that includes certain special characters. As a result, it deletes the entire file and recreates it from scratch, which increases both token usage and processing time.

View original on GitHub ↗

9 Comments

github-actions[bot] contributor · 7 months ago

Potential duplicates detected. Please review them and close your issue if it is a duplicate.

  • #6358

Powered by Codex Action

etraut-openai contributor · 7 months ago

Can you provide more details? You mentioned "special characters" in the bug title. Can you be more specific? Are you talking about non-ASCII unicode characters?

Please use the /feedback command to upload a session where this has occurred and post the thread ID here.

Without additional details, it's unlikely we'll be able to diagnose this.

shakilkhan496 · 7 months ago

Hi @etraut-openai — thanks for taking a look.

By “special characters” I mean cases where the patch includes non-ASCII Unicode and/or characters that are commonly tricky in diffs. In my repros it’s happened with things like:

  • Curly quotes / dashes: “ ” ‘ ’ — –
  • Zero-width / invisible chars (copied from docs/chat)
  • Non-Latin text (e.g., Bengali characters)
  • Occasionally when the edited block contains a mix of these alongside code punctuation (backticks, quotes, etc.)

What I see on Windows (VS Code + PowerShell terminal):

  • Codex generates the correct change, but when applying the patch to a large file, the patch step fails around the region containing the characters above.
  • After that, it appears to delete the file contents and recreate the whole file (full rewrite) instead of applying a minimal diff — which increases token usage and response time.

Repro (minimal):

  1. Create/open a large .ts/.tsx file (1k+ lines).
  2. Include a string/comment with “quotes” — dashes and some non-ASCII text.
  3. Ask Codex to edit a section that touches that region (even a small change).
  4. Patch fails → file gets rewritten from scratch.

I’ll use /feedback to upload a session where this occurred and will paste the thread ID here (and I can also attach a minimal sample file if that helps).

sayan-oai contributor · 7 months ago

Hey @shakilkhan496 , can you provide the thread-id via the /feedback command? Thanks.

shakilkhan496 · 7 months ago

<img width="711" height="829" alt="Image" src="https://github.com/user-attachments/assets/517ece73-8b91-496e-b8d2-4d8cbd17c413" />
Look, I just said to update the footer design; it is taking 40 minutes and involves deleting and editing files with a loop.

christopherpross · 7 months ago

Hey,
german user on windows system here. I found this issue and think this could be related. If not, just say, then i will open an other issue.
In my case, i have a german markdown file with non-ascii characters, like "ü" etc. Codex tries to do then editing with powershell, which is unstable (encoding, escaping)...
I hope my feedback id helps.
If you need more informations, just ask! This is strange and anoying, so i hope this can be fixed.

Feedback-id: 019b4017-14db-7611-850e-1ef10f0e575a

dylan-hurd-oai contributor · 6 months ago

We merged an experimental fix for shell output encoding in https://github.com/openai/codex/pull/7902, which should help with this. You can test out by running codex --enable powershell_utf8 or adding features.powershell_utf8 = true to your config.toml.

@christopherpross @shakilkhan496 can you try this feature out and let us know if it works for you?

shakilkhan496 · 6 months ago
We merged an experimental fix for shell output encoding in #7902, which should help with this. You can test out by running codex --enable powershell_utf8 or adding features.powershell_utf8 = true to your config.toml. @christopherpross @shakilkhan496 can you try this feature out and let us know if it works for you?

Sure thanks I will try soon! Really appreciate 🙏

shakilkhan496 · 6 months ago

@dylan-hurd-oai Perfect, everything works great, and super-fast editing after features.powershell_utf8 = truethis update.