fix(compaction): respect agent variant config during compaction - #41594
Open
ousamabenyounes wants to merge 1 commit into
Open
fix(compaction): respect agent variant config during compaction#41594ousamabenyounes wants to merge 1 commit into
ousamabenyounes wants to merge 1 commit into
Conversation
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
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 #41578
Type of change
What does this PR do?
Setting
agent.compaction.variantin config had no effect. When building thecompaction summary assistant message,
variantwas hardcoded to inherit fromthe parent user message (
userMessage.model.variant), ignoring the compactionagent's configured variant — even though
agent.compaction.modelis alreadyhonored 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:
This mirrors how a normal turn resolves its variant in
session/prompt.ts(
ag.variant && full?.variants?.[ag.variant] ? ag.variant : ...), and makesvariantconsistent with themodeloverride right above it. The fallback pathis 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.tsthat configuresagent.compaction.variantand asserts the compaction summary message uses it.RED (before the fix):
GREEN (after the fix): the whole
test/session/suite passes — 406 pass, 0 fail(baseline before this change: 405 pass).
bun run typecheckforpackages/opencodepasses.Checklist