Skip to content

fix(agent-core): account for earlier kept requests in the compaction summary - #2681

Open
tommy0103 wants to merge 1 commit into
MoonshotAI:mainfrom
tommy0103:fix/compaction-summary-task-status
Open

fix(agent-core): account for earlier kept requests in the compaction summary#2681
tommy0103 wants to merge 1 commit into
MoonshotAI:mainfrom
tommy0103:fix/compaction-summary-task-status

Conversation

@tommy0103

Copy link
Copy Markdown

Related Issue

Resolve #2680

Problem

See linked issue. In short: when auto compaction fires mid-turn in a long multi-task session, the rebuilt context keeps old user messages verbatim but drops their answers. If the summary does not say the earliest kept request (typically the session-opening skill activation) is already finished, the post-compaction step can abandon the in-flight request and re-execute that stale instruction.

What changed

Prompt-level fix on both the production and consumption sides of the compaction summary:

  • The compaction instruction now requires the summarizer to account for every earlier request still visible among the kept user messages — done (and where its output landed), abandoned, superseded, or still open — and calls out instruction-bearing messages (skill activations, slash commands) as needing an explicit "already carried out" record.
  • The summary prefix now tells the consuming turn that preserved user messages are stripped of their original answers, and that requests the summary marks as completed must not be restarted.

This approach fits Kimi Code because it closes the drift loophole without changing the rebuilt context shape (kept-set selection, head/tail budgets, and the drop of assistant messages all stay as-is); the stricter alternative of narrowing skill_activation retention was deliberately left out as too invasive for a first fix. Existing compaction tests cover the new text — snapshots and two hardcoded token-count expectations were updated for the longer templates.

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.

…summary

Auto compaction keeps old user messages verbatim but drops their answers,
so a long-completed request (notably a session-opening skill activation)
reads as pending work once the summary fails to mention it. The post-
compaction turn could then abandon the in-flight request and re-execute
the session's earliest message.

Teach the compaction instruction to mark each earlier request still
visible in the kept messages as done / abandoned / superseded / open,
and tell the summary consumer not to restart requests the summary marks
as completed.
@changeset-bot

changeset-bot Bot commented Aug 6, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 698b646

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 Patch

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

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.

After auto compaction, the agent abandons the in-flight request and re-executes the session's earliest skill activation

1 participant