Repository navigation
Codex Desktop App becomes laggy because it scans all ~/.codex/sessions rollout files instead of respecting Desktop-visible session index/state #20864
Description
What version of the Codex App are you using (From “About Codex” dialog)?
Version 26.429.30905 (2345)
What subscription do you have?
Pro and Business
What platform is your computer?
Darwin 25.3.0 arm64 arm
What issue are you seeing?
Summary
Codex Desktop App becomes slow/unresponsive when ~/.codex/sessions contains many rollout JSONL files.
The important point: these session files are not only created by Codex Desktop. They are also created by other Codex clients that share the same CODEX_HOME, including CLI, codex exec, app-server clients, VS Code-style clients, and subagents.
Desktop appears to scan/read the entire ~/.codex/sessions folder, even though ~/.codex/session_index.jsonl contains a much smaller set of sessions that seem to be the intended Desktop-visible history.
Clearing or moving files out of ~/.codex/sessions immediately fixes the Desktop UI lag.
Environment
- Codex Desktop App: Version 26.429.30905 (2345)
- Codex CLI:
codex-cli 0.128.0 - OS: macOS
- Platform: Apple Silicon / Darwin
CODEX_HOME: default~/.codex
Actual behaviour
Codex Desktop App becomes laggy as ~/.codex/sessions grows.
In my local case:
find ~/.codex/sessions -type f -name '*.jsonl' | wc -l
# 109
du -sh ~/.codex/sessions
# 78M
wc -l ~/.codex/session_index.jsonl
# 22The Desktop app becomes responsive again after clearing/moving files out of ~/.codex/sessions.
What steps can reproduce the bug?
- Use Codex Desktop App with the default
CODEX_HOME. - Also use Codex CLI / app-server / other Codex clients that share the same
CODEX_HOME. - Let
~/.codex/sessionsaccumulate many rollout JSONL files. - Open Codex Desktop App.
- Observe Desktop UI lag/slowness.
- Move or clear old files from
~/.codex/sessions. - Reopen Codex Desktop App.
- Observe that the lag is resolved.
What is the expected behavior?
Codex Desktop App should not eagerly scan or parse every rollout JSONL file under ~/.codex/sessions.
Desktop should only load the sessions it needs for its UI, using a bounded/indexed source of truth such as:
~/.codex/state_5.sqlite~/.codex/session_index.jsonl- Desktop-visible source filters
- lazy loading when a specific thread is opened
The Desktop UI should not degrade just because other Codex clients share the same CODEX_HOME.
Evidence / investigation
The sessions folder contains rollout files from multiple sources, not just Desktop-created sessions.
Observed source breakdown included:
vscode: 64
exec: 22
cli: 3
subagent / guardian / thread_spawn: multiple
Meanwhile:
~/.codex/session_index.jsonl: 22 entries
~/.codex/sessions: 109 rollout files
Archived sessions are physically moved out of the hot sessions tree into:
~/.codex/archived_sessions/
and state_5.sqlite marks them as archived. This suggests that files physically present under ~/.codex/sessions are on the Desktop hot path.
Additional information
Suggested fix
Make Codex Desktop App avoid full eager scans of ~/.codex/sessions.
Possible approaches:
- Use
state_5.sqliteorsession_index.jsonlas the bounded source for Desktop history. - Filter by Desktop-relevant sources before touching rollout JSONL contents.
- Lazy-load rollout files only when opening a specific thread.
- Avoid scan-and-repair work across all rollout files during normal Desktop startup or history rendering.
- Add a way to hide/archive non-Desktop sessions from Desktop history.
The core issue is that Codex Desktop App appears to pay an O(number/size of all rollout files) cost for a shared sessions directory that is written by many Codex clients.
Activity
github-actions commentedon May 3, 2026
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
codex resumepicker is slow with many local sessions because thread/list scans rollout files #19517Powered by Codex Action
ebarti commentedon May 3, 2026
I stumbled upon this in the past too - I even lost threads in Codex because of this. Since then, if I invoke codex programmatically or via the SDK I always set a different CODEX_HOME env var. The painful thing is you need to make sure the authentication in this secondary CODEX_HOME is valid
8th-block commentedon May 3, 2026
I just use a clean-up script for now. Use it at your own risk :-) it will probably break in the future when the app changes - they move fast
8th-block commentedon May 3, 2026
Those of you running heavily automated coding agents which generate lots of sessions. Use a separate CODEX_HOME and copy your auth in there from your regular codex home. HT(🎩): @ebarti
ebarti commentedon May 3, 2026
But I totally agree this should be something better handled natively by Codex. Not sure why they would think having programmatic and interactive sessions in the same session storage was a good idea 😓
8th-block commentedon May 3, 2026
it is simple. They are overworked and have different priorities ... been there
etraut-openai commentedon May 3, 2026
All client instances (including the CLI and app) share a database (
~/.codex/state_5.sqlite) that stores an indexed table of sessions. This eliminates the need for clients to scan all of~/.codex/sessionsat startup. If you are seeing large scans of the sessions directory, then something is very wrong. Perhaps the database has become corrupted, and Codex is attempting to rebuild it.dm-8thblock commentedon May 3, 2026
Thanks for your response I am merely posting my observations (& best guess what went wrong really). I can consistently reproduce the issue by running a large number of sessions via my local symphony, watch Codex App degrade and become laggy, then prune all my Symphony sessions stored in ~/.codex/sessions which then resolves fully the unresponsiveness with the Codex app snapping back to working well aagain. Tried on my Mac Studio and MacBook - same problem. Just FYI and hope this helps!
etraut-openai commentedon May 3, 2026
How are you "pruning your sessions"? There is currently no app server API for deleting sessions; there is an API for archiving sessions. If you're deleting or otherwise manipulating the files under
~/.codex/sessionsbehind the back of Codex, that might explain why Codex is going in to "rebuild the database" mode when it starts.dm-8thblock commentedon May 3, 2026
I was using that script above I posted earlier . Also just getting rid of the ~/.codex/sessions folder solved the lag initially during the investigation. that is how I narrowed down which piece was causing a problem for me
ebarti commentedon May 3, 2026
@etraut-openai I see extremely degraded performance since the last update, but I have been running Codex agents in a separate CODEX_HOME directory via the Codex SDK for a while now.
valdineipigajunior commentedon May 4, 2026
Here, the same thing happens. After a few days of conversation, the specific chat becomes very slow, both to open and minimize while it's processing data. If you open a new chat in the project, it will always be fast, until you chat for a while, then the slowness returns. It's quite amateurish how Codex handles this. The problem is that when you start a new chat, it always starts out "dumb," and you have to keep summarizing the slow chat and pasting it into the new, clean chat.
dm-8thblock commentedon May 4, 2026
Do not diss other people’s work! They are busy enough and now they have to listen to people like you who can’t conduct themselves in a respectful manner.
john0123412 commentedon Jul 10, 2026
Additional repro on Windows — same index vs. full-directory-scan pattern
Environment: Codex Desktop 26.707.3748.0 (codex-cli 0.144.0-alpha.4), Windows 11 25H2, x64, 39.7GB RAM (~23GB free), disk queue 0 — resource exhaustion ruled out.
Symptom: severe UI lag on Windows too — noticeable delay on typing and scrolling, not just macOS.
I checked my local ~/.codex/sessions directory and found the same pattern described in this issue:
session_index.jsonl (the file Desktop-visible history actually reads from): 65KB
Full sessions directory: 326MB across 162 rollout JSONL files, largest single file 40MB
This matches OP's finding that the index is tiny while the actual scanned directory is much larger, which supports the theory that Desktop is full-scanning every historical rollout file under sessions rather than only reading session_index.jsonl.
Process-level data: 9 Codex-Desktop-related processes running, 3 of them holding ~820MB RAM with sustained 40%+ CPU. I have sandbox = "elevated" configured as well, though I haven't isolated whether that specifically compounds the lag or is incidental — flagging it in case it's useful, not asserting causation.
Possibly related (unconfirmed same root cause, flagging for triage rather than claiming they're the same bug):
Discussion #29949 — multiple Windows users reporting general Desktop lag since June; mechanism there looks more like renderer/GPU CPU spikes and isn't clearly tied to the sessions-directory scan specifically.
#11984 — long-session renderer memory growth up to 5GB+; this looks like single-session bloat rather than many-old-files full-scan, so may be a distinct mechanism with overlapping symptoms.
Expected behavior: Desktop should only load/reference the sessions listed in session_index.jsonl rather than scanning every historical rollout file under sessions.
lyy0709 commentedon Jul 14, 2026
The CLI hits this same scan through codex-core, and I can add the code-level mechanism plus some real-world numbers (traced on codex-cli 0.144.4, paths unchanged on current main).
Where the scan comes from
rollout/src/state_db.rs→try_init_with_roots_innercallswait_for_backfill_gate, which runsbackfill_sessionsinline in a loop untilBackfillStatus::Complete, up toSTARTUP_BACKFILL_WAIT_TIMEOUT= 30s (1s poll). On timeout it returns an error, state-DB init fails for that launch, and the next launch resumes scanning from the watermark — so users see repeated ~30s startup stalls until the backfill eventually converges.backfill_sessions(rollout/src/metadata.rs) walks~/.codex/sessionsand~/.codex/archived_sessions, and for every rollout callsextract_metadata_from_rollout→RolloutRecorder::load_rollout_items, which reads and parses the entire rollout JSONL into memory just to derive listing metadata (title/preview/timestamps/usage).state/src/lib.rs:pub const STATE_DB_FILENAME: &str = "state_5.sqlite"— so every schema bump starts a fresh DB with emptybackfill_stateand re-scans the whole tree from scratch. The scan is not a one-time cost; it comes back with upgrades.Numbers from one real
~/.codex(macOS, CLI): 1,030 rollout files totalling 1.8 GB, largest single files 203 MB and 163 MB. A fresh backfill therefore reads ~2 GB from disk and materializes >200 MB single files in memory. The whole-fileload_rollout_itemsmaterialization is probably also a contributor to the ingestion RSS blowups reported in #31040, and the 30s gate behavior matches #23787 / #28087.Possible directions
SessionMetaline plus a bounded tail (last timestamps/usage), so a capped head+tail read would replace the full-file parse; alternatively skip/degrade files above a size threshold.backfill_state(or at least the completed watermark) forward across schema bumps so a version upgrade doesn't rescan every historical session.helenananaa commentedon Jul 16, 2026
Additional Windows A/B reproduction: GPT-5.6 Ultra subagent fan-out makes the full-session scan cost explode.
Environment
26.707.12708.026200CODEX_HOMEquick_checkpassed; this was not database corruptionStrong model/mode correlation
I analyzed the persisted thread graph in
state_5.sqlite(root threads plusthread_spawn_edges) after several days of normal heavy use.Across 289 root trees / 816 total thread nodes:
gpt-5.6-* + ultraThe largest trees were:
gpt-5.6-sol + ultragpt-5.6-sol + ultragpt-5.6-sol + ultragpt-5.6-sol + ultragpt-5.6-sol + ultragpt-5.6-sol + ultraFor the 180-node tree,
thread_sourcewas 1 user root + 179 subagent children. The 97-node tree was 1 root + 96 subagents, and the 43-node tree was 1 root + 42 subagents. Nested depth-2 children were also present.The
tokens_usedvalues in the state DB are apparently cumulative and extremely large (the 180-node tree summed to about 127.4B), so token count may not be a directly comparable usage metric. The node counts, model/effort fields, spawn edges, and rollout files are unambiguous.Older long
gpt-5.5 + highsessions could have large token counters, but were typically single-node threads. The sharp tree fan-out appeared after using GPT-5.6 Ultra heavily.A/B recovery
Before cleanup:
Recovery procedure:
codex archive <root-thread-id>command (recursive archive).CODEX_HOME, because archived files are also on the backfill scan path described in this issue.After cleanup:
Responding=TrueReducing local text/GPU caches did not explain the durable recovery. The decisive variable was removing the large multi-agent rollout forest from the hot scan path.
Interpretation
This looks like an algorithmic scalability bug in backfill/list/hydration, not a GPT-5.6 inference bug by itself. GPT-5.6 Ultra is a strong amplifier because it creates dozens or hundreds of child rollouts per user-visible root. If startup/listing cost is proportional to all rollout bytes and all child files, a few Ultra sessions can turn an otherwise normal profile into an O(total rollout history) startup and UI workload.
It also creates a bad product tradeoff: keeping history accessible makes Desktop unusable, while moving it outside
CODEX_HOMErestores performance but removes it from the UI.Suggested invariants
This overlaps with #31198 (subagent rollout amplification), #32443 (many spawn edges/hydration), and #25779 (unbounded session-state meta issue), but the A/B above specifically confirms the
sessions/backfill performance mechanism in this issue on a current Windows build.drkvj commentedon Jul 31, 2026
Additional macOS reproduction on a current Desktop build, with measurements captured immediately after a fresh restart.
Environment
26.727.40816(bundle build6067)CODEX_HOMEFresh-restart behavior
Restarting did not resolve the problem. Within roughly 3–5 minutes of launch:
codex ... app-serverstayed around60–100% CPU3.5–3.7 GB1.2–1.3 GBRSSThis makes the restart recommendation ineffective for this profile: it releases the old processes, but the replacement app-server immediately returns to heavy work.
Session inventory
~/.codex/sessions: 19,593 rollout JSONL filessession_index.jsonl: 3,164 rows, 417 KBThe large mismatch between the Desktop-visible index and the full rollout tree is consistent with the full-directory/backfill mechanism described above.
Process evidence
A read-only macOS
sampleof the hot app-server showed activity in:serde_jsonstring parsingNo raw sample, logs, paths, task titles, prompts, repository names, screenshots, or transcript contents are attached because they may contain private project data.
The machine had about 195 GB free disk space, so this was not caused by a nearly full volume. OpenAI service status was also operational, making a local history/backfill path more likely than model or network latency.
Interpretation
This appears to be the same algorithmic scalability issue: after restart, interactive startup/listing or hydration performs work proportional to the accumulated rollout corpus rather than the small visible-session index. The extremely large individual active rollouts may additionally overlap with #21134.
Useful product behavior would be:
harryshawk commentedon Aug 1, 2026
Additional reproducible evidence from Codex Desktop on macOS.
Feedback Ref ID:
019fbf2d-6cdf-74d3-9ba9-b8649ce6931cEnvironment
/Volumes/Expansion/CodexHome/sessionsObserved behavior
After the prompt “I have the OAI finance plugin,” the Codex app-server launched five overlapping
rgprocesses. Each searched the entire session archive using progressively longer versions of the same prompt:Earlier searches were not cancelled when newer searches began. The five processes:
Pausing the task and its sub-agents did not stop these searches.
Secondary diagnostic failure
When asked what the five processes were, the task initially claimed they were retained sub-agents from earlier work and said it was closing completed agents. That diagnosis was factually incorrect: PID/process-tree inspection showed five active
rgchildren of the app-server. The task corrected itself only after the independent process evidence was presented.Ruled out
A newly mounted external NTFS drive was unrelated. It was mounted read-only with Spotlight indexing disabled, and the runaway processes targeted only the Codex session archive on the APFS volume. No thermal, disk-space, or malware signal was observed.
Expected behavior
This appears related to the broader runaway-
rgbehavior reported in #13717, but this reproduction specifically involves Codex Desktop session-history retrieval and an externalCODEX_HOMEsession store.joeblowma commentedon Aug 3, 2026
Ohhh! So that's what that was... in my experience:
Environment
Observed behavior
Opened the app, did nothing except check usage, found it consumed 3% of weekly plus usage. Even saw the spike on a usage graph earlier today... that I can't seem to even find again now.
Expected behavior
Additional comments
Uninstalled. Then spent a good while hunting around for the stuff it didn't uninstall, well outside the installation directory. Nearly 2GB of electrum and other backing apps/data, still possibly more I've yet to discover.
Caveat: I'm not going to reinstall this app to find out if it's fixed. Ever. It's enough work already just keeping codex-cli functional. Thanks for the fish!
joeblowma commentedon Aug 17, 2026
@shleder state hasn't changed aside from a few more cli sessions. Thanks for making me look, if the GUI parsed all of those with only 3% inference use... I guess that was actually kinda efficient 😆
codex-rescue sessionsshowed me 20 sessions and emitted nothing that looked like a problem. Not that I'm sure what I'd be looking for.Still have a bunch of rollouts going back to late Feb. Did a quick powershell script that spews the resulting doctor output to a file named after/beside the rollout, and ran doctor against all of them.
Basically every session at or before May 6 (my next session after that was may 19) is loaded with
UNKNOWN_OPERATIONAL_SCHEMA. I have a couple"status": "OVERSIZED_PAYLOAD", a singleUNFINISHED_TOOL_CALL, the rest sayHEALTHY.Anything in particular you'd like me to look for? Really should clean these up, 77 items weighing in at 126MB, largest single file 22.4MB.
Script I used
thedjpetersen commentedon Aug 22, 2026
Additional exact Cmd-K reproduction on the current unified ChatGPT/Codex desktop build.
Environment
26.803.61601(bundle build6396)Exact trigger and timing
thread/search.zzzcontent search: ~8.1 sProfiled hot path
A read-only macOS sample during
thread/searchshowed:codex_rollout::search::content_match_snippetreadserde_jsonparsingThis confirms Cmd-K's third-character transition is reparsing rollout JSONL and building snippets on the interactive search path. It is not a GPU/renderer issue: the backend RPC alone reproduces it. It is not primarily network search either.
The renderer query code also supplies no abort signal or latest-query-wins cancellation. A typist who pauses for >=200 ms can therefore start overlapping content scans, consistent with the incremental-search process evidence already reported above.
Suggested fix
thread/searchrequests, or enforce latest-query-wins in app-server.This narrows #20864 from general history scanning to a deterministic Cmd-K call site and backend hot path. cc @thsottiaux
thedjpetersen commentedon Aug 22, 2026
Deeper profile from the installed macOS build 26.803.61601 (6396), renderer build commit a59c4c74cf79511086d3f7eb123d5d5052067680.
I extracted the shipped ASAR and traced the exact path:
cel("root", query)enables content results at 3 characters (hel = 3).stldebounces withCtl = 200, then creates a distinct React Query key per term and calls every host withsearch-threads-for-host.queryFnignores React Query'ssignal; the hostsearchThreadsmethod sendsthread/searchas a background request with no cancellation path.utl) is a disabled "No matches" item; there is no create-chat action carrying the typed phrase.Native app-server measurements using the installed binary and synthetic non-matching terms:
codex_rollout::search::content_match_snippet.The long-lived live app also retained the pre-cleanup state: after ~69 hours its primary renderer was 1.26 GB RSS, app-server 1.08 GB, and Electron main 593 MB. A restart is required for the local mitigation to fully take effect.
Recommended product changes:
signal, cancel the IPC/app-server request, and check cancellation between files. At minimum serialize/coalesce by host.useDeferredValue/startTransition; memoizeQWaandeGa, which currently rebuild/filter/sort loaded chat metadata instlon each input render.@thsottiaux this includes the exact shipped call chain and native contention profile. Happy to provide sanitized sample output privately if useful.
zyy0212time-del commentedon Sep 13, 2026
Platform: Windows 11 x64 — the reports in this thread so far are macOS-only, so this adds a Windows data point. Same class of symptom: Codex Desktop gets slow / stutters while idle, and the cost scales with
~/.codex/sessions.Environment
OpenAI.Codexpackage version26.908.4834.0codex-cli 0.154.0-alpha.6.2(codex.exe --version)~/.codex/sessionssize (Windows)sessions+ 16 files / 1.75 GB already moved toarchived_sessions)sessions= 376 files / 0.92 GBCodex Desktop while idle
ChatGPT.exeprocesses, ~1.87 GB RSS totalthread/listfiring every 5–15 s continuously, even with no active conversationA/B test: disabling 7 plugins
Disabled
documents@openai-primary-runtime,pdf@openai-primary-runtime,spreadsheets@openai-primary-runtime,presentations@openai-primary-runtime,template-creator@openai-primary-runtime,unified-computer-use@openai-bundled,computer-use@openai-bundled.ChatGPT.exeprocessescodex*helper processesnode_replinstancesSo the plugin set costs one extra process, ~70 MB RSS and a noticeably heavier startup burst, but it is not the source of the sustained idle load. With 392 session files / ~2.6 GB on disk the app still burns ~10–18% of one core and runs 12 processes while sitting idle at the composer, which points at continuous session scanning /
thread/listpolling rather than at plugin startup.Affected: MSIX
26.908.4834.0(bundledcodex-cli 0.154.0-alpha.6.2).