github / github/copilot-cli

Preserve durable context across repeated compactions

Aperta
#4,441 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

area:context-memory
Lingua principale
Shell
Stelle
11.2k
Fork
1.9k
Merge medio
14h 16m
PR unite (30g)
6

Descrizione

Describe the feature or problem you'd like to solve

Each compaction re-summarizes the previous summary, so early decisions and gotchas degrade with every cycle

Proposed solution

Repeated context compaction is recursively lossy. After one compaction replaces the active conversation history with an LLM-generated summary, a later compaction summarizes that prior summary together with newer turns. Users need a supported way to maintain an additive, durable handoff that is not itself repeatedly summarized.

Add first-class pre- and post-compaction support for a session-scoped durable handoff.

The current behavior is documented and observable:

  • The context-management documentation says compaction snapshots the current conversation, sends the full conversation to the model, and replaces the old active history with the generated summary.
  • The same documentation warns that important context may be lost after many compactions.
  • In a local Copilot CLI 1.0.79 session, the first compaction reported 196 active messages and removed 195; the second reported 473 and removed 472. Each cycle therefore reduced the active history to one replacement message before newer turns accumulated.

The existing preCompact hook is a useful start. It receives transcriptPath, trigger, and customInstructions, so a command can inspect the transcript and persist a handoff. However, its output is not processed, it cannot prevent compaction when handoff generation fails, and there is no postCompact event that can inject the handoff into the newly compacted context.

Suggested minimal contract:

  1. Let preCompact return a blocking failure decision and/or additionalContext that is included in the compaction input.
  2. Add postCompact, fired after successful compaction, with trigger, checkpointNumber, checkpointPath, and summaryContent.
  3. Let postCompact return additionalContext that is injected exactly once into the new active context.
  4. Optionally provide a built-in session-scoped handoff ledger so users do not need to launch a nested model from a shell hook.
  5. Treat durable facts, decisions, constraints, evidence, and gotchas as additive records with provenance. Keep current state and next steps as replaceable sections, with explicit superseding/tombstone support so stale statements do not accumulate forever.

This would preserve continuity without requiring every later compaction to further compress all earlier knowledge.

Example prompts or workflows
  1. Before manual /compact, update the durable handoff from the transcript. If that update fails, stop compaction and show the failure.
  2. After compaction, inject the latest handoff exactly once so the agent resumes with the preserved facts and current state.
  3. At the next compaction, add only newly learned decisions, constraints, evidence, and gotchas; replace only the current-state and next-steps sections.
  4. Apply the same flow to automatic background compaction without interrupting normal work.
  5. Use /session handoff to inspect entries, provenance, superseded facts, and the handoff's token cost.
Additional context

Checkpoints are valuable for audit and recovery, but they are passive: earlier phases are no longer in active context unless the user explicitly reads a checkpoint. They do not provide additive durable memory across compactions.

Official references:

I found related requests for configurable compaction thresholds, but no existing issue covering additive handoff state or a post-compaction hook.

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia dalla documentazione di context-management e hooks-reference, quindi segui il preCompact hook esistente e il flusso di /compact. Definisci e implementa il contratto concordato di pre- e post-compaction, includendo la gestione degli errori e l’iniezione una tantum del contesto, quindi verifica il comportamento per la compaction manuale e automatica.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
github, shell
Ambito
cli, developer-experience
Tipo di issue
Funzionalità
Difficoltà
5/5
Tempo stimato
Più di una settimana
Stato di attività
Tranquilla
Chiarezza
Da chiarire
Idoneità per principianti
30/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.