feat(agent-core): add compaction model config#931
Conversation
🦋 Changeset detectedLatest commit: 85d187a The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 85d187afb4
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| : this.agent.config.thinkingLevel; | ||
| const provider = createProvider(resolved.provider).withThinking(thinkingLevel); |
There was a problem hiding this comment.
Clamp compaction thinking against the compaction model
When the active conversation model is marked always_thinking but loop_control.compaction_model points at a non-thinking/text-only alias, this.agent.config.thinkingLevel is already clamped on for the active model, so this line also enables thinking on the compaction provider even if the user configured thinking off. For OpenAI/Kimi providers that adds reasoning/thinking request parameters to the compaction model and can make every compaction fail; derive this from the raw requested thinking setting and only force it on when resolved.alwaysThinking applies to the compaction alias.
Useful? React with 👍 / 👎.
Related Issue
Resolve #840
Problem
Full-history compaction always used the active conversation model. That made it impossible to use a cheaper or faster configured model just for context compression.
What changed
loop_control.compaction_modelas an optional model aliascompaction_modelis unsetValidation
pnpm --filter @moonshot-ai/agent-core exec vitest run test/agent/compaction/full.test.ts test/config/configs.test.tspnpm --filter @moonshot-ai/kimi-code-sdk exec vitest run test/config.test.tspnpm --filter @moonshot-ai/agent-core run testpnpm --filter @moonshot-ai/agent-core run typecheckpnpm --filter @moonshot-ai/kimi-code-sdk run typecheckpnpm exec oxlint --type-aware packages/agent-core/src/agent/compaction/full.ts packages/agent-core/src/agent/llm-request-logger.ts packages/agent-core/src/agent/index.ts packages/agent-core/src/config/schema.ts packages/agent-core/test/config/configs.test.ts packages/agent-core/test/agent/compaction/full.test.ts packages/node-sdk/test/config.test.ts --quietnpm run build(insidedocs/)git diff --checkReview
Ran a read-only subagent review. It found issues around request auth/log aliasing, alias output caps, and compaction-model window sizing; those are fixed. Second pass found no blockers.
Checklist
gen-changesetsskill, or this PR needs no changeset.gen-docsskill, or this PR needs no doc update.AI Assistance Disclosure
I used Codex to review the changes, sanity-check the implementation against existing patterns, and help spot potential edge cases.