Skip to content

Codex compaction retains hundreds of historical user messages, leaving ~187K active context after compaction #45296

Open

Description

@marko69420

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

26.901.31953

What subscription do you have?

ChatGPT Plus

What platform is your computer?

Windows

What issue are you seeing?

In very long-running Codex Goals, context compaction does not significantly reduce the active working set.

Using the default Codex configuration, I observed a compaction event that retained 192 historical user messages alongside the generated compaction checkpoint.

The checkpoint itself was only ~41.9K serialized characters, while the retained user messages occupied ~1.95M characters.

Immediately after compaction, the next model request still contained 187,306 input tokens.

Prompt caching was working correctly (~99.84% cached), so this does not appear to be a cache issue. The problem is that a large amount of historical user content remains pinned in the active context after compaction.

codex-context-compaction-retention-report.md

What steps can reproduce the bug?

  1. Use the default Codex configuration.
  2. Start or continue a very large, long-running Codex Goal.
  3. Allow the Goal to accumulate many messages and go through automatic context compactions.
  4. Inspect a recent "compacted" event in the local rollout JSONL.
  5. Inspect replacement_history and count retained messages.
  6. Inspect the first token_count event after compaction.

In my case:

  • Compaction window: 420
  • Replacement-history items: 194
  • Retained user messages: 192
  • Retained user-message size: ~1,948,886 serialized characters
  • Compaction checkpoint size: ~41,922 characters

The next request after compaction contained:

  • Input tokens: 187,306
  • Cached input: 187,008
  • Uncached input: 298
  • Output: 31

I can reproduce the behavior when a Codex Goal becomes sufficiently large.

What is the expected behavior?

Compaction should preserve the full conversation in local/searchable history while substantially reducing the active context sent to the model.

Older completed or superseded messages should be summarized or represented through retrievable references instead of keeping hundreds of historical user messages active after compaction.

The goal is not to reduce Codex's maximum context capacity, but to make compaction actually produce a smaller working set.

Additional information

This occurred with the default Codex configuration. I am not using a custom compact_prompt or experimental_compact_prompt_file.

Codex App version: 26.901.31953
Platform: Windows x64
Subscription: ChatGPT Plus

The issue becomes reproducible in sufficiently large/long-running Goals.

25 retained messages accounted for approximately 98.7% of the retained user-message data, suggesting that a relatively small number of very large historical messages or attachments dominate the post-compaction working set.

I also have a redacted JSONL excerpt containing only the relevant compaction metadata and the immediately following token_count event, with prompts, paths, credentials, and account identifiers removed.

Activity

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

    @github-actions
    Contributor

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

    Powered by Codex Action

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

    appbugcontext

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions