[FEATURE] Add opaque/deep compaction for long-running coding sessions

Open 💬 3 comments Opened Jun 30, 2026 by spira-unplugged

Preflight Checklist

  • [x] I have searched existing requests and this feature hasn't been requested yet
  • [x] This is a single feature request (not multiple features)

Problem Statement

Claude Code’s current compaction workflow is very helpful, but in long-running coding sessions it can still lose important working state after compaction.

In practice, I rarely inspect the compacted summary in detail. What I care about most is not whether the summary is human-readable, but whether Claude Code can continue the task reliably after compaction without losing:

  • the current implementation plan
  • files already changed and why
  • failed approaches and why they were abandoned
  • test commands and their results
  • subtle constraints discovered during debugging
  • decisions that should not be revisited
  • the next concrete steps

For long coding tasks, a human-readable summary can be too lossy. It is useful for review, but it may not be the most efficient representation for the model itself.

The current behavior makes long sessions feel fragile: after compaction, Claude Code can sometimes become less aware of the exact state of the work, requiring the user to restate context or manually maintain state in files.

Proposed Solution

I would like Claude Code to support a deeper, model-oriented compaction mode in addition to the current human-readable summary-based compaction.

Ideally, Claude Code would maintain two layers of compacted context:

  1. Human-readable summary
  • high-level task status
  • changed files
  • current plan
  • unresolved issues
  • next steps
  1. Model-oriented opaque/deep compaction state
  • a high-density internal representation optimized for continuation
  • not necessarily human-readable
  • focused on preserving detailed working state across long sessions

This could be exposed as an option such as:

  • /compact --deep
  • /compact --preserve-state
  • a setting like compaction.mode = "deep"
  • automatic deep compaction when the context window approaches the limit

The goal is not to remove the current readable /compact behavior. The readable summary is still valuable. The request is to add a deeper continuation-oriented compaction layer for users who prioritize long-session reliability over inspectability.

It would also be useful if /context showed that such a deep compaction state exists, when it was created, and roughly how much context it preserves, without necessarily exposing its full contents.

Alternative Solutions

Current workarounds include:

  • Manually asking Claude Code to summarize the session before compaction
  • Using /compact with detailed focus instructions
  • Writing important state into CLAUDE.md, TODO files, scratchpads, or implementation notes
  • Keeping external notes about changed files, test results, and decisions
  • Starting a new session and pasting a hand-written state summary

These workarounds help, but they add manual overhead and are easy to forget during intense debugging or refactoring sessions.

The existing human-readable compaction is useful, but it still feels optimized for readability rather than maximum task-continuation fidelity.

Priority

High - Significant impact on productivity

Feature Category

Performance and speed

Use Case Example

_No response_

Additional Context

Other coding agents and APIs are exploring continuation-oriented compaction approaches where the compacted state is not necessarily exposed as a fully human-readable summary, but is optimized for preserving task state across long-running agentic work.

For example, OpenAI Codex / Responses API has a concept of opaque or encrypted compaction items for carrying forward compressed context. I am not asking Claude Code to copy that implementation directly, but I think Claude Code could benefit from a similar product-level capability: a deeper, model-oriented compaction mode that prioritizes long-session continuity over human readability.

For Claude Code, the ideal design could be hybrid:

  • keep the current readable summary for transparency
  • add a deeper model-oriented compaction layer for continuity
  • allow users to choose between normal compaction and deep/state-preserving compaction
  • allow focus instructions, e.g. /compact --deep focus on tests, changed files, failed attempts, and unresolved decisions

The key point is that many users do not carefully inspect the compaction output every time. For long coding sessions, preserving execution continuity may be more valuable than making the compacted context fully readable.

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗