MoonshotAI / MoonshotAI/kimi-code

[Bug] Compaction fails: "No prefix that can be compacted" followed by APIContextOverflowError in v0.15.0 (0% context size displayed - brand new session)

Open
#794 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
7.5k
Forks
1.2k
Avg merge
11h 53m
Merged PRs (30d)
350

Description

What version of Kimi Code is running?

0.15.0 (Upgraded from 0.14.3 mid-session)

Which open platform/subscription were you using?

https://platform.kimi.ai/

Which model were you using?

openrouter/owl-alpha

What platform is your computer?

Linux 6.8.0-124-generic x86_64 x86_64

What issue are you seeing?

When running an explore agent with multiple MCP servers connected, a context compaction loop fails completely. (Brand new Session with 0% context size though, and getting auto compacted, while micro compaction option is set to false)

First, Kimi throws:
Error: [compaction.unable] No prefix that can be compacted in current history.

Then, it repeatedly attempts to send the request to OpenRouter but fails with:
Error: [compaction.failed] APIContextOverflowError: 400 This endpoint's maximum context length is 1048756 tokens. However, you requested about 1087438 tokens (4999 of text input, 33863 of tool input, 1048576 in the output). Please reduce the length of either one, or use the context-compression plugin to compress your prompt automatically.

Note: This seems highly related to existing issues #476 and #2439, but confirms the bug is still present in v0.15.0.

What steps can reproduce the bug?
  1. Have a heavy tool context (e.g., 9 MCP servers connected). (Though in the old Kimi CLI this setup was working) Context Size shown is 0% though, with a brnad new session throwing the same error.
  2. Run /agent create --type explore --goal "Setup n8n MCP connection for Hermes agent."
  3. Enter prompt: make n8n mcp (probably a docker container on xchg) available for hermes, also make sure n8n docker container or native runs on this system
  4. Context overflows, and compaction fails repeatedly.
What is the expected behavior?

Auto Compact shouldnt turn on immediately with first prompt and 0% Context size and
context compaction should successfully reduce the tool/history context or cleanly reject the prompt before sending an out-of-bounds request that crashes the loop.

Additional information

I have an exported session_47c955fa-5d5e-433e-81bc-8dfe5ea1ef2a.zip file available for the developers if needed for diagnosis.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source files or tests are named. Start by reproducing the failure with multiple MCP servers using the listed agent and prompt steps, then trace the compaction loop and context-size calculation before the OpenRouter request. Done means a fresh session does not compact at 0%, and oversized context is reduced or rejected without repeatedly crashing the loop.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.