anomalyco / anomalyco/opencode
core: compaction ignores agents.compaction.model since "shared model request" refactor (v2 beta)
@kitlangton is already working on this.
Since Aug 22, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
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/cli0.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, orPOST /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(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.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
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 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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.