Skip to content

feat(agent-core): add compaction model config#931

Open
tt-a1i wants to merge 1 commit into
MoonshotAI:mainfrom
tt-a1i:fix/compaction-model-config
Open

feat(agent-core): add compaction model config#931
tt-a1i wants to merge 1 commit into
MoonshotAI:mainfrom
tt-a1i:fix/compaction-model-config

Conversation

@tt-a1i

@tt-a1i tt-a1i commented Jun 20, 2026

Copy link
Copy Markdown

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

  • add loop_control.compaction_model as an optional model alias
  • resolve the compaction alias through the existing model/provider config path
  • use the compaction alias for request auth, request logging, usage accounting, completion budget, and request-prefix sizing
  • fall back to the active conversation model when compaction_model is unset
  • document the new field in the EN/ZH config docs

Validation

  • pnpm --filter @moonshot-ai/agent-core exec vitest run test/agent/compaction/full.test.ts test/config/configs.test.ts
  • pnpm --filter @moonshot-ai/kimi-code-sdk exec vitest run test/config.test.ts
  • pnpm --filter @moonshot-ai/agent-core run test
  • pnpm --filter @moonshot-ai/agent-core run typecheck
  • pnpm --filter @moonshot-ai/kimi-code-sdk run typecheck
  • pnpm 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 --quiet
  • npm run build (inside docs/)
  • git diff --check

Review

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

  • I have read the CONTRIBUTING document.
  • I have linked a related issue, or explained the problem above.
  • I have added tests that prove my feature works.
  • Ran gen-changesets skill, or this PR needs no changeset.
  • Ran gen-docs skill, 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.

@changeset-bot

changeset-bot Bot commented Jun 20, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 85d187a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@moonshot-ai/kimi-code Minor

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

@tt-a1i tt-a1i marked this pull request as ready for review June 20, 2026 04:20

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment on lines +491 to +492
: this.agent.config.thinkingLevel;
const provider = createProvider(resolved.provider).withThinking(thinkingLevel);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature: 支持 compaction 使用独立模型(compaction_model 配置项)

1 participant