Feature request: auto-handoff when context utilization exceeds threshold

Status Open
Maintainer reply None cached
Activity 0 comments · opened Jul 22, 2026

Problem

LLM accuracy degrades in long contexts (anchoring, instruction dilution, confabulation over re-checking). Currently I manually watch the context % in the status bar and run /end-chat → new session when it gets too high. This should be automatable.

Proposed Solution

One or more of the following:

  1. New hook event onContextThreshold — fires when context utilization crosses a configurable % (e.g. 50%). The hook could then trigger /end-chat or a handoff.
  1. Expose CLAUDE_CONTEXT_PERCENT as an env var in all hook invocations (especially Stop), so a hook script can detect the threshold and act on it.
  1. A hook action for session handoff — something like {"action": "end_session", "handoff_prompt": "continue from .claude/progress/"} that gracefully ends the current session and spawns a new one with a continuation prompt.

Use Case

I've been manually doing this workflow for a while:

  • Watch context % in status bar
  • When it passes ~50%, run /end-chat (which snapshots progress)
  • Start a new session with "continue from .claude/progress/"

This works but is manual and easy to forget. Automating it would keep sessions in the "fresh context" sweet spot without user intervention.

Why This Matters

  • Context compression helps but doesn't fully prevent mid-context degradation
  • Users who run long coding sessions (refactors, debugging, multi-file changes) are most affected
  • The progress/handoff infrastructure already exists (/end-chat, .claude/progress/) — this just needs a trigger mechanism

View original on GitHub ↗