Feature request: a setting/env to choose the model used for context compaction (`compactModel` / `CLAUDE_CODE_COMPACT_MODEL`)

Status Open
Reported on v2.1.260
Maintainer reply None cached
Activity 1 comment · opened Sep 23, 2026

Version

Claude Code 2.1.260, Linux (also observed on 2.1.258). No compaction-model setting appears in the CHANGELOG through 2.1.280.

Problem

The context-compaction summary (auto-compact and /compact) is generated with the session model. For sessions running on Opus- or Fable-class models this is the most expensive possible call at the moment the context is largest, and there is no way to route it to a cheaper model:

  • The model configuration docs (/docs/en/model-config) list ANTHROPIC_DEFAULT_{OPUS,SONNET,HAIKU,FABLE}_MODEL, ANTHROPIC_MODEL, ANTHROPIC_DEFAULT_MODEL, CLAUDE_CODE_SUBAGENT_MODEL(_FORCE), CLAUDE_CODE_AUTO_COMPACT_WINDOW and CLAUDE_CODE_MAX_CONTEXT_TOKENS — none selects the compaction model.
  • ANTHROPIC_SMALL_FAST_MODEL is deprecated in favor of ANTHROPIC_DEFAULT_HAIKU_MODEL ("haiku alias or background functionality"). Even if compaction were routed there, organizations that disallow Haiku for policy reasons cannot use it.
  • A /model switch queued from the composer applies to the next turn, i.e. after an auto-compact has already run, so a PreCompact hook cannot redirect the call either (its output carries custom instructions, not a model).

Ask

  1. A compactModel setting in settings.json and a CLAUDE_CODE_COMPACT_MODEL env var, honored by both auto-compact and /compact, accepting the same aliases/IDs as --model.
  2. (Optional) allow a PreCompact hook's JSON output to set "model" for that one compaction.
  3. Document which model compaction uses today.

Why it matters

Long-running agent sessions on large models compact many times a day; letting the summary run on a mid-tier model (e.g. Sonnet) cuts a large, predictable cost without changing the working model.

Related

Earlier requests for the same setting were closed by the inactivity bot without being implemented and are now locked: #12660, #16065, #49816.

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗