feat: Switch compaction model from session model#14665
Open
ryanwyler wants to merge 1 commit intoanomalyco:devfrom
Open
feat: Switch compaction model from session model#14665ryanwyler wants to merge 1 commit intoanomalyco:devfrom
ryanwyler wants to merge 1 commit intoanomalyco:devfrom
Conversation
Allow users to select a different LLM model for compaction at runtime
via TUI, independent of the session model. Enables using cheaper or
specialized models for context summarization without changing the
primary chat model.
Model resolution priority:
TUI compaction model override > agent config > session model
TUI:
app.tsx - register command + slash /compaction-models
dialog-model.tsx - target prop; compaction mode shows session
model default option
context/local.tsx - kv.signal('compaction_model') state
prompt/index.tsx - compact model indicator in prompt footer
Server:
routes/session.ts - summarize route accepts compactionModel
message-v2.ts - CompactionPart gains compactionModel field
compaction.ts - 3-tier model resolution in process()
prompt.ts - passes compactionModel through to process()
Config:
config.ts - compaction_model_list keybind
SDK:
types.gen.ts, sdk.gen.ts, openapi.json - regenerated
Contributor
|
The following comment was made by an LLM, it may be inaccurate: Based on my search, I found related PRs but no duplicate PRs. The PR #14665 is unique in its focus on adding runtime compaction model switching. The related PRs found are addressing different aspects of the compaction system:
These are complementary changes, not duplicates of PR #14665. |
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue for this PR
Closes #13946
Closes #12135
Related: #14368, #14259, #14233
Type of change
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.modelin config?The existing
agent.compaction.modelconfig option is static — it requires editingopencode.jsonand is fixed for the lifetime of the config. This PR adds runtime switching without touching config files, matching how the primary model switcher works: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:
/compaction-modelsslash command and "Switch compaction model" in the command menukv.signalinkv.json, matching how all other TUI settings are persistedChanges:
DialogModelacceptstarget="compaction"prop — no duplicate componentSessionCompaction.process()accepts and resolves the override modelCompactionPartschema extended with optionalcompactionModelfieldcompaction_model_listkeybind added (default: none)./script/generate.tsHow 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
[compaction-model]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 existingagent.compaction.modelconfig continues to work when no TUI override is set.Checklist