[Feature] Preserve source seq/turn references in compaction summaries
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 25/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- typescript
- Ambito
- ai-infra-agents
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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.
- Lingua principale
- TypeScript
- Stelle
- 8.3k
- Fork
- 1.4k
- Merge medio
- 12h 6m
- PR unite (30g)
- 596
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di MoonshotAI/kimi-code
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
MoonshotAI/kimi-code#5539 ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug] Kimi RC workspace folder picker does not display symbolic link directoriesForse già presa @markankamaransheogarat-sys l’ha presa 2 giorni fa. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
MoonshotAI/kimi-code#5296 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
MoonshotAI/kimi-code#5256 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
MoonshotAI/kimi-code#5062 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
MoonshotAI/kimi-code#5057 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di MoonshotAI/kimi-code
Issue simili
-
Add Alice&BotAperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 72/100
slavakurilyak/awesome-ai-agents#1048 ·
-
bot:ai-assisted component:faucet github_actions security status:untriaged
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
midnightntwrk/midnight-faucet-api#215 ·
I maintainer di solito rispondono entro 1 giorno
-
[功能] 手机端命令执行显示 AI 动作描述Apertaenhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
NanmiCoder/cc-haha#2034 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
mobile prio:low
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
digitalfabrik/entitlementcard#3324 ·
I maintainer di solito rispondono entro 2 giorni
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
I maintainer di solito rispondono entro 1 giorno