#15927: feat: add compaction.model override config option
channel: discord
channel: imessage
channel: signal
gateway
agents
stale
size: M
Cluster:
Compaction Enhancements and Features
## Problem
Compaction currently uses the session's primary model. For users running an expensive primary model (e.g., Claude Opus) for conversation quality, compaction is a mechanical summarization task that doesn't need the same level of intelligence (#15826).
## Solution
Allow configuring a separate model for conversation compaction via `agents.defaults.compaction.model` (and per-agent overrides).
## Changes
- **Config**: Add `model?: string` to `AgentCompactionConfig` type
- **Command**: Apply override in manual `/compact` command handler
- **Auto-compaction**: Apply override in context overflow auto-compaction
## Usage
```json
{
"agents": {
"defaults": {
"compaction": {
"model": "anthropic/claude-sonnet-4"
}
}
}
}
```
Supports full model refs (`provider/model`) or just model IDs.
Same pattern as `heartbeat.model` and `subagents.model`.
Fixes #15826
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
Adds `agents.defaults.compaction.model` config option to allow using a cheaper model for compaction while keeping an expensive primary model for conversation quality. The implementation correctly:
- Added the `model?: string` field to `AgentCompactionConfig` type
- Implemented resolution logic that checks per-agent config before falling back to defaults
- Applied the override in both manual `/compact` command and auto-compaction on context overflow
- Followed the same pattern as existing `heartbeat.model` and `subagents.model` configs
The changes are functionally correct and support both full model refs (`provider/model`) and bare model IDs. Two helper functions (`splitModelRef` and `resolveCompactionModelOverride`) are duplicated across files and could be consolidated into a shared utility module to reduce maintenance burden.
<h3>Confidence Score: 4/5</h3>
- This PR is safe to merge with minimal risk
- The implementation is straightforward, follows established patterns in the codebase (heartbeat.model and subagents.model), and correctly applies the override in both manual and auto-compaction scenarios. The only minor concern is code duplication of helper functions across two files, which is a style issue rather than a functional problem.
- No files require special attention
<sub>Last reviewed commit: 7fdad2e</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#11089: feat(compaction): support customInstructions and model override for...
by p697 · 2026-02-07
86.9%
#11970: feat: add model.compact config for dedicated compaction model
by meaadore1221-afk · 2026-02-08
86.1%
#20493: feat(agents): add compaction model override for compaction runs
by PastaPastaPasta · 2026-02-19
83.4%
#10505: feat(compaction): add timeout, model override, and diagnostic logging
by thebtf · 2026-02-06
83.4%
#12046: fix(compaction): add fallback for undefined ctx.model (#12016)
by anandsuraj · 2026-02-08
81.1%
#19329: feat: add per-agent compaction and context pruning overrides
by curtismercier · 2026-02-17
81.1%
#6108: Fix compaction producing empty summary when ctx.model is undefined ...
by GangEunzzang · 2026-02-01
79.8%
#17864: fix(compaction): pass model through runtime + reduce chunk ratio to...
by battman21 · 2026-02-16
78.5%
#8313: feat: auto-compaction support for spawned subagent sessions
by vishaltandale00 · 2026-02-03
78.0%
#21547: feat: add compaction.announce config to notify users of compaction ...
by jlwestsr · 2026-02-20
77.5%