[FEATURE] Allow agents to auto-trigger /compact before context overflow

Resolved 💬 2 comments Opened Mar 18, 2026 by buychoi Closed Apr 16, 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

When working on image-heavy tasks (e.g., building PowerPoint presentations with many screenshots), the context window fills up and Claude becomes completely unresponsive — unable to process any input, including /compact or /clear.

This means all conversation context and work progress is lost. The user must force /clear and start over from scratch. The agent already knows when context is getting full, but has no way to act on it.

Proposed Solution

Allow the agent to programmatically trigger /compact when context usage is high. This could be:

  1. A tool like compact() that agents can call directly
  2. An automatic system-level trigger when context exceeds ~80% capacity
  3. A user setting: auto_compact: true that handles this transparently

The ideal experience: the agent detects high context usage, silently saves important context to memory, then auto-compacts — all without user intervention.

Alternative Solutions

Currently the agent reminds the user to manually type /compact, but this fails when:

  • The user forgets or is busy focusing on the task
  • The context is already full and Claude is unresponsive before the user can act

The agent also saves progress to memory files as a backup, but this is a lossy workaround — full conversation context is still lost.

Priority

High - Significant impact on productivity

Feature Category

CLI commands and flags

Use Case Example

  1. I ask Claude to help build a 30-slide PowerPoint presentation
  2. I send screenshots of existing slides for reference (5-10 images)
  3. After ~20 minutes of work, Claude becomes completely unresponsive
  4. I cannot type /compact or any command — the session is frozen
  5. I'm forced to /clear, losing all context and 20-30 minutes of work
  6. With auto-compact, Claude would detect high context usage at step 2-3, silently compress, and continue working without interruption

Additional Context

_No response_

View original on GitHub ↗

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