core: compaction ignores agents.compaction.model since "shared model request" refactor (v2 beta)
Summary
Since the Aug 19–21 refactor that routes title and compaction through a shared model-request flow, manual compaction in v2 beta always uses the session's current model and silently ignores agents.compaction.model. The config key is accepted (it shows up in opencode2 debug agents) but never consulted for model selection — a silent regression for v1 configs that set a dedicated compaction model.
Environment
- opencode version: 0.0.0-beta-17898
- OS: Windows 11 (Windows_NT 10.0.26200.9168, x64)
- Terminal: Git Bash / mintty (TERM=xterm-256color)
- Shell: bash (Git Bash, /usr/bin/bash)
- Install/channel: beta (npm
@opencode-ai/cli 0.0.0-beta-17898, auto-updated)
- Active plugins: none found in config
Reproduction
- Configure a dedicated compaction model, e.g. in
opencode.json:
{
"agents": {
"build": { "model": "opencode-go/deepseek-v4-flash#max" },
"compaction": { "model": "opencode-go/mimo-v2.5" }
}
}
- Restart the service (
opencode2 service restart) and verify the merged registry:
opencode2 debug agents → compaction agent does show "model": { "id": "mimo-v2.5", "providerID": "opencode-go" }.
- Trigger manual compaction (keybind
session.compact, or POST /api/session/{sessionID}/compact).
- Observe the actual model used: the request follows the session's model (e.g.
deepseek-v4-flash#max), not the configured compaction model (observable via cost/token accounting deltas matching the session model's pricing, and via the summary request behavior).
Expected Behavior
When agents.compaction.model is set, compaction should use that model (as v1 did, and as the dev branch code still does). At minimum, an accepted-but-ignored config key should produce a warning instead of silent no-op.
Actual Behavior
Compaction model resolution is hard-wired to the session model:
packages/core/src/session/compaction.ts (beta branch): models.resolve(input.session) → modelRequests.prepare({ scope: { session, agentID: Agent.ID.make("compaction"), model: plan.resolved }, ... })
packages/core/src/session/runner/model.ts: resolve(session) returns the session's session.model (falling back to a default only when none is set).
packages/core/src/session/model-request.ts: prepare uses input.scope.model directly (line ~284 const resolved = input.scope.model); scope.agentID is used only as a request label (agent: input.scope.agentID), never to look up the agent's own model.
So agents.compaction.model never participates in model selection in beta builds.
Additional Context
- Docs (opencode.ai/v2/docs/compaction) state compaction uses the session's current model with no separate model setting — that matches beta behavior, but the config key is still accepted without warning, which silently breaks migrated v1 configs (including the v1 built-in compaction agent model field).
- The dev branch still has the old behavior:
packages/opencode/src/session/compaction.ts (dev, last change Aug 12) resolves:
const agent = yield* agents.get("compaction")
const model = agent.model
? yield* provider.getModel(agent.model.providerID, agent.model.modelID)
: yield* provider.getModel(userMessage.model.providerID, userMessage.model.modelID)
- Likely related commits on the
beta branch:
ace822308f (2026-08-19) "refactor(core): move compaction config into state"
ebc2504ef3 (2026-08-20) "refactor(core): route title and compaction through shared model request"
e5da5bfab2 / 3a1fb5ae65 (2026-08-21) "simplify effect workflows" / "simplify projection state"
Feature request: in the shared model-request flow, honor agents.compaction.model (the agent model, like the dev branch) when set — e.g. resolve the compaction scope's model from the compaction agent first, falling back to the session model. Otherwise the beta channel can never use a cheaper/larger model for compaction while keeping the session model for chat.
core: compaction ignores
agents.compaction.modelsince "shared model request" refactor (v2 beta)Summary
Since the Aug 19–21 refactor that routes title and compaction through a shared model-request flow, manual compaction in v2 beta always uses the session's current model and silently ignores
agents.compaction.model. The config key is accepted (it shows up inopencode2 debug agents) but never consulted for model selection — a silent regression for v1 configs that set a dedicated compaction model.Environment
@opencode-ai/cli0.0.0-beta-17898, auto-updated)Reproduction
opencode.json:{ "agents": { "build": { "model": "opencode-go/deepseek-v4-flash#max" }, "compaction": { "model": "opencode-go/mimo-v2.5" } } }opencode2 service restart) and verify the merged registry:opencode2 debug agents→ compaction agent does show"model": { "id": "mimo-v2.5", "providerID": "opencode-go" }.session.compact, orPOST /api/session/{sessionID}/compact).deepseek-v4-flash#max), not the configured compaction model (observable via cost/token accounting deltas matching the session model's pricing, and via the summary request behavior).Expected Behavior
When
agents.compaction.modelis set, compaction should use that model (as v1 did, and as the dev branch code still does). At minimum, an accepted-but-ignored config key should produce a warning instead of silent no-op.Actual Behavior
Compaction model resolution is hard-wired to the session model:
packages/core/src/session/compaction.ts(betabranch):models.resolve(input.session)→modelRequests.prepare({ scope: { session, agentID: Agent.ID.make("compaction"), model: plan.resolved }, ... })packages/core/src/session/runner/model.ts:resolve(session)returns the session'ssession.model(falling back to a default only when none is set).packages/core/src/session/model-request.ts:prepareusesinput.scope.modeldirectly (line ~284const resolved = input.scope.model);scope.agentIDis used only as a request label (agent: input.scope.agentID), never to look up the agent's ownmodel.So
agents.compaction.modelnever participates in model selection in beta builds.Additional Context
packages/opencode/src/session/compaction.ts(dev, last change Aug 12) resolves:betabranch:ace822308f(2026-08-19) "refactor(core): move compaction config into state"ebc2504ef3(2026-08-20) "refactor(core): route title and compaction through shared model request"e5da5bfab2/3a1fb5ae65(2026-08-21) "simplify effect workflows" / "simplify projection state"Feature request: in the shared model-request flow, honor
agents.compaction.model(the agent model, like the dev branch) when set — e.g. resolve the compaction scope's model from thecompactionagent first, falling back to the session model. Otherwise the beta channel can never use a cheaper/larger model for compaction while keeping the session model for chat.