[Feature Request] Auto-compact during background task idle with user-defined token threshold
Status Open
Reported on v2.1.207
Maintainer reply None cached
Activity 2 comments · opened Jul 12, 2026
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:
- 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.
- 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
[]This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗