[FEATURE] Context-Aware Agent with Low-Context Actions and Iterative Session-continuation Document Creation

Resolved 💬 6 comments Opened Dec 10, 2025 by ptaczek Closed Feb 28, 2026

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

Currently, Claude Code agents have no awareness of how much session context remains available. This means:

  • Users cannot anticipate when context limits will be reached
  • Auto-compact triggers unexpectedly and doesn't always produce optimal results
  • There's no opportunity to take proactive action before context is exhausted
  • Session continuity is disrupted, requiring manual recovery efforts

Users who disable auto-compact to maximize context space have no mechanism to gracefully handle approaching context limits, leading to abrupt session endings or sub-optimal automatic compaction.

Proposed Solution

Implement continuous context awareness that exposes the remaining/used context to the agent, enabling configurable actions when thresholds are reached. Options could include:

  • Automatic session continuation document creation — Generate an enhanced, detailed session history document optimized for recovery in new sessions
  • User-defined prompt execution — Allow users to specify a custom prompt/instruction that runs when context is low
  • Agent-specific behaviors — Reduce token usage on non-vital actions (builds, commits, verbose logging), or suggest "bail-out" strategies

The behavior should be configurable, allowing users to choose between:

  • Fully automatic actions
  • Interactive confirmation before taking action
  • Notification-only mode

Alternative Solutions

  • Improve auto-compact to produce higher-quality, more recoverable summaries (though this doesn't address the configurability need)
  • Provide a simple always-on context usage indicator, leaving manual intervention to the user. Warning shown at 10% only as it is now often leads to abrupt actions and ad-hoc bail-out with fingers crossed that the remaining context will be enough

Priority

Medium - Would be very helpful

Feature Category

Other

Use Case Example

My current workflow:

  1. Run with auto-compact OFF to maximize available context
  2. Manually create tailored session continuation documents before context runs out
  3. Use these documents to fully recover state in new sessions

With this feature, I could configure the agent to automatically ask for generation of continuation document in my preferred format at let's say 80-90% context usage, ensuring I never lose session state unexpectedly and can seamlessly continue work.

Additional Context

  • Auto-compact doesn't always preserve the specific details needed for effective session recovery
  • Power users often have domain-specific recovery needs that a generic solution can't address
  • This feature would benefit long-running agentic sessions where context management is critical
  • Consider exposing context metrics (used/available/percentage) in the agent's working state for transparency

Additional insight from my workflow:

Creating effective session continuation documents is inherently iterative. My typical process:

  • Ask Claude to write down everything it thinks is needed to fully recover and continue in a new session
  • Review and edit — adding context I know matters, removing noise
  • Ask Claude to validate the document against the current live session context for contradictions, ambiguities, or gaps

That third step is critical: it's using Claude's full working memory to QA the compressed version before the context is gone. Once a new session starts, that verification opportunity is lost.
Any automated solution should account for this — not just "generate summary" but "generate → validate → refine." A single-pass approach would essentially be auto-compact with a different trigger point.

View original on GitHub ↗

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