@foliox/transparent-compact-pi 0.11.2 → 0.11.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -0
- package/README.md +40 -7
- package/docs/DESIGN.md +72 -49
- package/extensions/index.ts +150 -203
- package/extensions/lib/read-retention-ui.ts +105 -0
- package/extensions/lib/read-retention.ts +228 -0
- package/extensions/lib/turn-context.ts +5 -1
- package/extensions/lib/turn-filter.ts +20 -4
- package/package.json +2 -2
- package/skills/context-retrieval/SKILL.md +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.11.3
|
|
4
|
+
|
|
5
|
+
- Replace heuristic startup-read retention with explicit `<retain-reads>` declarations
|
|
6
|
+
in AGENTS/CLAUDE files: default to the first read, or use `latest:`.
|
|
7
|
+
- Add `/retain-reads` with OFF/FIRST/LATEST selection, first/latest read ordering,
|
|
8
|
+
complete previews, coverage labels and filtered-turn flags. Group consecutive
|
|
9
|
+
partial reads into episodes; preserve selected outputs independently of turn
|
|
10
|
+
filtering without duplicating recent-tail or native-turn outputs. Choices persist
|
|
11
|
+
in the session branch; confirmed edits can revise an existing checkpoint without
|
|
12
|
+
additional compaction.
|
|
13
|
+
- Keep retained read outputs at their original positions, or directly after their
|
|
14
|
+
filtered-turn marker, without a separate retained-read section. Preserve placement
|
|
15
|
+
through restoration and repeated compactions; keep inline outputs untrimmed.
|
|
16
|
+
- Document the potential next-request prompt-cache cost of manual context edits.
|
|
17
|
+
- Add `/export-checkpoint [path]` to export the current branch's saved checkpoint
|
|
18
|
+
as plain text, including confirmed manual revisions, without rebuilding it or
|
|
19
|
+
changing context.
|
|
20
|
+
|
|
21
|
+
## 0.11.2
|
|
22
|
+
|
|
23
|
+
- Remove read/modified file inventories and per-file evidence annotations from
|
|
24
|
+
checkpoints. Keep the location dictionary as a plain ID-to-location lookup and
|
|
25
|
+
remove related agent-facing guidance; file operations remain in conversation context.
|
|
26
|
+
|
|
27
|
+
## 0.11.2
|
|
28
|
+
|
|
29
|
+
- Added manual context filtering.
|
|
30
|
+
|
|
3
31
|
## 0.11.0
|
|
4
32
|
|
|
5
33
|
- Use shared location IDs and AST-based skeletons for long bash tool calls.
|
package/README.md
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
# transparent-compact
|
|
1
|
+
# transparent-compact-pi
|
|
2
2
|
|
|
3
|
-
[Context compaction](#control-compaction) for [Pi](https://pi.dev/) that keeps conversation text verbatim instead of replacing it with a model-generated summary. It removes thinking and most tool output from the active context, while keeping user messages, assistant text, compact tool-call stubs and selected
|
|
3
|
+
[Context compaction](#control-compaction) and pruning for [Pi](https://pi.dev/) that keeps conversation text verbatim instead of replacing it with a model-generated summary. It removes thinking and most tool output from the active context, while keeping user messages, assistant text, compact tool-call stubs and explicitly selected reads. The original session history remains available.
|
|
4
4
|
|
|
5
5
|
When the agent needs a detail that is no longer in context, it can use retrieval tools to search the recorded session with a subagent. Compaction itself does not make a model call.
|
|
6
6
|
|
|
7
|
-
The user can also [selectively manipulate which turns to hold in the current context](#filter-turns) in higher or lower fidelity.
|
|
7
|
+
The user can also [selectively manipulate which turns to hold in the current context](#filter-turns) in higher or lower fidelity, and [specify file reads to be retained in the context in full](#retain-reads), (e.g. a spec or plan).
|
|
8
8
|
|
|
9
9
|
This extension is aimed at addressing two main issues that other compaction techniques face, which are especially exacerbated in agents running on lightweight and local LLMs:
|
|
10
10
|
- Model summaries such as Pi's default method can lead to degradation and confabulation of details that can cause confident blunders.
|
|
11
|
-
- Retrieval-based systems like `pi-vcc` can be effective when the agent knows what to look for, but omitting session structure from the retained context can make retrieval less reliable.
|
|
11
|
+
- Retrieval-based systems like `pi-vcc` can be effective when the agent knows what to look for, but omitting session structure from the retained context can make the actual use of retrieval less reliable.
|
|
12
12
|
|
|
13
|
-
`transparent-compact` is also a retrieval-based system, but its design keeps manipulation of conversation text to a minimum and maximises the agent's awareness of its compacted state, with the aim of avoiding confabulation and encouraging accurate retrieval of historical details. [This study](https://arxiv.org/abs/2610.20116) found that a minimal approach outperformed more complex techniques with lightweight models and was at least as effective with frontier models.
|
|
13
|
+
`transparent-compact` is also a retrieval-based system, but its design keeps manipulation of conversation text to a minimum and maximises the agent's awareness of its own compacted state, with the aim of avoiding confabulation and encouraging accurate retrieval of historical details. [This study](https://arxiv.org/abs/2610.20116) found that a minimal approach outperformed more complex techniques with lightweight models and was at least as effective with frontier models.
|
|
14
14
|
|
|
15
15
|
The verbatim compaction system plays particularly nicely with manual pruning of the context. This allows you to decide which parts of the session remain important to the current work, without having to commit to a particular branching point with /tree or decide at the time of the prompt with something like claude's /btw.
|
|
16
16
|
|
|
@@ -35,7 +35,7 @@ Once loaded, the extension uses verbatim compaction by default. Pi's automatic c
|
|
|
35
35
|
/compact
|
|
36
36
|
```
|
|
37
37
|
|
|
38
|
-
No additional setup is required. The agent can recover missing details from session history as needed.
|
|
38
|
+
No additional setup is required. The agent can recover missing details from session history as needed.
|
|
39
39
|
|
|
40
40
|
## Filter turns
|
|
41
41
|
|
|
@@ -64,6 +64,12 @@ You can restore filtered turns later. Choices persist in the current session bra
|
|
|
64
64
|
|
|
65
65
|
PROSE+TOOLS and FULL can use substantial context. Oversized selections are rejected, and if later context growth or a model change makes them too large, use `/filter-turns` to downgrade them. FULL includes only what was recorded; provider and model limitations can still affect thinking and images.
|
|
66
66
|
|
|
67
|
+
### Manual context editing and caching
|
|
68
|
+
Manual context edits typically reduce prompt-cache reuse for the next model request, so frequent edits of the retained reads or turn filters are discouraged, and the best time to adjust them is just after compaction, before the next request.
|
|
69
|
+
|
|
70
|
+
The extension never automatically modifies the context outside of Pi's usual compaction trigger. The user is expected to control the filtering system, or simply ignore it when not needed.
|
|
71
|
+
Treat filtering/pruning/read-retention as useful tools when the situation calls for them, not necessary to the use of the compaction system.
|
|
72
|
+
|
|
67
73
|
### Flag an aside
|
|
68
74
|
|
|
69
75
|
```text
|
|
@@ -76,8 +82,35 @@ PROSE+TOOLS and FULL can use substantial context. Oversized selections are rejec
|
|
|
76
82
|
|
|
77
83
|
A flagged turn remains in context until it is eligible for filtering. It is preselected for pruning in the editor, where you can keep or later restore it. Automatic application of flags is **off** by default. `/fl` is a normal conversation turn, not an isolated aside.
|
|
78
84
|
|
|
85
|
+
## Retain reads
|
|
86
|
+
|
|
87
|
+
Use `/retain-reads` while the agent is idle to keep selected text-read outputs verbatim in the checkpoint. Each file can be **OFF**, **FIRST**, or **LATEST**. In the picker, controls are as in the turn-filtering picker.
|
|
88
|
+
|
|
89
|
+
Consecutive partial reads of the same file with connected ranges form one selectable read episode. Another tool operation, a restarted range, or a new user turn starts a new episode. The picker shows full or partial coverage and flags reads from filtered turns. Retention survives turn filtering;
|
|
90
|
+
|
|
91
|
+
Retained outputs are historical snapshots of the read tool output, not current file contents.
|
|
92
|
+
|
|
93
|
+
### Automatic file retention
|
|
94
|
+
|
|
95
|
+
Nothing is retained automatically, but files can be declared for retention in `AGENTS.md` or `CLAUDE.md` like so:
|
|
96
|
+
|
|
97
|
+
```text
|
|
98
|
+
<retain-reads>
|
|
99
|
+
docs/SPEC.md
|
|
100
|
+
latest: docs/WORKING-NOTES.md
|
|
101
|
+
</retain-reads>
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
Use one literal path per line, relative to the instruction file. Plain paths default to FIRST; `latest:` selects the latest read. These declarations do not read files themselves. Manual choices override the defaults.
|
|
105
|
+
|
|
79
106
|
## Control compaction
|
|
80
107
|
|
|
108
|
+
### Export the checkpoint
|
|
109
|
+
|
|
110
|
+
Use `/export-checkpoint [path]` to save the current checkpoint as plain text. Without a path, it writes `pi-checkpoint-<session-id>.txt` in the working directory; quote paths containing spaces.
|
|
111
|
+
|
|
112
|
+
This exports the saved text, including confirmed filtering and read-retention edits, without rebuilding or changing context. Recent messages and separately reinserted PROSE+TOOLS/FULL messages are not included.
|
|
113
|
+
|
|
81
114
|
### Choose the method
|
|
82
115
|
|
|
83
116
|
```text
|
|
@@ -105,7 +138,7 @@ If you regularly reach the cap, consider starting a new session or using a diffe
|
|
|
105
138
|
/cap-compaction 40000c # change budget without changing mode
|
|
106
139
|
```
|
|
107
140
|
|
|
108
|
-
Mode and budget persist in the session branch; changing one leaves the other unchanged. They apply only to verbatim compaction. The cap estimates tokens at four characters each and is not a limit on the whole model context. Some content, including retained
|
|
141
|
+
Mode and budget persist in the session branch; changing one leaves the other unchanged. They apply only to verbatim compaction. The cap estimates tokens at four characters each and is not a limit on the whole model context. Some content, including retained reads, is not trimmed. Disabling the cap may leave too much context for the model.
|
|
109
142
|
|
|
110
143
|
For unattended use, choose `on` to avoid interactive prompts. Without an interactive UI, `warn` emits a warning and applies the cap. If the model's context window is unavailable, use a fixed token or character budget, or turn the cap off.
|
|
111
144
|
|
package/docs/DESIGN.md
CHANGED
|
@@ -12,7 +12,7 @@ extension builds a checkpoint without changing that boundary or calling a model:
|
|
|
12
12
|
| Assistant prose | Kept, subject to the size guard. |
|
|
13
13
|
| Tool calls | Short signatures with outcome labels; full arguments and outputs remain recoverable. |
|
|
14
14
|
| Assistant thinking | Removed from the checkpoint; retained in the raw session. |
|
|
15
|
-
| Tool outputs | Mostly removed; selected bash observations and
|
|
15
|
+
| Tool outputs | Mostly removed; selected bash observations and explicitly retained reads remain. All remain in raw history. |
|
|
16
16
|
| Custom messages | Short type stubs marked `content removed`; bodies remain in the raw session. Managed re-orientation messages are regenerated instead. |
|
|
17
17
|
| Recent conversation | Pi keeps its normal verbatim tail. |
|
|
18
18
|
| Earlier compacted spans | Re-rendered chronologically, without repeated model summarization. |
|
|
@@ -159,21 +159,22 @@ compaction spans. Confirmed exclusions are stored as the current `filteredTurnId
|
|
|
159
159
|
snapshot on the compaction entry or its standalone revision, not an append-only
|
|
160
160
|
union. Later verbatim checkpoints apply that branch-local selection to the original canonical spans before size
|
|
161
161
|
trimming, reindexing tool display records without changing stored history.
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
162
|
+
Read-retention choices apply independently after turn filtering; selected read
|
|
163
|
+
outputs survive even when their owning turn is pruned. Restoring a turn restores
|
|
164
|
+
its prose and location definitions without filesystem reads. There is no migration
|
|
165
|
+
or reconstruction of saved spans without turn ownership; opaque content is not
|
|
166
|
+
individually selectable.
|
|
167
167
|
|
|
168
168
|
One `[Turn manually filtered]` marker replaces each excluded group at its original
|
|
169
|
-
position, even across spans. Markers survive the size cap.
|
|
170
|
-
|
|
169
|
+
position, even across spans. Markers survive the size cap. Explicitly retained reads
|
|
170
|
+
follow their turn's marker directly, in recorded order, even across spans; location
|
|
171
|
+
definitions used only by excluded turns are removed.
|
|
171
172
|
Filtering does not undo filesystem mutations. The checkpoint introduction and
|
|
172
173
|
persistent reorientation conditionally explain that the user excluded low-value
|
|
173
174
|
context, which remains retrievable from the full raw history. Recovery tools are
|
|
174
175
|
unchanged. Cancelling or failing a turn edit saves no revision. Mechanical compaction
|
|
175
|
-
with existing pruning or
|
|
176
|
-
falling through to a model summary that would lose those choices.
|
|
176
|
+
with existing pruning, fidelity or read-retention choices cancels on build failure
|
|
177
|
+
rather than falling through to a model summary that would lose those choices.
|
|
177
178
|
|
|
178
179
|
Standalone updates append a non-context `transparent-compact:filter-revision`
|
|
179
180
|
entry containing the source compaction ID, rendered checkpoint, exclusions and
|
|
@@ -236,10 +237,9 @@ copies prevent later transforms from mutating canonical session records. Provide
|
|
|
236
237
|
compatibility transformations still apply, including cross-model reasoning and
|
|
237
238
|
non-vision image handling; no unavailable reasoning or nested outputs are invented.
|
|
238
239
|
|
|
239
|
-
Native turns replace their compacted prose and
|
|
240
|
-
canonical source data.
|
|
241
|
-
|
|
242
|
-
can recover its canonical retained reads again. Mode choices inherit through
|
|
240
|
+
Native turns replace their compacted prose and retained-read duplicates, not the
|
|
241
|
+
canonical source data. PROSE restoration makes separately selected reads visible
|
|
242
|
+
at their original read positions again. Mode choices inherit through
|
|
243
243
|
reload/resume, tree navigation and later verbatim compactions; explicit fidelity
|
|
244
244
|
choices also override aside pre-flags. An empty revision clears old fidelity rather
|
|
245
245
|
than falling back to the source checkpoint's map. Explicit summary compaction gets
|
|
@@ -304,38 +304,61 @@ a failed estimate), not on every toggle. Generation checks reject stale results,
|
|
|
304
304
|
closing/disposing the dialog invalidates pending work. No estimated sizes are
|
|
305
305
|
persisted in checkpoint metadata, and no model calls are introduced.
|
|
306
306
|
|
|
307
|
-
###
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
307
|
+
### Explicit read retention
|
|
308
|
+
|
|
309
|
+
`extensions/lib/read-retention.ts` derives a file/episode catalog from Pi's
|
|
310
|
+
context-edited original projection of the active branch. Only unambiguous,
|
|
311
|
+
successful, text-only `read` pairs qualify. Failed, missing-status, orphaned,
|
|
312
|
+
non-text and explicitly omitted reads do not. Replacements supply their projected
|
|
313
|
+
bytes. Shell and nested reads have no standalone result to retain. No source
|
|
314
|
+
files are opened, and no model calls or additional tool operations are involved.
|
|
315
|
+
|
|
316
|
+
Defaults come only from `<retain-reads>` blocks in AGENTS/CLAUDE context files
|
|
317
|
+
(including `AGENTS.override.md`) or their recorded reads. Named project-instruction
|
|
318
|
+
blocks provide a fallback when structured context files are absent. Each line is
|
|
319
|
+
a literal path resolved relative to its instruction file: plain paths select FIRST,
|
|
320
|
+
`latest:` selects LATEST. Ordinary mentions, basenames elsewhere and globs have
|
|
321
|
+
no matching semantics. Current system context files override recorded copies.
|
|
322
|
+
There is no special first-user-turn selection window.
|
|
323
|
+
|
|
324
|
+
Consecutive successful reads of the same normalized path and user turn form an
|
|
325
|
+
episode when their ranges advance and connect or overlap. Assistant commentary
|
|
326
|
+
is allowed between pages; other tool calls, gaps, errors, restarted ranges and
|
|
327
|
+
new user turns break adjacency. Source call order, not tool completion order,
|
|
328
|
+
defines adjacency. The first/latest episode is selected per file. Requested limits
|
|
329
|
+
are not output coverage: Pi pagination notices and delivered text determine
|
|
330
|
+
coverage, and unknown truncation stays partial. Outputs remain separate verbatim
|
|
331
|
+
blocks, including their original pagination notices; no synthetic file is built.
|
|
332
|
+
|
|
333
|
+
`/retain-reads` uses a local draft with OFF/FIRST/LATEST, first/latest ascending
|
|
334
|
+
ordering, full scrollable previews, coverage/size labels and filtered-turn flags.
|
|
335
|
+
Enter reviews and then saves; Escape cancels. Manual overrides, including OFF,
|
|
336
|
+
persist branch-locally and can be reset to declarations. Before any checkpoint,
|
|
337
|
+
choices are custom state; afterward they share the checkpoint revision mechanism
|
|
338
|
+
with turn controls. Revisions preserve the existing boundary, tail and native
|
|
339
|
+
placements, with session/leaf checks before saving. Compaction details and revisions
|
|
340
|
+
store defaults and overrides, not additional copies of raw read bodies. Saving
|
|
341
|
+
also refreshes changed read candidates without requiring a mode toggle; no-op
|
|
342
|
+
checks compare generated retained copies against the previous revision's branch
|
|
343
|
+
inputs, never parsed checkpoint text.
|
|
344
|
+
|
|
345
|
+
Canonical spans record `readPositions`: result entry IDs and insertion boundaries
|
|
346
|
+
between prose/tool lines, including reads currently OFF. They contain no read bodies.
|
|
347
|
+
Rendering inserts selected original outputs at those positions, with structural
|
|
348
|
+
protection from trimming and remapped tool-record indices. There is no separate
|
|
349
|
+
retained-read section or introduction. Batched results keep recorded result order;
|
|
350
|
+
episode grouping/selection still uses call order.
|
|
351
|
+
|
|
352
|
+
Retention survives turn pruning: protected read rows from a pruned turn, including
|
|
353
|
+
later-span rows, move directly after its single first marker, with
|
|
354
|
+
`filtered-turn="true"`. Restoration returns them to their original positions.
|
|
355
|
+
Native expansion preserves protection on other turns' reads. An unplaceable selected
|
|
356
|
+
read (such as one covered only by an opaque model summary) rejects the rebuild rather
|
|
357
|
+
than silently dropping or moving it to an invented location. OFF does not remove
|
|
358
|
+
normal tool content. Tail/native outputs are not duplicated. Repeated compactions select
|
|
359
|
+
original projected outputs again (FIRST stays first; LATEST follows later reads),
|
|
360
|
+
not text parsed from earlier checkpoints. Reload, resume and tree navigation use
|
|
361
|
+
the active branch's choices and candidates.
|
|
339
362
|
|
|
340
363
|
#### How cap trimming works
|
|
341
364
|
|
|
@@ -377,7 +400,7 @@ opaque and use the conservative omission fallback. They are not regex-parsed or
|
|
|
377
400
|
reconstructed from current raw history, which might differ from the projected
|
|
378
401
|
content originally compacted. Inherited model-summary/opaque bases remain fixed.
|
|
379
402
|
|
|
380
|
-
|
|
403
|
+
Explicitly retained reads count once in the span budget as protected rows and are never trimmed.
|
|
381
404
|
Like an inherited base, they can exceed the budget by themselves; in that case
|
|
382
405
|
the extension warns and preserves them. The conversation-line budget still has
|
|
383
406
|
a 500-character minimum. Space for span annotations is reserved in the size guard.
|
|
@@ -522,14 +545,14 @@ instructions that must be prominent at the actual point of resumption:
|
|
|
522
545
|
|
|
523
546
|
```text
|
|
524
547
|
Checkpoint introduction: what was removed + full recovery instructions
|
|
525
|
-
All compacted spans (oldest first
|
|
548
|
+
All compacted spans (oldest first, with retained reads in place), then location dictionary
|
|
526
549
|
One evidence-boundary warning + start-of-verbatim-tail marker
|
|
527
550
|
Retained verbatim tail
|
|
528
551
|
Any pending new user input
|
|
529
552
|
Task-relevant recovery reminders + brief recovery recap
|
|
530
553
|
```
|
|
531
554
|
|
|
532
|
-
The recovery reminders identify retained
|
|
555
|
+
The recovery reminders identify selected retained reads and the uncompacted tail
|
|
533
556
|
as available evidence. They ask for recovery only when task-relevant inputs are
|
|
534
557
|
missing, not for rediscovery of reading requirements or blanket document rereads.
|
|
535
558
|
They also distinguish restoring inputs from repeating completed writes, call for
|