Skip to content

Feature Request: Configurable Context Window Compaction Threshold #15719

Description

@perrywinkle1

Summary

Add a user-configurable setting to control when auto-compaction triggers, instead of the hardcoded 95% threshold.

Motivation

The current 95% threshold works for many users, but some workflows benefit from more aggressive compaction:

  • Long coding sessions - Users working on complex, multi-file tasks may want earlier compaction to preserve more relevant context before hitting limits
  • Cost management - Earlier compaction can help users stay within budget by summarizing sooner
  • Context quality - Compacting at 50-70% leaves headroom for the model to retain more nuanced details rather than aggressive summarization under pressure

Proposed Solution

Add a new setting contextCompactionThreshold (or similar) that accepts a percentage value (e.g., 0.5 for 50%).

Configuration via /config:

Auto-compact threshold: 50%

Or via settings file (~/.claude/settings.json):

{
  "contextCompactionThreshold": 0.5
}

Suggested Defaults

  • Default: 0.95 (current behavior, no breaking change)
  • Valid range: 0.25 to 0.95

Alternatives Considered

  1. Manual /compact only - Works but requires user vigilance and interrupts flow
  2. Multiple preset options (e.g., "aggressive", "moderate", "conservative") - Less flexible but simpler UX

Additional Context

This pairs well with the existing custom compaction instructions in CLAUDE.md, giving users full control over both when and how compaction occurs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    duplicateThis issue or pull request already exists

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions