MoonshotAI / MoonshotAI/kimi-cli

# Context compaction reloads system prompt and project instructions, wasting ~20k tokens

Open
#2,472 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Python
Stars
11.4k
Forks
1.3k
Avg merge
9h 47m
Merged PRs (30d)
2

Description

Problem

After the session triggers context compaction, the system prompt and project-level instructions (e.g., AGENTS.md, skills, environment context) appear to be reloaded from scratch. This costs a significant number of tokens (~20k in observed cases) even though the information itself has not changed.

Steps to reproduce
  1. Start a Kimi Code CLI session in a project with a large AGENTS.md / skill set.
  2. Work until context compaction is triggered.
  3. Observe that the system prompt and project instructions are re-injected/reloaded instead of being preserved.
Expected behavior

Context compaction should prune transient conversation history while keeping immutable or unchanged context (system prompt, project instructions, skills) pinned, so it does not need to be re-sent and re-billed.

Actual behavior

The system prompt and project instructions are reloaded after compaction, causing unnecessary token usage.

Additional information

No response

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

Start by reproducing context compaction in a Kimi Code CLI project with a large AGENTS.md or skill set, then trace the context compaction path to see where system and project instructions are reloaded. Done means transient conversation history is pruned while unchanged system prompts, project instructions, skills, and environment context remain pinned without the observed token waste.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.