Feature request: Hook event when context nears compaction threshold

Resolved 💬 3 comments Opened Jan 29, 2026 by kmichels Closed Feb 1, 2026

Summary

Add a hook event that fires when remaining context before compaction drops below a threshold (e.g., <5% remaining).

Use Case

I use project planning files (progress.md, task_plan.md) to track work across sessions. When context compacts, the conversation summary may lose details about work completed.

A pre-compaction hook would allow:

  1. Auto-save progress — update planning docs with session work before details are lost
  2. Warn the user — alert that compaction is imminent so they can review
  3. Checkpoint state — save any in-progress work to files

Proposed Solution

Add a PreCompaction or LowContext hook event with:

  • Trigger: fires when remaining context drops below configurable threshold (default 5%)
  • Timing: fires once per threshold crossing, not repeatedly
  • Output: hook can add final context or perform cleanup before compaction

Example Hook Output

{
  "hookSpecificOutput": {
    "hookEventName": "PreCompaction",
    "remainingContext": "3%",
    "additionalContext": "Update progress.md before context compacts."
  }
}

Workaround

Currently none — compaction happens automatically with no warning or hook opportunity. Users must manually track context usage and remember to save progress.

View original on GitHub ↗

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