Skip to content

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

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

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
@ousamabenyounes
ousamabenyounes force-pushed the compaction-agent-variant branch from 0ae2a72 to 139a1c4 Compare August 16, 2026 16:51
@github-actions github-actions Bot mentioned this pull request Aug 19, 2026
Closed
6 tasks
@github-actions

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant