Skip to content

feat: Switch compaction model from session model#15525

Open
ryanwyler wants to merge 1 commit intoanomalyco:devfrom
gignit:feature/compaction-model
Open

feat: Switch compaction model from session model#15525
ryanwyler wants to merge 1 commit intoanomalyco:devfrom
gignit:feature/compaction-model

Conversation

@ryanwyler
Copy link
Contributor

Issue for this PR

Closes #13946
Closes #12135
Related: #14368, #14259, #14233

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Adds a dedicated compaction model selector so users can run one model for chat and a different model for summarization. Run Claude Sonnet or Opus 4.6 for interactive coding while compacting with Zen Big Pickle (free) to eliminate compaction cost entirely, or GPT-5.3 Codex (400k context) for detail-oriented summaries that capture nuance your session model would lose — with headroom to compact sessions that have already exceeded their primary model's context limit.

For best results use this enhanced compaction prompt: #14662

Why not just use agent.compaction.model in config?

The existing agent.compaction.model config option is static — it requires editing opencode.json and is fixed for the lifetime of the config. This PR adds runtime switching without touching config files, matching how the primary model switcher works:

  • Switch compaction models on the fly without restarting or editing config
  • Different sessions can use different compaction models in the same instance
  • Browse available models with the same familiar picker UI
  • See the active compaction model in the prompt footer at a glance

Both approaches coexist. Model resolution priority: TUI selection > config file (agent.compaction.model) > session model. When no TUI selection is made, the config-based approach works exactly as before. Nothing is broken.

Features:

  • Reuses existing provider infrastructure — same providers, API keys, and auth as the primary model picker
  • /compaction-models slash command and "Switch compaction model" in the command menu
  • Model resolution priority: compaction model override > agent config > session model
  • Compaction model preference stored via kv.signal in kv.json, matching how all other TUI settings are persisted
  • Prompt footer displays active compaction model when set
  • When unset, behavior is identical to upstream

Changes:

  • DialogModel accepts target="compaction" prop — no duplicate component
  • SessionCompaction.process() accepts and resolves the override model
  • CompactionPart schema extended with optional compactionModel field
  • compaction_model_list keybind added (default: none)
  • SDK regenerated via ./script/generate.ts

How did you verify your code works?

Tested with Claude Sonnet 4.5 (chat) + GPT-5.3 Codex (compaction). Confirmed correct model at each pipeline stage via log entries. Compaction completed successfully, session resumed on the original model. Also tested auto-compaction with no override set to verify identical upstream behavior. Verified that existing agent.compaction.model config continues to work when no TUI override is set.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

image
image
image

Adds a dedicated compaction model selector so users can run one model
for chat and a different model for summarization (e.g. Claude Sonnet for
interactive coding, Zen Big Pickle free tier for zero-cost compaction).

Model resolution priority: TUI selection > agent.compaction.model config
> session model. When no TUI selection is set, behavior is identical to
upstream.

Changes:
- DialogModel gains target="compaction" prop — no duplicate component
- SessionCompaction.process() accepts optional compactionModel override
- CompactionPart schema extended with optional compactionModel field
- compaction_model_list keybind added (default: none)
- /compaction-models slash command and command menu entry
- local.model.compaction context backed by kv.signal('compaction_model')
- Prompt footer shows active compaction model when set
- SDK regenerated via ./script/generate.ts
@ryanwyler ryanwyler force-pushed the feature/compaction-model branch from 00b3b7d to 80b6e35 Compare March 1, 2026 03:14
@github-actions github-actions bot mentioned this pull request Mar 1, 2026
6 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

1 participant