Codex App freezes when pasting JSON stack traces with escaped backslashes into composer
What version of the Codex App are you using (From “About Codex” dialog)?
26.527.60818 (3437)
What subscription do you have?
Enterprise
What platform is your computer?
Darwin 24.6.0 arm64 arm
What issue are you seeing?
Codex Desktop freezes when I paste a medium-sized JSON stack trace into the composer.
The renderer process stays near 100% CPU and the UI becomes unresponsive. This happens in a new chat as the first pasted input, so it does not appear to be caused by thread history size.
The trigger is a JSON array such as stackTrace: [ containing many escaped stack-frame strings with sequences like \" and \n. This is common when copying AWS Lambda / Python stack traces as JSON:
{
"stackTrace": [
" File \"/var/task/src/application/services.py\", line 688, in fetch_events\n events = future.result()\n"
]
}
Important observations:
- Pasting random ASCII text of the same length does not freeze.
- Pasting multiline random ASCII text of the same length does not freeze.
- Pasting JSON-like text without escaped backslashes does not freeze.
- Pasting
File \"...\", line ...text outside a JSON/bracketed structure does not freeze. - Pasting text at or above 5000 characters does not freeze because Codex converts it into
Pasted text.txt. - Pasting under 5000 characters freezes because it is inspected and inserted directly into the composer.
This looks like catastrophic backtracking in the paste-time Markdown link / rich prompt detection regex, not a backend/Lambda issue or spellcheck issue.
What steps can reproduce the bug?
- Open Codex Desktop.
- Open a new chat.
- Paste a generated text under 5000 characters that contains:
- an opening
[ - many backslash escape sequences such as
\" - no valid Markdown link terminator
](...)
- Observe that Codex Desktop becomes unresponsive and a renderer process pegs CPU near 100%.
Minimal generator:
const target = 4991;
let text = '{\n "stackTrace": [\n';
let i = 0;
while (text.length < target) {
text += ` "alpha beta gamma \\"quoted\\" delta epsilon ${i}",\n`;
i += 1;
}
text = text.slice(0, target);
console.log(text);
I also reproduced the core slowdown outside Codex Desktop in Node/V8 with the same regex shape used by the composer paste path:
const markdownLink = /\[((?:\\.|[^\]])+)\]\(((?:\\.|[^)])+)\)/g;
Measured results for a JSON-stack-trace-like string:
1200 chars: ~21 ms
1400 chars: ~262 ms
1600 chars: ~1.47 s
1800 chars: >5 s timeout
Measured results with a fixed 2000-character string:
[`... 16 backslash escapes ...]` without `](`: ~207 ms
[`... 20 backslash escapes ...]` without `](`: ~3 s
[`... 24 backslash escapes ...]` without `](`: >5 s timeout
same 40 backslash escapes with valid `](target)`: ~0.04 ms
What is the expected behavior?
Pasting this text should not freeze the composer.
If Codex needs to inspect pasted text for rich links or mentions, that detection should be bounded and should not block the renderer. If the pasted text is too expensive to inspect safely, Codex should treat it as plain text or convert it into a pasted-text attachment.
Additional information
Environment details:
- macOS 15.7 (24G222)
- Apple Silicon
- Bundle ID:
com.openai.codex app.asarSHA-256:de59889d6501fc863a825c3e1c05a902ce5e001dff4d1e65474d5ae73768c0ae
The likely root cause is the Markdown link detection regex used during paste handling:
/\[((?:\\.|[^\]])+)\]\(((?:\\.|[^)])+)\)/g
The subpattern (?:\\.|[^\]])+ is ambiguous because a backslash can match both alternatives:
\\.[^\]]
When a string contains [ followed by many escaped backslashes or escaped quotes, but does not form a valid Markdown link ](...), V8 spends a long time backtracking.
Making the fallback character classes exclude backslash removes the slowdown in my local reproduction:
/\[((?:\\.|[^\\\]])+)\]\(((?:\\.|[^\\)])+)\)/g
With that safer pattern, the same 4991-character heavy cases complete in about 0.06-0.10 ms.
Possible fixes:
- Make Markdown link detection regexes unambiguous by excluding backslash from fallback character classes.
- Add a length/time guard around paste-time rich prompt parsing.
- Skip rich prompt parsing for stack-trace-like pasted JSON under 5000 characters, or convert medium-sized pasted text to an attachment before running expensive detection.
Workarounds:
- Paste stack traces as
.txtattachments. - Paste at or above 5000 characters so Codex converts the content into
Pasted text.txt. - Decode escaped JSON stack-trace strings before pasting.
9 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
I checked the suggested duplicates. They look related, but this report has a narrower repro and points to
the paste-time Markdown link regex backtracking path.
I hit a related recovery failure mode after a large pasted payload made the composer unusable on session reopen. The important detail: clearing only the Codex session history is not enough, because the VS Code extension can keep/rewrite the stuck composer text from its own persisted state.
Workaround that recovered the affected session without deleting the conversation:
ItemTable, keyopenai.chatgpt, parse the JSON value and remove:In my case the stuck composer text started with
1) href=..., and deleting onlycomposer-prompt-drafts-v1did not help becauseprompt-historyrestored/reseeded it.ItemTable.value, then optionally runVACUUMon the DB so the raw pasted bytes are physically removed from the SQLite file.A minimal Python shape of the recovery is(replace "1) href" with yours prompt starts) :
This is only a local recovery workaround, not the root fix for the paste-time freeze, but it should help affected users recover a session while preserving the conversation.
Adding a Windows datapoint that appears to be the same paste-path bug, with an additional recovery clue.
Environment:
26.602.4764.0#simulation-result, containing\[,\],\,,\:,\(,\., Tailwind arbitrary value classes, and>combinators.Observed:
electron-persisted-atom-state.composer-prompt-drafts-v1.new-conversation.codex-global-state.json/.codex-global-state.json.bakrestored the app without touching local sessions.This suggests the paste parser can freeze before or during autosave, and then the persisted draft re-enters the expensive path on restart. Besides fixing the paste-time regex/backtracking path, Codex should avoid synchronously hydrating persisted composer drafts through the same unsafe rich parsing path, or should timeout/drop/attach drafts that match this unsafe case.
Workaround/recovery:
.txtfile and ask Codex to read it.Adding another macOS datapoint that appears to be the same paste-time composer freeze.
Environment:
Observed:
This payload is small and contains nested escaped JSON inside the
messageContentstring, so it does not look like a large-paste or history-size issue.Payload:
The specific pattern here is a JSON array with a
messageContentfield whose value is itself a JSON string with many escaped quotes and nestedcomponentProps.messageDatacontent.I hit what appears to be the same paste/composer freeze on Windows.
Additional reproduction details:
Two examples that triggered the freeze for me:
stackTracearray with escaped Windows paths, for example strings like:torch.multiprocessing.spawn.ProcessRaisedException, Windows paths, and nested traceback text.I originally opened #27135 before noticing this duplicate. Closing that one as a duplicate and leaving this additional Windows repro data here.
Additional reproduction case — escaped JSON with CJK characters
App version:
0.124.0Platform:
Darwin 24.6.0 arm64 armWhat issue are you seeing?
Same freeze as described in this issue. Pasting a JSON array (~800 chars) containing escaped Chinese address fields into the composer causes immediate UI hang. The renderer CPU spikes to ~100% and the app must be force-quit.
Steps to reproduce
Sanitized repro payload
Sensitive fields (phone, userId, lat/lng, name) replaced with placeholders. The escaped JSON structure and CJK characters are preserved — these are the trigger.
Why it triggers
Matches the root cause in this issue exactly:
[— the regex enters the Markdown link capture group\"escape sequences — each creates an ambiguous branch for(?:\\.|[^\]])+](url)terminator — the engine backtracks exponentiallyThe CJK characters (
某某路,某某省) add extra bytes per character but are not the primary cause — the freeze reproduces with ASCII-only escaped JSON of similar length as well.Add another situation that can also be replicated
critical-text.txt
Adding one more Windows datapoint.
I was able to reproduce the slowdown/freeze with a very small user-authored prompt containing escaped backslash sequences inside square brackets, without a valid Markdown link terminator.
Minimal payload that triggered the issue in my local test:
One useful distinction from my testing: the problematic behavior appears to be on the user/composer/user-message rendering path. The same payload rendered in an assistant response did not trigger the same slowdown locally.
I also isolated the Markdown-link detection pattern and confirmed this reduced payload can exceed 10s in a worker benchmark, while removing either the square brackets or the backslash escape sequences makes it return immediately.
This seems consistent with the catastrophic backtracking explanation already described here.