Skip to content

fix(core): use the compaction agent's model for summaries - #52875

Closed
sergiopadure wants to merge 1 commit into
anomalyco:v2from
sergiopadure:compaction-agent-model
Closed

sergiopadure wants to merge 1 commit into
anomalyco:v2from
sergiopadure:compaction-agent-model

Conversation

@sergiopadure

Copy link
Copy Markdown
Contributor

Issue for this PR

Fixes #44094

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

agents.compaction.model is merged into the compaction agent and shows up in debug agents, but nothing reads it: every compaction runs on the session model. Titles already honour their agent's model through selectTitle; compaction had no equivalent.

This adds SessionContext.selectCompaction, which resolves the compaction agent's model the same way selectTitle does, and passes it as summaryModel on the manual, auto and overflow triggers. In compact, only the summary request moves to that model: the transcript lowering, request, usage/cost and the recorded compaction message use it, and the request budget is capped by its window too. The decision when to compact stays on the session model, and provider-native compaction is unchanged (its window belongs to the session's provider). With no compaction model configured, or one that cannot be resolved, behaviour is the same as before.

@kitlangton I saw the issue is assigned to you; happy to adjust or close this if you already have a fix in progress.

How did you verify your code works?

  • New tests in session-compaction.test.ts (request, output limit, cost and recorded model use the compaction model; native compaction ignores it) and a runner scenario in session-runner.test.ts (manual /compact summarizes with the compaction model, the next prompt goes back to the session model). Auto and overflow pass the same value through the same call; only manual is covered end to end.
  • bun typecheck in packages/core, and session-compaction, session-compact, session-native-compaction, session-title, session-compaction-transport and session-runner tests all pass.

Screenshots / recordings

Not a UI change.

Checklist

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

Copilot AI balanced review requested due to automatic review settings October 3, 2026 00:07

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

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.

@sergiopadure

Copy link
Copy Markdown
Contributor Author

Closing in favour of #53276, which merged a simpler version of this change for #44094. Thanks for picking it up, @rekram1-node.

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.

2 participants