Skip to content

Add configurable auto-compaction threshold to config.json #1688

@jvivescortes

Description

@jvivescortes

Describe the feature or problem you'd like to solve

When using slower, higher-capacity models like Claude Opus 4.6, context window bloat significantly degrades performance well before the CLI's built-in compaction triggers. At ~45-60% context usage: - Response latency increases dramatically (40-90s+ per turn) - Tool call quality degrades — the model makes redundant/malformed calls and repeats work - Rate limit errors become frequent due to higher per-request compute cost - Compaction itself becomes slow because it has to summarize a larger message history In practice, the optimal time to compact with Opus is around 30-35% usage, but the CLI doesn't offer any way to configure this.

Proposed solution

Add an auto_compact_threshold field to ~/.copilot/config.json:

{
"auto_compact_threshold": 0.30
}

Why this matters

  • The current implicit threshold is tuned for faster models (Sonnet/Haiku) where high context usage is tolerable.
    It doesn't account for the disproportionate latency penalty on slower models.
  • Users who compact proactively at 30-35% see significantly better results: faster responses, fewer errors, better
    tool call efficiency, and fewer rate limit hits.
  • Power users currently have no mechanism to automate this — it requires manually running /context and /compact
    every few turns.

Additional Considerations

  • Could support per-model thresholds: "auto_compact_threshold": { "default":
    0.50, "claude-opus-4.6-fast": 0.30 }
  • Could support a "auto_compact_mode": "auto" | "prompt" to let users choose between silent compaction vs. a
    confirmation prompt
  • Reasonable default could remain at current behavior (~70-80%) so existing users aren't affected

Example prompts or workflows

Example Workflows

  1. Long refactoring session with Opus A developer is refactoring an auth module across 15 files using Opus 4.6 for
    its superior reasoning. After 8-10 turns, context hits 40% and responses slow to 60s+. They don't notice until
    they're at 55% and the model starts re-reading files it already processed. With "auto_compact_threshold": 0.30,
    compaction fires early while it's still fast (~20s), and the session stays responsive throughout.

  2. Per-model tuning for mixed-model workflow A user switches between Sonnet (fast, tolerates high context) and Opus
    (slow, needs lean context). With per-model thresholds, they configure { "default": 0.50, "claude-opus-4.6-fast":
    0.30 } and get optimal behavior regardless of which model they're using — no manual intervention needed.

  3. Autopilot mode without babysitting In experimental autopilot mode, the agent chains actions without user
    confirmation. Without auto-compaction, the context silently bloats until the agent degrades — making duplicate tool
    calls, generating malformed JSON, and burning through rate limits. A 30% threshold keeps autopilot running cleanly
    without the user needing to interrupt with /compact.

  4. Rate limit avoidance during crunch time A developer on a deadline keeps hitting "rate limit, try again in 1
    minute" errors. They don't realize that their 120k-token context is causing each request to consume disproportionate
    compute. Auto-compaction at 30% would keep requests lightweight, reducing rate limit pressure and eliminating forced
    cooldown periods.

  5. Team standardization via repo-level config A team adds "auto_compact_threshold": 0.35 to their shared config so
    that all developers using Copilot CLI on their repo get consistent, performant behavior — especially onboarding
    developers who don't yet know to manually compact.

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:configurationConfig files, instruction files, settings, and environment variablesarea:context-memoryContext window, memory, compaction, checkpoints, and instruction loading
    No fields configured for Feature.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions