Skip to content

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

Description

@creatiVision

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions