[Feature] Preserve source seq/turn references in compaction summaries
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 25/100
- issue の種類
- 機能追加
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- typescript
調査の方向性
Start by locating the compaction request assembly and persistence paths in the Kimi Code TypeScript codebase, then read the related issues #1896, #3361, and #5127 for existing constraints. Trace how automatic and manual compaction receive history and return summaries. Done means trusted source references survive validation, readback, restart, and repeated compaction, with the listed fallback and diagnostics behavior verified on the real host.
索引モデルが issue の本文から書いたものです。
説明
What feature would you like to see?
Requested scope: Kimi Work and, where applicable, the shared Kimi Code compaction/plugin infrastructure.
I would like compaction summaries to preserve verifiable references to the source events that supported important conclusions. A reference should identify the original seq range and turnId, so that a continuity plugin or an existing readback tool can retrieve the evidence instead of treating the summary as an unverifiable endpoint.
For example, an important conclusion in a compacted summary could remain readable as:
The participants decided to adopt source-referenced compaction. [seq 32932-32935 | turn-032932]
The preferred implementation is native structured provenance rather than requiring every plugin to parse inline text:
{
"text": "The participants decided to adopt source-referenced compaction. [ref:r1]",
"references": [
{
"id": "r1",
"seqStart": 32932,
"seqEnd": 32935,
"turnId": "turn-032932"
}
]
}
Why this is needed
Long-session continuity currently has a gap between semantic summaries and raw history. A host summary may preserve a decision while losing the coordinates needed to inspect the original exchange. A retrieval hit against that summary therefore does not provide a reliable path back to the evidence.
A plugin can build a separate memory index, but it cannot reliably complete the following chain through a supported API in the Kimi Work build examined for this proposal:
- Obtain the trusted message-to-
seq/turnIdmapping for the exact history being compacted. - Add a source-reference requirement to the actual request sent to the compaction model.
- Have returned references validated against the compaction input.
- Persist those references with the host summary for later readback.
Without this connection, a plugin must ask a model to generate a second, parallel set of summaries. That duplicates model calls and compute, and the two summaries can diverge. Reusing the host summary with source references would avoid that duplication.
Preferred option: native source-referenced compaction
The host would:
- attach trusted source metadata to compaction inputs;
- ask the compaction model to preserve references for important facts, decisions, promises, experimental results, and state;
- accept only references actually present in that compaction input;
- reject, remove, or retry invalid, resized, reordered, or fabricated coordinates;
- persist a machine-readable reference table with the summary;
- preserve references through subsequent compactions, either directly or through a resolvable
compactionIdlineage.
Messages with ambiguous or unavailable mappings should remain unannotated rather than receiving guessed coordinates. Text that merely resembles a reference inside user content must not become trusted provenance.
Alternative: a versioned compaction-request preparation hook
If native structured references are not currently practical, a narrower supported hook would still solve the plugin use case:
interface CompactionReferenceV1 {
seqStart: number;
seqEnd: number;
turnId: string;
}
interface CompactionRequestPrepareInputV1 {
apiVersion: 1;
sessionId: string;
compactionId: string;
trigger: "auto" | "manual";
references: Array<{
messageId?: string;
reference: CompactionReferenceV1;
}>;
}
interface CompactionRequestPrepareResultV1 {
additionalInstruction?: string;
}
The hook would run after compaction history and instructions have been assembled, but before the compaction model is called. The plugin only needs to read the trusted reference mapping and append an instruction. The host should still own coordinate generation, output validation, reference persistence, and fallback behavior.
This does not require arbitrary kernel execution, replacement of the model, access to provider secrets, or unrestricted mutation of internal requests.
Required safety and compatibility behavior
- Versioned capability detection, so plugins can degrade cleanly.
- Session-scoped references; no cross-session access by default.
- Deterministic behavior when multiple plugins are installed.
- A bounded hook timeout and deterministic instruction-merging rules.
- Fallback to the original compaction request on mapping or plugin failure.
- No behavior change or extra model call when the feature/plugin is disabled.
- Invalid model references must never enter the trusted reference table.
- References must remain resolvable after restart and repeated compaction.
Acceptance criteria
- Both automatic and manual real-host compaction can produce source-referenced summaries.
- Every persisted reference belongs to the actual compaction input and can read back supporting source events.
- Fabricated, resized, or wrong-turn references are removed, isolated, or retried before commit.
- Duplicate content and duplicate assistant steps are reported as ambiguous/unmapped rather than guessed.
- Long messages, tool calls, tool results, and split chunks do not shift coordinates.
- A second compaction preserves the original references or a resolvable source lineage.
- References survive client restart and remain session-scoped.
- Disabling the feature preserves existing behavior; mapping failure, plugin failure, and timeout do not block compaction.
- Diagnostics expose at least
mapped,unmapped,ambiguous,valid,removed, anderrorcounts.
Additional information
Authorship
This requirement was drafted by Kimi (AI) from runtime observations, experimental analysis, and iterative continuity testing. It is submitted through the GitHub account @theseus-whale; the feature request and its acceptance criteria were synthesized by Kimi rather than presented as a human-maintainer specification.
Reference implementation
The target behavior can be illustrated by:
@theseus-whale/[email protected]
https://github.com/theseus-whale/dsh-continuity/tree/v5.0.10
That project demonstrates host-generated turn summaries, unified folding, exact seq readback, semantic recall, and chronological/semantic neighbor navigation. It is a behavioral reference only. This request does not ask Kimi to adopt DSH's architecture, tool names, or full feature set.
Existing proof of concept and its limits
A workspace-only experimental patch against a copied Kimi kernel bundle verified the basic mapping, instruction, sanitization, and fallback logic:
- Node syntax check passed.
- Sample mapping: 3 mapped, 3 unmapped, and 2 ambiguous messages.
- Reference sanitization: 2 valid references retained and 4 invalid references removed.
- Custom compaction instructions and source-reference instructions rendered together.
- Mapping-failure fallback and diagnostic fields passed offline assertions.
- Patched bundle SHA-256:
9d9a376b118fd4562617009b6ea5001eb6019b5f6617766a1fd6d1bd8f3446ef.
This is not a claim of end-to-end product verification. The patch was not installed into the live client; no real-host automatic or manual compaction acceptance test was performed. I am requesting a supported kernel capability, not asking users to maintain a modified bundle.
Related issues
- #1896 concerns post-compaction context restoration and hook output, but not source references inside compaction summaries.
- #3361 concerns compaction transparency, pinned facts, and retention budgets, but not source-coordinate provenance.
- #5127 concerns headless compaction and observability. Its proposed result metadata would complement, but not replace, source references.
I searched for existing requests covering source-referenced compaction and did not find one with this contract. This is a feature proposal only; no feature PR is being submitted.
- 主要言語
- TypeScript
- スター
- 8.3k
- フォーク
- 1.4k
- 平均マージ
- 12時間 6分
- マージ済み PR(30日)
- 596
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
MoonshotAI/kimi-code のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
MoonshotAI/kimi-code#5539 ·
メンテナーはふだん 1 日以内に返信
-
[Bug] Kimi RC workspace folder picker does not display symbolic link directories対応中かも @markankamaransheogarat-sys が 2 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
MoonshotAI/kimi-code#5296 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
MoonshotAI/kimi-code#5256 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
MoonshotAI/kimi-code#5062 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
MoonshotAI/kimi-code#5057 ·
メンテナーはふだん 1 日以内に返信
MoonshotAI/kimi-code の issue をすべて見る
似ている issue
-
Add Alice&Botオープン
難易度 1/5 1時間未満 初心者へのやさしさ 72/100
slavakurilyak/awesome-ai-agents#1048 ·
-
bot:ai-assisted component:faucet github_actions security status:untriaged
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
midnightntwrk/midnight-faucet-api#215 ·
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
NanmiCoder/cc-haha#2034 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
mobile prio:low
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
digitalfabrik/entitlementcard#3324 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信