Skip to content

fix(opencode): compaction uses selected session model, not hardcoded sonnet#25

Merged
terrxo merged 1 commit into
devfrom
fix/compaction-use-session-model
Jun 5, 2026
Merged

fix(opencode): compaction uses selected session model, not hardcoded sonnet#25
terrxo merged 1 commit into
devfrom
fix/compaction-use-session-model

Conversation

@terrxo

@terrxo terrxo commented Jun 5, 2026

Copy link
Copy Markdown

What

Closes hivemind anomalyco#377.

selectCompactionModel() in packages/opencode/src/session/compaction.ts had a tier-4 default that forced every non-Anthropic session model to compact via claude-sonnet-4-6. For a large-context driver (the motivating case: a deepseek 1M-context model) this is wasteful and counterproductive — you pay for a sonnet round-trip to summarize history the driver could compact itself.

Change

Tier 4 now returns the session model. One-file change.

The opt-in tiers are untouched, so configurability is fully preserved:

  1. agent.model (explicit compaction-agent override)
  2. compaction.model (provider/model, e.g. anthropic/claude-sonnet-4-6)
  3. compaction.model_overrides (glob-pattern, keyed on the session model)
  4. default → session model (was: hardcoded sonnet for non-anthropic)

Anyone who wants sonnet-for-compaction (or Haiku, etc.) still gets it via tiers 1-3 — including a model_overrides glob to scope it to specific drivers.

Acceptance (anomalyco#377)

  • Compaction uses the model selected in opencode.json / active provider config by default
  • No hardcoded model reference in the default compaction path
  • Works across all providers, not just Anthropic

Verification

  • bun typecheck — clean
  • bun test test/session/compaction.test.ts test/session/compaction-strip.test.ts — 59 pass / 0 fail

Notes

  • Sibling ticket web search tool anomalyco/opencode#309 (compaction quality bundle) was cancelled as stale — its substantive parts (the compaction.model config knob + structured summary prompt) already landed on dev.

…dcoded sonnet

selectCompactionModel forced every non-anthropic session model through
claude-sonnet-4-6 for summarization. That is wasteful and counterproductive
for large-context drivers (e.g. a 1M-token model gets routed through sonnet).

Tier 4 now returns the session model. The opt-in tiers (agent.model,
compaction.model, compaction.model_overrides) are unchanged, so anyone who
wants a dedicated compaction model — including sonnet — still gets it.

Closes anomalyco#377
@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@terrxo terrxo merged commit adf7f3f into dev Jun 5, 2026
3 of 10 checks passed
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.

1 participant