Skip to content

Add history message compression to prevent context overflow #3416

@fannnzhang

Description

@fannnzhang

Description

Currently, Codex maintains the full history of messages without any compression or summarization mechanism. This can cause problems in long-running tasks:

  • The accumulated conversation history may exceed the maximum context length of the underlying large language model.
  • Once the context window is exceeded, older parts of the history are dropped, which can lead to loss of important information.
  • This often results in failed executions or unexpected outputs, as the model no longer has access to the full task context.

Proposed Solution

Introduce a history compression mechanism, such as:

  • Summarizing older messages into a shorter form while preserving key details.
  • Allowing configurable strategies (e.g., summarization, truncation, or selective retention).
  • Providing hooks for custom compression strategies, so developers can tailor it to their use case.

Benefit

This feature would make Codex more reliable for handling long-running tasks and ensure better alignment with the model’s context limitations, improving both stability and predictability.

Are you interested in implementing this feature?

Yes, I am interested in working on this feature. However, I believe message history compression can be a complex task. It may be best to start with a basic version first, and then gradually improve it.

Additional information

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions