anomalyco / anomalyco/opencode
[Bug] agent.compaction.variant config is ignored during compaction
@nexxeln is already working on this.
Since Aug 10, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Description
Summary
Setting variant on the compaction agent in config (e.g. agent.compaction.variant: "no-thinking") has no effect. The compaction request always uses the variant from the original message that triggered compaction, not the variant configured for the compaction agent — even though agent.compaction.model overrides are respected.
Config example that triggers this:
{
"agent": {
"compaction": {
"model": "dev/deepseek-v4-flash",
"variant": "no-thinking"
}
}
}
Root cause
In processCompaction (packages/opencode/src/session/compaction.ts), the compaction agent config is correctly used to override the model:
const agent = yield* agents.get("compaction")
const model = agent.model
? yield* provider.getModel(agent.model.providerID, agent.model.modelID).pipe(Effect.orDie)
: yield* provider.getModel(userMessage.model.providerID, userMessage.model.modelID).pipe(Effect.orDie)
But when building the assistant message, variant is hardcoded to inherit from the parent user message, ignoring agent.variant entirely:
const msg: SessionV1.Assistant = {
...
variant: userMessage.model.variant,
The agent object fetched above (which does contain variant: "no-thinking") is never consulted for this field. This is inconsistent with the model handling right above it, and also inconsistent with how normal agent turns resolve variant in createUserMessage:
const variant = input.variant ?? (ag.variant && full?.variants?.[ag.variant] ? ag.variant : undefined)
Expected behavior
When agent.compaction.variant is set, compaction requests should use that variant (validated against the resolved compaction model's available variants), falling back to the inherited userMessage.model.variant only when the compaction agent has no variant configured.
Suggested fix
variant: agent.variant ?? userMessage.model.variant,
possibly with the same variant-validity check createUserMessage performs (confirming the resolved model actually has that variant) before applying it.
Impact
Users who configure a different model + variant combo for the compaction agent get the model switch applied but silently lose the variant override, which can be surprising/incorrect for reasoning-mode-sensitive variants (e.g. no-thinking vs thinking).
Citations
File: packages/opencode/src/session/compaction.ts (L328-331)
const agent = yield* agents.get("compaction")
const model = agent.model
? yield* provider.getModel(agent.model.providerID, agent.model.modelID).pipe(Effect.orDie)
: yield* provider.getModel(userMessage.model.providerID, userMessage.model.modelID).pipe(Effect.orDie)
File: packages/opencode/src/session/compaction.ts (L356-363)
const msg: SessionV1.Assistant = {
id: MessageID.ascending(),
role: "assistant",
parentID: input.parentID,
sessionID: input.sessionID,
mode: "compaction",
agent: "compaction",
variant: userMessage.model.variant,
File: packages/opencode/src/session/prompt.ts (L646-654)
const model = input.model ?? ag.model ?? (yield* currentModel(input.sessionID))
const same = ag.model && model.providerID === ag.model.providerID && model.modelID === ag.model.modelID
const full =
!input.variant && ag.variant && same
? yield* provider
.getModel(model.providerID, model.modelID)
.pipe(Effect.catchIf(Provider.ModelNotFoundError.isInstance, () => Effect.succeed(undefined)))
: undefined
const variant = input.variant ?? (ag.variant && full?.variants?.[ag.variant] ? ag.variant : undefined)
Plugins
none
OpenCode version
1.18.16
Steps to reproduce
- Install opencode and configure with an openAI compatible Provider
- configure a model on that provider to have a variant, that you can distinguish from the default. In my yase it is a non-thinking variant that i need to use on comapction, since the model trips up on it's own thoughts during compaction.
- Have a session with the model that you can compact
- See that even though the variant is configured in the compaction agent it is not used and thinking tokens are emmited.,
Operating System
RedHat Linux 8
Terminal
Not tested. Used opencode serve web UI
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.