Preserve durable context across repeated compactions
まだ誰も着手していません。
- 主要言語
- Shell
- スター
- 11.2k
- フォーク
- 1.9k
- 平均マージ
- 14時間 16分
- マージ済み PR(30日)
- 6
説明
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:
- Let
preCompactreturn a blocking failure decision and/oradditionalContextthat is included in the compaction input. - Add
postCompact, fired after successful compaction, withtrigger,checkpointNumber,checkpointPath, andsummaryContent. - Let
postCompactreturnadditionalContextthat is injected exactly once into the new active context. - Optionally provide a built-in session-scoped handoff ledger so users do not need to launch a nested model from a shell hook.
- 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
- Before manual
/compact, update the durable handoff from the transcript. If that update fails, stop compaction and show the failure. - After compaction, inject the latest handoff exactly once so the agent resumes with the preserved facts and current state.
- At the next compaction, add only newly learned decisions, constraints, evidence, and gotchas; replace only the current-state and next-steps sections.
- Apply the same flow to automatic background compaction without interrupting normal work.
- Use
/session handoffto 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:
- https://docs.github.com/en/copilot/concepts/agents/copilot-cli/context-management
- https://docs.github.com/en/copilot/reference/hooks-reference
I found related requests for configurable compaction thresholds, but no existing issue covering additive handoff state or a post-compaction hook.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
context-management と hooks-reference のドキュメントから始め、既存の preCompact hook と /compact フローを追跡します。合意された圧縮前後のコントラクトを定義・実装し、失敗処理とコンテキストの一度限りの注入を含め、手動および自動の圧縮で動作を検証します。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- github, shell
- 領域
- cli, developer-experience
- issue の種類
- 機能追加
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 活発さ
- 静か
- 明瞭さ
- 説明が足りない
- 初心者へのやさしさ
- 30/100