[Feature Request] Auto-compact during background task idle with user-defined token threshold

Open 💬 0 comments Opened Jul 12, 2026 by vitali87

Bug Description
Feature request: auto-compact when idle on a background task, gated on a user-defined token threshold

I'd like auto-compaction to trigger when two conditions hold together:

  1. Context usage (input + output tokens) is past a threshold I define, not Claude Code's internal near-limit point. For me that's 150k tokens, which is where my custom statusline

goes red.

  1. The agent is idle because it's blocked waiting on a run_in_background Bash task.

Compacting during that idle wait is effectively free on latency, since the model is only waiting. Right now this is unreachable: hooks have no "idle on background task" event,
can't read token usage, and can't invoke /compact, and native auto-compact fires on a fixed internal threshold I can't move.

Ideal shape: a configurable token/percent threshold for auto-compact, plus an option to prefer compacting during background-task idle time.

Environment Info

  • Platform: darwin
  • Terminal: ghostty
  • Version: 2.1.207
  • Feedback ID: 909762dc-8791-47f2-b1e1-6a10aa3a13b4

Errors

[]

View original on GitHub ↗