[FEATURE] Add `compactionModel` config to use a cheaper model during auto-compaction

Resolved 💬 2 comments Opened Mar 24, 2026 by athanbase Closed Mar 25, 2026

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

Claude Code already supports PreCompact and PostCompact hook events, which is great for custom logic around compaction. However, hooks only support type: command — they cannot switch the model used internally during compaction.

Currently, the same model selected for the session (e.g., Sonnet, Opus) is also used for context compaction. Compaction is essentially a summarization task, and it doesn't require a top-tier model to produce good results.

Proposed Solution

Add a compactionModel config option in settings.json:

```json
{
"model": "claude-sonnet-4-6",
"compactionModel": "claude-haiku-4-5-20251001"
}


  **Expected behavior:**

  1. Session runs with claude-sonnet-4-6
  2. Context nears the limit → compaction triggers using claude-haiku-4-5-20251001
  3. Compaction completes → session resumes with claude-sonnet-4-6
  
**Motivation**

  - Compaction is a summarization task — a lighter model (e.g., Haiku) handles it just as well
  - Users running long sessions (large codebases, heavy refactoring) hit compaction frequently
  - This would reduce cost with no meaningful quality impact
  - PreCompact/PostCompact hooks exist but cannot address this — they only support shell commands, not internal model switching

### Alternative Solutions

Using PreCompact hook to switch models — not possible today, as hooks cannot modify Claude Code's internal model state. This config option is the most straightforward path to solving this.

### Priority

Medium - Would be very helpful

### Feature Category

CLI commands and flags

### Use Case Example

_No response_

### Additional Context

_No response_

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗