openai / openai/codex

[Codex desktop] User messages disappear from rendered history after context compaction

Open
#41,954 3 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

app bug context session
Dominant language
Rust
Stars
125k
Forks
19.4k
PR merge metrics
PR metrics pending

Description

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

Unknown (not available in current About dialog)

What subscription do you have?

Not provided

What platform is your computer?

Darwin 25.3.0 arm64 arm

What issue are you seeing?

Summary

After a long-running local Codex task undergoes repeated context compaction, the desktop app no longer renders many historical user messages. The task title, search result, and most assistant messages remain available.

The original user messages are still present in the raw rollout data inside compacted.payload.replacement_history, but the rendered history returns empty user-message items.

Actual behavior

  • The task remains searchable and can be opened.

  • Some assistant messages are rendered.

  • Many historical user messages are blank or missing.

  • The history API/materialized output contains items equivalent to:

    {"type":"userMessage","text":""}
    
  • The raw rollout still contains the original user text in replacement_history.

Evidence

The raw rollout contains records shaped like:

{
  "type": "compacted",
  "payload": {
    "message": "",
    "replacement_history": [
      {"role":"user","content":[{"type":"input_text","text":"<original user message>"}]}
    ]
  }
}

Observed local statistics:

  • 44 compaction records;
  • all 44 have an empty payload.message;
  • replacement_history still contains the original user messages;
  • SQLite integrity check succeeds.

The local log also repeatedly reports:

thread history projection expected ordinal 47511, got 47513;
1 rejected rollout lines cannot cover that gap
error=trailing characters at line 1 column 12

Relevant components in the log:

codex_thread_store::local::thread_history_materialization
codex_thread_store::local::live_writer

Suspected cause

The durable history projection appears to treat the empty compacted.payload.message as the displayable history, but does not expand replacement_history back into user-visible messages. A separate ordinal-accounting or record-filtering issue around world_state and turn_context then causes the projection to retry indefinitely.

What steps can reproduce the bug?
  1. Start a local Codex task with a long multi-turn conversation.
  2. Allow the task to trigger context compaction multiple times.
  3. Close and reopen the task in the Codex desktop app.
  4. Scroll back through the conversation history.
  5. Compare the rendered history with the raw rollout data.
What is the expected behavior?

The renderer should rehydrate the messages in compacted.payload.replacement_history and display the original user and assistant messages in the correct order.

Internal world_state and turn_context records should not create a permanent history gap.

Additional information
  • OS: macOS
  • Codex app version: Unknown (not available in current About dialog)
  • Execution mode: local task
  • Task: long-running task with repeated context compaction

The attached rollout and logs contain private prompts, local paths, task IDs, and possibly sensitive project data. Any attached files should be redacted before publication.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the codex_thread_store::local::thread_history_materialization and live_writer components, then compare compacted.payload.replacement_history with the rendered history and the reported ordinal gaps. Reproduce the issue using a long-running local task with repeated compaction and inspect the attached rollout and logs. Done means historical user and assistant messages render in order without permanent gaps from world_state or turn_context records.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust, sqlite
Domain
databases, desktop-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.