feat(plugin): add configurable compaction providers#1549
feat(plugin): add configurable compaction providers#1549CanerKocak wants to merge 10 commits intoMoonshotAI:mainfrom
Conversation
- Extend plugin.json with compaction.entrypoint (module.Class under plugin dir) - Resolve first loadable compactor from ~/.kimi/plugins (sorted); warn on conflicts - KimiSoul uses plugin compactor when present, else SimpleCompaction - Purge cached top-level module before import so plugins can reuse module names Made-with: Cursor
# Conflicts: # CHANGELOG.md # docs/en/release-notes/changelog.md # docs/zh/release-notes/changelog.md # src/kimi_cli/soul/agent.py # tests/core/test_startup_progress.py
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1c6416f142
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| for part in module_parts[:-1]: | ||
| parent_dir = parent_dir / part | ||
| parent_package = f"{parent_package}.{part}" | ||
| _ensure_package_module(parent_package, parent_dir) |
There was a problem hiding this comment.
Load real parent packages for package entrypoints
When compaction.entrypoint points to a submodule (for example mypkg.compactor.MyCompactor), _load_plugin_module() creates synthetic parent package modules via _ensure_package_module() but never executes mypkg/__init__.py. In that case, valid plugins that rely on package-init symbols (e.g. from . import SOME_CONST) fail at import time with ImportError, even though they work with normal Python imports. Parent packages need to be imported/executed, not only stubbed, before loading the target submodule.
Useful? React with 👍 / 👎.
Related Issue
N/A
Description
This PR adds explicit, user-configurable compaction support to Kimi Code CLI.
Changes in this PR:
loop_control.compaction_modelso context compaction can use a dedicated model instead of always reusing the active chat modelloop_control.compaction_pluginso users can select a plugin-provided compactor explicitlyplugin.jsonto supportcompaction.entrypointfor custom compaction implementationsKimiSoulThis core work is also intended to support a companion plugin repo, CanerKocak/kimi-morph-plugin, which builds on top of the new plugin-based compaction path as a concrete consumer of these hooks.
morph-plugin-demo.mp4
Checklist
make gen-changelogto update the changelog.make gen-docsto update the user documentation.