design: use knox state to improve compaction #28
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Compaction is where a long session loses its thread: the transcript is summarised generically, and decisions, open questions and evidence provenance are the first things to go.
knox already holds the structured version of what a compaction is trying to reconstruct — entries, threads with motivation, claim-ledger state, recent observations — and it is now fresh at turn start.
Hook contract (verified in the V2 docs)
compactionis a session request hook:messages— the transcript being summarisedsystem— mutable, same ascontextresult?: SessionCompactionResult— set it to record the compaction yourself and skip the model callSo there are two shapes:
A. Augment (safe, recommend first) — push a system part carrying knox state, let the model write the summary as usual. The summary keeps its usual quality and gains structure. No risk of replacing summarisation with something worse.
B. Replace (powerful, risky) — generate the compaction from knox alone. Cheap and deterministic, but any detail knox never ingested is silently lost, and a bad compaction poisons the rest of the session.
Proposed v1 (A)
compaction, query knox for: open threads (title + motivation), claims currently due, and the last N observations in this project.KNOX_COMPACTION=augment|off, default off until observed.Why not ship it live today
Compaction only fires on long sessions, so it cannot be exercised by a unit test or a short run. The failure mode is a session that continues confidently with a wrong summary — the same class of error this repo keeps hitting, but self-inflicted and hard to notice.
Verification path: enable
augmenton one long session, diff the resulting summary against one produced without it, and only then consider defaults.Open questions