Skip to content

[Feature Request] Scoped context compaction for exploratory phases #14747

Closed as not planned

Description

@cyborg42

What variant of Codex are you using?

CLI

What feature would you like to see?

A way to compress a specific segment of the conversation history — not the whole thing — when that segment represents a completed exploratory phase.

Problem

Current context management in Codex compresses the entire history when approaching limits. But real agentic sessions have structure:

turns 1–30:   initial setup, requirements gathering
turns 31–80:  exploring a bug → lots of dead ends, tool calls, false starts
turn 81:      conclusion reached: "the issue is in X, fix is Y"
turns 82–...: implementing the fix

When compaction fires, the entire history gets summarized — including turns 1–30 (still relevant setup context) and turns 31–80 (completed exploration). The precise conclusion from turn 81 gets diluted into the global summary, and the setup context from turns 1–30 is unnecessarily compressed too.

Proposed solution

A scoped compaction primitive: compress only a defined range of turns into a conclusion block, leaving the rest of the context intact.

# Agent-callable tool — compress only the exploration phase, leave setup and implementation intact
compact_scope(discard_from=31, summary="root cause: X, fix: Y")

The agent could call this autonomously when it detects a phase transition (e.g. "I've finished investigating, now implementing").

Why this matters

  • Precision: A narrow-scope summary is more accurate than a global one — the model knows exactly what conclusion was reached
  • Continuity: The rest of the session (implementation, tests, etc.) stays fully intact, not re-summarized
  • Cost: Exploratory turns are token-heavy but conclusion-light; compressing them early reduces ongoing costs
  • Distinct from subagents: This is about the main agent's own session history — subagents are a separate orthogonal concept

Suggested implementation path

Could be built as a layer on top of existing session serialization — select a turn range, run a focused summarization pass, replace with a <conclusion> block, continue. No new API primitives required.

Additional information

No response

Activity

  1. added
    enhancement
    on Mar 15, 2026
  2. github-actions commented on Mar 15, 2026

    @github-actions
    Contributor
  3. added
    context
    on Mar 15, 2026
  4. etraut-openai commented on Apr 18, 2026

    @etraut-openai
    Contributor

    This feature request hasn't received any upvotes in over a month, so I'm going to close 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

    contextenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions