[FEATURE]
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
Feature Request: Configurable Auto-Compact Threshold
Currently, Claude Code automatically triggers /compact only when the context
window reaches ~95% capacity. This threshold is not configurable by the user.
For larger models like Claude Opus 4.7 (which has a significantly larger context
window), this means the auto-compact fires very late — after a large amount of
tokens have already been consumed. By that point, the session has already used
a disproportionate amount of the token budget, making long work sessions
expensive and slow.
Why This Matters
- Larger models (Opus) have bigger context windows → later auto-compact →
higher token cost per session
- Earlier compaction keeps sessions lean, responsive, and cost-efficient
- Users lose the ability to course-correct before most of the token budget
is already spent
- A simple threshold config gives users full control over the cost/context
tradeoff without requiring manual /compact calls
Environment
- OS: Windows 10
- Claude Code version: latest
- Model: claude-opus-4-7 (most impactful, but applies to all models)
자동 /compact가 컨텍스트 창의 약 95%에서만 발동되며,
사용자가 이 임계치를 조정할 수 없습니다.
Opus 4.7처럼 컨텍스트 창이 큰 모델은 임계치 도달이 매우 늦어서
토큰을 대량 소비한 후에야 compact가 실행됩니다.
그랬을 경우 쓸데없이 많은 컨텍스트가 지속적으로 반복하여 사람들의 무지를 이용해서
너희만 돈을 처 벌겠죠?
settings.json에 "autoCompactThreshold": 0.5 같은 옵션을 추가해
사용자가 원하는 시점에 자동 compact가 발동되도록 설정할 수 있게 해주세요.
Proposed Solution
Add a configurable autoCompactThreshold field to settings.json and settings.local.json:
{
"autoCompactThreshold": 0.5
}
- Value range:
0.1to0.95(float, percentage of context window) - Default:
0.95(current behavior, no breaking change) - When set to
0.5, auto-compact triggers at 50% context usage instead of 95%
Optionally, allow per-model overrides:
{
"autoCompactThreshold": 0.95,
"modelOverrides": {
"claude-opus-4-7": {
"autoCompactThreshold": 0.5
}
}
}
This way users can set a tighter threshold specifically for larger/more expensive
models while keeping the default behavior for lighter models like Haiku.
Alternative Solutions
_No response_
Priority
Medium - Would be very helpful
Feature Category
CLI commands and flags
Use Case Example
_No response_
Additional Context
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗