Skip to content

fix(compaction): respect agent variant config during compaction - #41594

Open
ousamabenyounes wants to merge 1 commit into
anomalyco:devfrom
ousamabenyounes:compaction-agent-variant
Open

fix(compaction): respect agent variant config during compaction#41594
ousamabenyounes wants to merge 1 commit into
anomalyco:devfrom
ousamabenyounes:compaction-agent-variant

Conversation

@ousamabenyounes

Copy link
Copy Markdown

Issue for this PR

Closes #41578

Type of change

  • Bug fix

What does this PR do?

Setting agent.compaction.variant in config had no effect. When building the
compaction summary assistant message, variant was hardcoded to inherit from
the parent user message (userMessage.model.variant), ignoring the compaction
agent's configured variant — even though agent.compaction.model is already
honored a few lines above.

The fix resolves the variant from the compaction agent config when it is set and
valid for the resolved model, and otherwise falls back to the previous behavior:

variant: agent.variant && model.variants?.[agent.variant] ? agent.variant : userMessage.model.variant,

This mirrors how a normal turn resolves its variant in session/prompt.ts
(ag.variant && full?.variants?.[ag.variant] ? ag.variant : ...), and makes
variant consistent with the model override right above it. The fallback path
is unchanged, so sessions that do not configure a compaction variant behave
exactly as before.

How did you verify your code works?

Added a unit test in test/session/compaction.test.ts that configures
agent.compaction.variant and asserts the compaction summary message uses it.

RED (before the fix):

expect(summary.info.variant).toBe("no-thinking")
Expected: "no-thinking"
Received: undefined

GREEN (after the fix): the whole test/session/ suite passes — 406 pass, 0 fail
(baseline before this change: 405 pass). bun run typecheck for
packages/opencode passes.

Checklist

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

The compaction summary message hardcoded its variant to the parent user
message's variant, ignoring agent.compaction.variant even though
agent.compaction.model is already honored. Resolve the variant from the
compaction agent config when it is valid for the model, mirroring the
existing resolution in session/prompt.ts, and fall back to the previous
behavior otherwise.

Closes anomalyco#41578
avion23 pushed a commit to avion23/opencode that referenced this pull request Aug 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] agent.compaction.variant config is ignored during compaction

1 participant