Repository navigation
v0.5.0 — Independent extension preview for Pi 1.3.0, 1.2.0 and 1.1.0
Pre-releasePi Context Compaction v0.5.0 supplies an ordinary extension for unmodified official Pi 1.3.0, 1.2.0 and 1.1.0.
Install this release's extension package (a fixed package tag) from your terminal, then restart Pi:
pi install git:github.com/youxi-huang/pi-context-compaction@extension-v0.5.0Start a new persistent text session and run /compaction-doctor to check it without calling a model. Source tag v0.5.0 selects the development monorepo, not the package. To follow later previews instead, install the moving extension-preview branch in place of the tag and update only this package with pi update --extension git:github.com/youxi-huang/pi-context-compaction@extension-preview. A plain pi update updates Pi itself.
This pre-release supports manual /compact and Pi's threshold compaction after completed text turns, source-linked history retrieval and explicit disk-confirmed failure recovery. In the sessions it handles, overflow recovery still requires explicit /compact, and background cache warming is paused. Sessions it never protected and cannot check, such as ones with native checkpoints, images or another Pi version, are left to Pi without a failure marker. Other checkpoint formats, parent-history grants, attachments, concurrent writers and Windows are outside its verified scope.
Ordinary Agent retries after transient provider failures are supported, including partial-response connection drops. Existing retry-related blocks and text-only context-overflow failures can use explicit /compact recovery when sufficient completed source history exists. Arbitrary context edits and unfinished tool-call omissions remain unsupported.
Optional preparation has two arms, both disabled by default: A prepares with the configured writer; B merges data-only work notes from the session model. A validated candidate can commit its covered prefix without a writer call while every later original stays verbatim. B carries covered user messages in full and falls back to the configured writer when they do not fit. Every writer call is journaled, including cancelled or discarded preparation and unknown usage. These are experimental paths; real-provider pause, total cost, cache behavior and recovery benefits remain unproven.
Validation: this publication run passed 88 stock-Pi package and lifecycle checks on official Pi 1.3.0, 1.2.0 and 1.1.0 and the full default-settings scenario suite on Pi 1.3.0 with strict acceptance and no performance exceptions or known gaps. Scenario evidence is bound to this exact package and source commit; the 50 ms request-overhead target and checkpoint-growth bound are required checks. Focused, security and frozen evaluator checks also remain required on final main. Services are synthetic and loopback only; no real-provider quality, latency or interactive TUI claim is made.
Source commit: f95109b. Preview runtime: stock-preview+src.c6aefd74b04f4aaa. Resident runtime keeps its v0.3.0 fingerprint.
Usage and recovery · Validation
Changes
v0.5.0 makes the independent extension's notes harder to lose and its history quicker to search. The session writer sees every uncovered user message in full beside its entry ID, a note that fails only on its quotations gets one targeted repair, and context_history lists constraints, decisions, failed approaches, files, edits and errors directly. The writer also reuses the session's prompt cache, which cut its cost by about 70% on DeepSeek. The changes are in the independent preview only: the resident runtime, its build fingerprint, the checkpoint schema and the evaluation pin are unchanged, and a v0.5.0 checkpoint reopens under v0.4.3. Two bounded runs with DeepSeek V4.1 Flash on Pi 1.3.0 are in the validation record: on the two synthetic sessions both writers ran, v0.5.0 builds committed 37 to 40 of 40 notes against 32 for the v0.4.3 writer, and on the session built for retrieval every probe passed with fewer calls than the baseline. They cover one model and synthetic tasks, not a general failure rate.
Added
- One quotation repair. When a candidate note fails only because quotations do not match the entries they cite, for at most five facts, the writer gets one request about those facts alone: the entries they cite and the entries that do contain the quoted text, with their roles. A replacement may change only its sources and quote, or withdraw the fact; the rest of the note is kept as written and the whole note is checked again.
noteRepairgoverns this repair and the size repair, and a compaction spends at most one of them. A second failure blocks as before, and the extension never moves a quotation to another entry on its own. context_historylists one kind of item withoperation: "list": the constraints, decisions, failed approaches, files, plans and state that committed checkpoints recorded, plus edits and errors read from tool records, newest first, with superseded items marked and their original entries named. The list is computed on every call and stores nothing; search and read are unchanged./compaction-statusreports underlastWriterthe first refused candidate's quotation failures by class, the kind of repair that ran, what a quotation repair changed, how many writer responses called a tool and whether one was declined.
Changed
- The session writer's handover request lists every uncovered user message in full beside its entry ID, and says that the manifest's openings are not to be copied as quotations. Both recorded live runs lost a checkpoint to a quotation cited to the wrong entry. The list is marked as serving quotation only: on DeepSeek, without that line, the writer read it as the whole task and recorded the assistant's announced next step as unrequested.
- The session writer sets no tool choice, as the session's own requests do, so a provider that caches prompt prefixes serves its request from the session's cache. With
tool_choice: "none", DeepSeek left the tool definitions out of the prompt and every compaction paid for the whole history; in a check, 91 to 99.6% of the writer's input now came from cache and each call cost about a third. The request tells the model to call no tool. A tool call is never run: the first is answered as unavailable and the request continues once on the same cached prefix, without spending the size or quotation repair, so a compaction makes at most three writer calls; a second tool call refuses the note, andnoteRepairgoverns the continuation too. - A refused quotation's message counts the failures by class: text found in other entries, text that differs only in spacing or punctuation, and text found nowhere. A refused
context_notenames each failing field and the entries that contain its quoted text.
Maintenance
eval/previewadds an evaluation set for the preview, separate from the frozen fixtures: three invented sessions with revisions, withdrawn work, forbidden retries, quotation traps and, in P3, answers no note can hold, with 75 typed probes and their scorer. Scorer version 2 passes an answer that leads with the right value in prose and counts it;rescore.tsapplies it to saved replies.scripts/context-memory-preview-bench.mjsruns a writer bench and the probes on official Pi, offline by default.- The stock-Pi scenarios check quotation repair and the typed list end to end.
- The bench reaches a provider through Pi's proxy-aware dispatcher, retries a refused probe cut up to four attempts, and reports each committed note's size against the history it condenses and the gold answers it cites. By default it reproduces a session's prompt cache, warming the prefix before each cut's compactions as a session's turns do;
--cache coldmeasures a cold prefix. Two bounded DeepSeek runs of the baseline and the candidate are in the validation record.