Skip to content

Context compaction rewrites the stored rollout in place and permanently destroys the conversation transcript #44363

Open

Description

@noclascio

What version of the Codex App are you using (From “About Codex” dialog)?

Version 26.903.61454

What subscription do you have?

Pro

What platform is your computer?

Darwin 25.6.0 arm64 arm

What issue are you seeing?

Environment

  • Codex desktop (ChatGPT.app) 26.903.61454 (build 8378), macOS 26.6.1, Apple Silicon
  • Session cli_version recorded in rollout: 0.144.0-alpha.4
  • Long-running remote-control session, hosted on a Mac mini, accessed from iPhone / another Mac

Summary

Context compaction rewrote the session's rollout .jsonl in place, replacing the durable
transcript with a compacted summary. The file went from 851,046,757 bytes / 122,877 records
to 7,117,868 bytes / 762 records. All 3,777 assistant messages were discarded. Only the
584 user messages survived, embedded in a replacement_history array inside a single
compacted record, alongside one encrypted_content compaction entry.

Because the app renders thread history from the rollout, the entire visible conversation
disappeared from every client simultaneously (Mac mini, MacBook, iPhone). The session itself kept
running and kept responding.

Compaction should bound what the model carries in context. It should not be destructive to the
stored record. Here the working context and the durable transcript are the same file, so trimming
one destroyed the other.

Impact

  • Two months of conversation (2026-07-11 → 2026-09-09) became unrenderable and unrecoverable
    from the live installation.
  • Loss is silent. No warning before, no error after. The thread still lists and still accepts
    messages; it just shows nothing.
  • Recovery was only possible because an APFS local Time Machine snapshot happened to exist from
    12 minutes before the rewrite.

Timeline (local time)

Time Event
2026-07-11 15:27:42 Session starts. Rollout created.
~2 months Normal use. 175 compacted records accumulate; the file retains full history throughout.
2026-09-09 17:59:21 Rollout file recreated (birth timestamp), 851 MB → 7.1 MB. Assistant turns discarded.
2026-09-09 18:50:50 legacy_to_paginated_v1 migration runs against the now-truncated file.
2026-09-09 18:54 User notices blank history on all three clients.

Note the filename still encodes the original July start time
(rollout-2026-07-11T15-27-42-<thread-id>.jsonl) while the inode's birth time is the compaction
moment. Records at the head of the rewritten file carry July timestamps but contain September
message IDs, which is what makes the rewrite visible.

Reproduction

Not deliberately reproduced — this was a production session. Conditions present:

  1. Very long-lived thread (2 months, ~3.07 billion cumulative tokens reported in token_count).
  2. Multi-agent use — the thread spawned ~170 sub-agent threads.
  3. Always-loaded remote-control session (auto-resumed via startup_prewarm on every app-server start).
  4. Context compaction triggered on a rollout of ~851 MB.

Secondary bug: migration silently skips the compacted rollout

The rewritten rollout carries a ContextCompaction item plus world_state and
token_usage_record record types. legacy_to_paginated_v1:

  • flipped threads.history_mode to paginated,
  • wrote thread_history_projection_state with the cursor parked at EOF
    (next_rollout_byte_offset = file size), so no backfill can ever occur,
  • projected zero items,
  • recorded no row in rollout_migration_skipped_rollouts.

Every other thread on the machine (2,000+) migrated correctly. Re-running the sweep will not
revisit this thread, because history_mode is already paginated.

Third issue: always-loaded threads never read stored history

For a thread that is loaded, thread/resume takes resume_running_thread and composes the
response from the in-memory session, which starts empty on each load. It never consults
thread_items. Combined with startup_prewarm auto-loading this session at app-server startup,
the stored-history path is unreachable for this thread — repopulating thread_items correctly
had no effect on what the client displayed.

Relevant log line, repeating on every open:

resume_running_thread: thread/resume overrides ignored for loaded thread <id>:
config overrides were provided and ignored while running

Also observed

The desktop client requests experimental feature keys the bundled app-server rejects as invalid,
including one directly related to this area:

ignoring invalid experimental feature enablement keys:
apps_mcp_path_override, background_paginated_rollout_migration, local_thread_store_compression

Expected behavior

  1. Compaction must not mutate or truncate the stored rollout. Bound the model's context window
    without destroying the durable record — separate files, or append a compaction marker while
    retaining prior records.
  2. If a destructive rewrite is genuinely intended, retain the pre-compaction file and warn.
  3. A migration that projects zero items must record a skip with a reason rather than marking the
    thread migrated.
  4. A loaded thread should fall back to stored history when its in-memory item list is empty.

Artifacts available

  • Pre-compaction rollout, 851,046,757 bytes, recovered from an APFS snapshot (SHA-256 available).
  • Post-compaction rollout, 7,117,868 bytes.
  • App-server logs covering the migration and every resume.

What steps can reproduce the bug?

Use the app. Watch your thread get destroyed.

What is the expected behavior?

No response

Additional information

No response

Activity

  1. added
    app
    on Sep 10, 2026
  2. added
    bug
    context
    session
    app-server
    on Sep 10, 2026
  3. github-actions commented on Sep 10, 2026

    @github-actions
    Contributor

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

    Powered by Codex Action

  4. noclascio commented on Sep 10, 2026

    @noclascio
    Author

    Related to #44033 but not a duplicate — and the difference matters for which subsystem is at fault.

    #44033 (Windows) shows the same end state: long-running threads whose JSONL shrank drastically
    (267 MB → 5.26 MB, 710 MB → 3.63 MB), zero rows in thread_turns/thread_items, projection
    state at EOF, legacy_to_paginated_v1 marker present. That matches this report on macOS, so the
    defect is cross-platform.

    Two differences worth keeping separate:

    1. Severity of the data loss. In #44033 the stored JSONL still contains user and assistant
    messages. In my case only user messages survived — the compacted record's replacement_history
    holds 584 entries, every one role: "user", and all 3,777 assistant turns are gone from disk.
    Same mechanism, worse outcome.

    2. What actually did the rewriting. #44033 documents the shrunken files and empty tables and
    asks whether it's a migration defect. The timestamps here say it isn't:

    • rollout file inode birth time: 2026-09-09 17:59:21 — the file was recreated then, two months
      after the session started, while the filename still encodes the original
      2026-07-11T15-27-42 start.
    • legacy_to_paginated_v1 completed at 18:50:50 — 51 minutes later, against an already
      truncated file.

    So the migration is a downstream victim, not the cause. It then compounds the problem by flipping
    threads.history_mode to paginated and writing thread_history_projection_state with the cursor
    already at EOF, projecting zero items and recording no row in rollout_migration_skipped_rollouts
    — which means re-running the sweep never revisits the thread.

    If these are consolidated, the fix needs to land on compaction's write path rather than on the
    migration.

  5. lufu159 commented on Sep 13, 2026

    @lufu159

    I can confirm what appears to be the same destructive-compaction issue on Windows.

    Environment

    • Windows x64
    • Microsoft Store package: OpenAI.Codex_26.908.4834.0_x64
    • Bundled codex-cli: 0.154.0-alpha.6.2
    • The affected projects are located on a local drive, not a mapped network drive.
    • The affected tasks used different models, so the loss does not appear to be model-specific.

    Windows evidence

    Two long-running tasks remained visible and could still accept new messages, but most of their earlier assistant replies disappeared.

    • Affected rollout A is now approximately 5.81 MB. It contains 244 user entries inside replacement_history, but only 27 top-level assistant messages.
    • Affected rollout B is now approximately 1.80 MB. It contains 108 user entries inside replacement_history, but only 9 top-level assistant messages.
    • Rebuilding the SQLite history index/projection made the tasks scrollable again, but it did not restore the missing assistant content.
    • Every available Windows Volume Shadow Copy for these two tasks already contained the same compacted state, so the destructive rewrite occurred before those snapshots were created.

    In a separate earlier affected task, recovery succeeded only because a pre-rewrite Windows shadow copy was still available. That recovered rollout was approximately 1.46 GB and contained 145,824 records, including 8,869 assistant messages and 763 user messages.

    This Windows evidence supports the original report: the durable transcript appears to be destructively rewritten before or independently of the subsequent history projection/index migration. Once that rewrite has occurred, rebuilding the index cannot recover the discarded assistant messages.

    No project files, raw transcripts, local paths, hashes, or task IDs are included in this public comment. In-app diagnostic feedback has also been submitted, and the feedback/session ID can be provided privately to an OpenAI maintainer.

  6. MikelEguren commented on Sep 13, 2026

    @MikelEguren

    Additional Windows reproduction (sanitized), observed 2026-09-13:

    • Codex Desktop 26.908.4834.0 on Windows 11 x64. A long-lived local task remains listed and accepts new messages, but its earlier visible conversation history has disappeared. Restarting the app and reopening the task did not restore it.
    • A read-only task-history request with a 10-turn limit returned only four recent turns and reported no older page (nextCursor: null).
    • The current rollout JSONL parses as 464 records / 2,286,647 bytes. Its filename encodes an August session start, while the filesystem creation timestamp is September 11. It contains one compacted record with 118 replacement_history entries: 113 user messages, four developer messages, one compaction entry, and zero assistant messages. Only 20 top-level assistant message records remain in the current file. This is consistent with a rewritten/compacted durable transcript and loss of older assistant replies; without a pre-rewrite copy or write audit, I cannot establish the exact writer or the full extent of lost content.
    • A separate UI banner says the task's working directory no longer exists. A read-only check confirms that the former worktree directory is absent. I am reporting this as a co-occurring condition, not asserting that it caused the history loss.

    Expected: context compaction must not silently remove the user-visible conversation; if storage or projection cannot restore it, the app should show an explicit recoverable error and provide a supported non-destructive path.

    No conversation text, project names, task IDs, local paths, credentials, raw logs, transcript files, or screenshots are included. No source transcript or database was edited.

  7. sonicscrewdriver-leo commented on Sep 14, 2026

    @sonicscrewdriver-leo

    I can confirm a closely matching failure on Windows, with three affected long-running threads and a second history-projection failure observed during the same investigation. I filed a separate Windows case at #45350 and am linking it here because the rollout evidence strongly supports the compaction rewrite described in this issue.

    Environment

    • Windows x64, build 26100
    • Microsoft Store package: OpenAI.Codex_26.908.4834.0_x64
    • Bundled codex-cli: 0.154.0-alpha.6.2
    • Affected rollouts record CLI versions 0.146.0-alpha.9.2 and 0.147.0-alpha.6.6

    Sanitized rollout evidence

    All three current rollouts begin with session_meta followed immediately by one compacted record. No ordinary user or assistant messages exist before it. The compacted message field is empty.

    • Thread A: 3,578,844 bytes; filename encodes an August 4 start; Windows creation time is September 9. replacement_history contains 81 user items, three developer items, and one encrypted compaction item. Only 15 top-level assistant messages remain after the compacted record.
    • Thread B: 1,966,274 bytes; filename encodes an August 3 start; Windows creation time is September 9. replacement_history contains 132 user items, three developer items, and one encrypted compaction item. Only 22 top-level assistant messages remain.
    • Thread C: 1,784,535 bytes; filename encodes an August 15 start; Windows creation time is September 13. replacement_history contains 78 user items, three developer items, and one encrypted compaction item. Only 20 top-level assistant messages remain.

    The initial compacted records are byte-identical to a backup made before any local repair. Rebuilding the SQLite history projection restored later explicit messages but could not restore the earlier assistant transcript because those source records are absent from the current rollouts.

    Secondary projection failure

    Thirteen ordinary threads had completed message events in their JSONL source but no history items. After a full backup, rebuilding the projection restored 209 message items. A subsequent audit found source/index parity across 55 ordinary threads and complete app-server pagination for 53 content-bearing threads. This fixed the visibility/index layer only.

    No predecessor rollout was found in active or archived sessions, Codex caches, package storage, logs, temporary files, Recycle Bin, or older local databases. Windows File History was not configured, and an elevated VSS/restore-point check found no snapshots.

    This appears consistent with the original report: destructive rollout rewrite first, followed by a migration/projection failure that compounds the visible loss. No conversation text, task names, thread/window IDs, local paths, credentials, raw logs, or transcript files are included in this public comment.

  8. jsegeren commented on Sep 22, 2026

    @jsegeren

    This is a strong example of why the live Codex store should not be the only durable copy.

    Disclosure: I maintain Codex Migrate + Vault, an independent Mac tool. Vault keeps encrypted, versioned snapshots of local Codex conversations in a folder the user controls—including OneDrive, Google Drive, or iCloud—and provides verification, search, export, and guarded recovery.

    It cannot reconstruct content destroyed before the first snapshot, but a pre-compaction snapshot would preserve the original rollout instead of requiring a lucky Time Machine snapshot. I’d be happy to test this exact failure mode using a redacted fixture and personally help with setup.

    App: https://migrate.segeren.com/
    Free MIT source: https://github.com/jsegeren/codex-migrate

  9. jsegeren commented on Sep 22, 2026

    @jsegeren

    Update after more disposable tests on macOS Codex CLI 0.155.0-alpha.16. These are CLI hook results, not a reproduction of the desktop rollout rewrite reported here.

    • A trusted synchronous PreCompact hook received a readable transcript_path on manual and automatic CLI compaction. Before manual /compact finished, a test-only hook encrypted the pre-compaction transcript with AES-256-GCM, reopened and authenticated the ciphertext, and an independent verifier decrypted it and matched the 78,899-byte count and SHA-256. No hook is installed in customer sessions.
    • With the disposable checkpoint key unavailable, the hook returned continue: false. The tested CLI stopped manual /compact and, separately, automatic compaction triggered with an artificially low test threshold.
    • Crucial negative case: a hook command that slept for five seconds with timeout=1 logged “Hook failed — hook timed out after 1s”, but manual /compact still reported “Context compacted.” In this CLI build, a hook timeout fails open. So PreCompact alone is not a reliable write-ahead safety boundary.
    • In four disposable app-server thread/compact/start runs on the same binary, compaction completed without a hook notification or checkpoint. The hook was configured and listed as enabled but had trustStatus: modified, so this does not distinguish a trust skip from a missing app-server invocation.

    This still does not establish whether the affected desktop/app-server on-disk rewrite invokes PreCompact before replacing the durable rollout. Even if it does, the timeout path leaves a loss window. The robust upstream fix is to keep the durable transcript independent of compacted model context, or retain a verified predecessor before any destructive rewrite; history projection should not report success after projecting zero items. Could maintainers confirm desktop rewrite ordering and whether a fail-closed error/timeout option is planned for PreCompact? Versioned backups remain useful, but can recover only the last verified capture, not content already destroyed before it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    appapp-serverbugcontextsession

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions