pi-tuck 1.1.3 → 1.3.1

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.
Files changed (86) hide show
  1. package/CHANGELOG.md +64 -0
  2. package/README.md +28 -59
  3. package/dist/index.d.ts +2 -6
  4. package/dist/index.js +16 -111
  5. package/dist/src/bash-command.d.ts +8 -0
  6. package/dist/src/bash-command.js +116 -0
  7. package/dist/src/build-id.d.ts +1 -1
  8. package/dist/src/build-id.js +1 -1
  9. package/dist/src/compaction.d.ts +2 -103
  10. package/dist/src/compaction.js +20 -140
  11. package/dist/src/diagnostic-replay.js +3 -3
  12. package/dist/src/diagnostics.d.ts +3 -2
  13. package/dist/src/diagnostics.js +30 -9
  14. package/dist/src/history-tools.js +3 -3
  15. package/dist/src/kept-reads.d.ts +2 -2
  16. package/dist/src/kept-reads.js +35 -8
  17. package/dist/src/kept-searches.d.ts +11 -0
  18. package/dist/src/kept-searches.js +202 -0
  19. package/dist/src/ledger.d.ts +1 -1
  20. package/dist/src/ledger.js +5 -3
  21. package/dist/src/legacy-cleanup.d.ts +3 -0
  22. package/dist/src/legacy-cleanup.js +190 -0
  23. package/dist/src/notify.d.ts +3 -0
  24. package/dist/src/notify.js +13 -0
  25. package/dist/src/omissions.d.ts +1 -1
  26. package/dist/src/omissions.js +3 -3
  27. package/dist/src/path-key.d.ts +3 -0
  28. package/dist/src/path-key.js +8 -0
  29. package/dist/src/request-capacity.js +1 -1
  30. package/dist/src/run.d.ts +1 -3
  31. package/dist/src/run.js +3 -5
  32. package/dist/src/source-export.d.ts +1 -1
  33. package/dist/src/source-export.js +1 -1
  34. package/dist/src/status.d.ts +0 -6
  35. package/dist/src/status.js +1 -6
  36. package/dist/src/tuck/core/content.d.ts +0 -11
  37. package/dist/src/tuck/core/content.js +5 -55
  38. package/dist/src/tuck/core/keyword-query.d.ts +2 -2
  39. package/dist/src/tuck/core/keyword-query.js +1 -1
  40. package/dist/src/tuck/core/search-entries.d.ts +5 -28
  41. package/dist/src/tuck/core/search-entries.js +14 -156
  42. package/dist/src/tuck/core/transcript.js +2 -1
  43. package/dist/src/tuck.d.ts +7 -15
  44. package/dist/src/tuck.js +409 -409
  45. package/dist/src/windows-private-storage.d.ts +9 -0
  46. package/dist/src/windows-private-storage.js +90 -0
  47. package/index.ts +18 -82
  48. package/package.json +5 -8
  49. package/src/bash-command.ts +59 -0
  50. package/src/build-id.ts +1 -1
  51. package/src/compaction.ts +19 -107
  52. package/src/diagnostic-replay.ts +3 -3
  53. package/src/diagnostics.ts +24 -9
  54. package/src/history-tools.ts +3 -3
  55. package/src/kept-reads.ts +27 -10
  56. package/src/kept-searches.ts +163 -0
  57. package/src/ledger.ts +5 -3
  58. package/src/legacy-cleanup.ts +134 -0
  59. package/src/notify.ts +10 -0
  60. package/src/omissions.ts +3 -3
  61. package/src/path-key.ts +9 -0
  62. package/src/request-capacity.ts +1 -1
  63. package/src/run.ts +4 -6
  64. package/src/source-export.ts +1 -1
  65. package/src/status.ts +1 -10
  66. package/src/tuck/core/content.ts +4 -52
  67. package/src/tuck/core/keyword-query.ts +2 -2
  68. package/src/tuck/core/search-entries.ts +15 -202
  69. package/src/tuck/core/transcript.ts +2 -1
  70. package/src/tuck.ts +350 -357
  71. package/src/windows-private-storage.ts +94 -0
  72. package/dist/src/assets.d.ts +0 -58
  73. package/dist/src/assets.js +0 -80
  74. package/dist/src/eligibility-cache.d.ts +0 -19
  75. package/dist/src/eligibility-cache.js +0 -33
  76. package/dist/src/semantic-recall.d.ts +0 -422
  77. package/dist/src/semantic-recall.js +0 -1386
  78. package/dist/src/setup.d.ts +0 -3
  79. package/dist/src/setup.js +0 -191
  80. package/scripts/eg2-runtime.py +0 -307
  81. package/scripts/provision-eg2.py +0 -139
  82. package/scripts/semantic-worker.py +0 -234
  83. package/src/assets.ts +0 -92
  84. package/src/eligibility-cache.ts +0 -43
  85. package/src/semantic-recall.ts +0 -592
  86. package/src/setup.ts +0 -163
package/CHANGELOG.md CHANGED
@@ -3,6 +3,70 @@
3
3
  All notable changes to pi-tuck. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and versions follow
4
4
  [Semantic Versioning](https://semver.org/).
5
5
 
6
+ ## [1.3.1] - 2026-11-15
7
+
8
+ ### Changed
9
+
10
+ - **Same code as 1.3.0**, which never reached npm: a timing check in the test suite stopped its publish on the release runner. The check now
11
+ bounds only cells with at least 3 cuts. Everything listed under 1.3.0 ships in this version.
12
+
13
+ ## [1.3.0] - 2026-11-15
14
+
15
+ ### Added
16
+
17
+ - **Kept searches.** A cut's summary now also keeps the latest output of a `grep` or `rg` search (per command, at most 4), alongside the
18
+ kept reads, while nothing the search lists has changed since: a later write or edit of a listed file, or a shell command that is not
19
+ read-only and names one, drops it. Searches with shell syntax pi-tuck cannot classify are never kept. Kept searches share kept reads'
20
+ space in the summary, so the summary's size target is unchanged. In a 10-task paired live gate against 1.2.0's line (NVIDIA Nemotron,
21
+ room 16,384), the agent repeated a search after a cut 0.23 times per cut against 0.45, and resolved 5 tasks the other build missed
22
+ against 2, with no refusals, lost tasks or error stops.
23
+
24
+ ## [1.2.0] - 2026-11-15
25
+
26
+ ### Added
27
+
28
+ - **Windows.** pi-tuck now installs and runs on Windows. Paths are compared the same way however Windows spells them (drive letter case,
29
+ backslashes, relative paths), and Windows shell commands that change files (`Set-Content`, `Remove-Item`, `del`, `move` and others)
30
+ count as changes. `/tuck-incident` creates its folder and files with private Windows permissions and refuses folders other users can read.
31
+ Tested on Windows 10 with Node 24 and Pi 1.5.2.
32
+
33
+ ### Fixed
34
+
35
+ - **Kept reads no longer quote a stale or partial file as if it were whole and current.** A cut's summary now keeps only whole reads;
36
+ a read is dropped from it when a later shell command that is not read-only names the file, or when a git command such as `checkout`,
37
+ `stash`, `restore` or `reset` ran, and paths are compared after normalising their spelling.
38
+
39
+ ### Removed
40
+
41
+ - **Semantic search and `tuck_search`.** Semantic-unique hits were 18 of 1,935 events (0.9%), against a 15% bar. The local model,
42
+ setup and downloads, worker, indexes and background indexing are gone. `tuck_recall` still provides exact reads and keyword search.
43
+
44
+ ### Changed
45
+
46
+ - **Old sessions still load, cut and recall.** Historical `tuck_search` and `vcc_search` calls remain readable; old private entries are
47
+ ignored. A leftover `semanticRecall` setting is ignored silently, and `/tuck` no longer reports semantic state.
48
+ - **Old search files are cleaned up once per machine.** Under `~/.pi/agent/pi-tuck/` (from the home directory, independent of Pi's agent-folder
49
+ setting), cleanup removes the real directories `python`, `index`,
50
+ `downloads`, `staging-<digits>` (exactly `staging-` followed by one or more digits), and `.pi-semantic-<six alphanumeric characters>`.
51
+ It removes `runtime` only when a child has a `pins.json` with pi-tuck's old pin fields, then removes the root only if empty.
52
+ Symlinks at the root or candidate paths and foreign files in the root are left in place; links inside removed directories are unlinked without
53
+ following their targets. On macOS and Linux, a directory is left alone if a live process has it open or the bounded `lsof` check fails;
54
+ Windows leaves all candidates alone. A notice names only removed directories, with the path and best-effort space freed, using stderr
55
+ without a UI. An empty `~/.pi/agent/pi-tuck-semantic-removed` marker records a completed attempt, including partial cleanup or nothing
56
+ to clean; an attempt that cannot start is retried. Once marked, a folder recreated later by another program is left alone.
57
+ `/tuck-semantic`, its stub text and the old notice are gone.
58
+
59
+ ### Release gates
60
+
61
+ - **Live gate on NIM Nemotron (10 paired tasks at room 16,384, against 1.1.2):** solved wins minus losses +1 (bar at least -1), turn-cap
62
+ stops 3 against 4, doubt moments 6 against 9, 0 lost tasks. Kept-read records quoting a partial or stale read: 0 against 141. The gate
63
+ found one false refusal after a steering message; it was fixed (1.1.3) and pinned by tests built from that run.
64
+ - **Replay against 1.1.3 (byte-identical to 1.1.2):** 29 recordings, cuts 1,975 → 1,869 and clips 16 → 8 with the smaller tool list and
65
+ the stricter kept reads; 0 lost or dead tasks, 0 faults.
66
+ - **Strict stress:** 322 cells, the resumed-session and stand-down suites and an 85 MB recall test, 0 findings. Lifecycle with 40 seeds.
67
+ Tests and CI on macOS and Ubuntu; the full suite also passed on Windows. The packed tarball loaded in the real installed Pi on macOS and
68
+ Windows.
69
+
6
70
  ## [1.1.3] - 2026-11-15
7
71
 
8
72
  ### Fixed
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # pi-tuck
2
2
 
3
- **Compaction for [Pi](https://pi.dev) with no model call, and a history the agent can search by keyword, and on Apple silicon by meaning, all on your machine.** In our 128k live run, a cut took a median 0.08 s (pi-tuck 1.0.1). It costs no tokens. The same session always gives the same summary. And nothing is lost: the agent can read back anything earlier, word for word, and on Apple silicon it can find it by meaning.
3
+ **Compaction for [Pi](https://pi.dev) with no model call, and exact recall of earlier history, all on your machine.** In our 128k live run, a cut took a median 0.08 s (pi-tuck 1.0.1). It costs no tokens. The same session always gives the same summary. And nothing is lost: the agent can read back anything earlier, word for word.
4
4
 
5
5
  ```sh
6
6
  pi install npm:pi-tuck
@@ -19,7 +19,6 @@ Pi's built-in compaction asks a model to write a summary. pi-tuck builds the sum
19
19
  | Tasks resolved at 128k (300 SWE-bench Verified tasks per arm, pi-tuck 1.0.1) | 251 of 300 | 258 of 300. The registered claim is only "no loss larger than 0.4 points"; chain s09 matters, see below |
20
20
  | Same session, same summary | Not guaranteed, since a model writes it | Yes |
21
21
  | Can the agent get dropped detail back | No recall tool in Pi 1.4.0. The full history stays in the session file, but the agent has no tool made to search it | Yes. `tuck_recall` reads any original exactly |
22
- | Search history by meaning | No | Yes, with `tuck_search`, on macOS with Apple silicon. It runs locally on your Mac's GPU, and no text leaves your machine. Elsewhere there is no `tuck_search`, and `tuck_recall` searches by keyword |
23
22
  | Can the summary invent history | It can, since a model writes it | No, it holds only recorded text |
24
23
  | What the summary leaves out | Whatever the model dropped | Tool output only; the agent reads it back exactly |
25
24
  | Tasks resolved at a 32k window (150 SWE-bench Verified tasks, one model, pi-tuck 1.0.5) | 94 of 150 | 120 of 150 (+17.3 points, 95% lower bound +10.7). Limits below the table |
@@ -38,21 +37,21 @@ A summary cannot hold everything. So pi-tuck lets the agent look things up inste
38
37
 
39
38
  > "What was the reason we dropped the retry on the token refresh?"
40
39
 
41
- The original message says "removing the backoff loop from the auth renewal". The words differ, so a keyword search finds nothing. The agent calls `tuck_search`, which also searches by meaning:
40
+ The agent searches its history by keyword with `tuck_recall`:
42
41
 
43
42
  ```json
44
- { "query": "why did we drop the retry on token refresh" }
43
+ { "query": "retry token refresh" }
45
44
  ```
46
45
 
47
- It gets back the original passage, with a pointer such as `#212`. It reads the whole message, exactly as it was written:
46
+ It gets back ranked passages with a pointer such as `#212`. It reads the whole message, exactly as it was written:
48
47
 
49
48
  ```json
50
49
  { "index": 212 }
51
50
  ```
52
51
 
53
- That is `tuck_recall`. The agent answers from the original text, not from a model's memory of it.
52
+ The agent answers from the original text, not from a model's memory of it.
54
53
 
55
- *This example is an illustration. It is not a recorded session.* The call shapes are real. **Semantic search has no measured quality numbers yet.** A test of it is pre-registered in [`benchmark/PREREG-RECALL.md`](benchmark/PREREG-RECALL.md); it has no result yet. The benchmarks below measure cut time, cost and answer retention after cuts, not how well `tuck_search` finds a passage. `tuck_search` exists only on macOS with Apple silicon. Elsewhere the agent has `tuck_recall` and its keyword search, and the example above would not find its match.
54
+ *This example is an illustration. It is not a recorded session.* The call shapes are real. Keyword recall finds a passage only by words it contains, so the question has to use words the original message used.
56
55
 
57
56
  ## Install
58
57
 
@@ -62,10 +61,9 @@ pi install npm:pi-tuck
62
61
 
63
62
  Then start a new Pi session. That is all. pi-tuck takes over Pi's compaction, both automatic and `/compact`. You change no setting.
64
63
 
65
- - Needs Pi 1.2.0 or later (tested on 1.2.0 and 1.4.0), on macOS or Linux. On an older Pi, pi-tuck stays off, Pi's own compaction runs, and pi-tuck says so once. Full features on macOS with Apple silicon; elsewhere, compaction and word recall.
66
- - On macOS with Apple silicon, the first session also downloads a local search model in the background (about 390 MB, once), and says once when it is set up. Until it is ready, search works by keyword. See [Semantic search](#semantic-search).
67
- - Prefer GitHub? `pi install git:github.com/galyavin/pi-tuck@v1.1.2`.
68
- - To pin a version, add it: `pi install npm:pi-tuck@1.1.2`.
64
+ - Needs Pi 1.2.0 or later (tested on 1.2.0 and 1.4.0), on macOS, Linux or Windows (Windows since 1.2.0, tested on Windows 10 with Node 24 and Pi 1.5.2). On an older Pi, pi-tuck stays off, Pi's own compaction runs, and pi-tuck says so once.
65
+ - Prefer GitHub? `pi install git:github.com/galyavin/pi-tuck@v1.2.0`.
66
+ - To pin a version, add it: `pi install npm:pi-tuck@1.2.0`.
69
67
 
70
68
  ## Uninstall
71
69
 
@@ -73,13 +71,7 @@ Then start a new Pi session. That is all. pi-tuck takes over Pi's compaction, bo
73
71
  pi remove npm:pi-tuck
74
72
  ```
75
73
 
76
- Use the same source you installed with. This takes pi-tuck out of Pi's settings. It does not delete what the search setup downloaded: about 460 MB in the `pi-tuck` folder of Pi's agent folder (`~/.pi/agent/pi-tuck`, or the folder `PI_CODING_AGENT_DIR` names). To free the space, delete that folder:
77
-
78
- ```sh
79
- rm -rf ~/.pi/agent/pi-tuck
80
- ```
81
-
82
- On Linux and Intel Macs, nothing is downloaded, so there is nothing to delete.
74
+ Use the same source you installed with. This takes pi-tuck out of Pi's settings. pi-tuck downloads nothing, so there is nothing else to delete, apart from incident records if you turned `/tuck-incident` on: they are in `~/.local/state/pi-tuck-incidents`. Versions before 1.2.0 downloaded about 460 MB of files for a search feature that has been removed. pi-tuck deletes those old files itself, once per machine, the first time 1.2.0 starts, and a notice names the folders it removed. On Windows it leaves them alone, so delete `~/.pi/agent/pi-tuck` yourself if it exists.
83
75
 
84
76
  ## How it works
85
77
 
@@ -87,24 +79,22 @@ When context fills up, pi-tuck replaces the older turns with one summary. The su
87
79
 
88
80
  - **The dialogue and your prompts, ranked.** Since 1.0.18, one ranked list decides what a cut carries, across the summary and the kept tail together: the current prompt, whole; the openings of the first prompt and the newest answered prompts, sized to the room; the newest part of the conversation, kept as it is; the file and action lists below; and the rest of the conversation. Dropped turns and tool results are counted with index ranges that `tuck_recall` reads back. Clipped text says how to read it in full.
89
81
  - **The files.** Files the agent read, wrote or edited, newest first (up to 60), each with a pointer to read it back.
90
- - **Kept reads** (1.1.0 and later). After the Files list, the summary carries the newest whole read of each file that has no later write or edit, headed `read PATH (as recorded at #N; no write or edit recorded since):`. It keeps at most 4 files, whole outputs only, within 20% of the summary's room and never more than 24,000 characters. When the summary is over its target, these records are dropped first, oldest first. With no such reads the summary is unchanged, and tool outputs are never touched. The header says only that no write or edit was recorded since the read; it does not say the file on disk is unchanged. After a cut, agents often doubted what an earlier read had shown and read the same file again, and this is meant to spare that. It has no effectiveness result yet; see Benchmarks.
82
+ - **Kept reads** (1.1.0 and later). After the Files list, the summary carries the newest whole read of each file that has no later write or edit, headed `read PATH (as recorded at #N; no write or edit recorded since):`. It keeps at most 4 files, whole outputs only, within 20% of the summary's room and never more than 24,000 characters. Since 1.2.0, a read is also dropped from the summary when a later shell command that is not read-only names the file, or when a git command such as `checkout`, `stash`, `restore` or `reset` ran, and paths are compared after normalising their spelling. When the summary is over its target, these records are dropped first, oldest first. With no such reads the summary is unchanged, and tool outputs are never touched. The header says only that no write or edit was recorded since the read; it does not say the file on disk is unchanged. After a cut, agents often doubted what an earlier read had shown and read the same file again, and this is meant to spare that. It has no effectiveness claim; see Benchmarks.
91
83
  - **The action trail.** The agent's other tool calls, such as shell commands, newest first (up to 30). The output is left out. A pointer leads to it.
92
84
 
93
85
  Tool output stays in the session file, not in the summary. Each summary ends with a short instruction to the agent: re-read a file before you edit it, look things up, and treat anything not shown as unknown.
94
86
 
95
87
  The summary is plain text, one line per record, such as `#12 user @2026-10-30T14:00:00Z: text`. The number is the index that `tuck_recall` takes. Summaries from earlier versions are still read.
96
88
 
97
- The agent gets two tools to get anything back:
89
+ The agent gets one tool to get anything back:
98
90
 
99
91
  - **`tuck_recall`** finds earlier text by keyword. It reads any original message or tool result exactly, by the index shown in a summary. It can also write an original out to a file.
100
- - **`tuck_search`** (macOS with Apple silicon only) finds earlier history related to a question, even when the wording differs. It combines keyword hits with local semantic search and returns the original text with pointers for `tuck_recall`.
101
92
 
102
- pi-tuck's tools appear only after its first cut. Before that there is nothing out of view to recall, and a request is byte-identical to one without pi-tuck (254 of 254 requests on replay). After the first cut, on Apple silicon, both tools cost about 1,050 tokens of tool description per request. Elsewhere only `tuck_recall` is offered.
93
+ pi-tuck's tool appears only after its first cut. Before that there is nothing out of view to recall, and a request is byte-identical to one without pi-tuck (254 of 254 requests on replay).
103
94
 
104
95
  | Command | Does |
105
96
  |---|---|
106
- | `/tuck` | Says in words what pi-tuck is doing in this session: the version this session loaded (an open session keeps it until Pi restarts), how many cuts and retries pi-tuck made and the last cut's size before and after, whether the cut point adapts or is fixed by `cutAt`, how search works here, and, since 1.1.1, `standing down:` with the reason when pi-tuck is not acting. It is for you; the model sees nothing new. |
107
- | `/tuck-semantic on\|off\|status` | Turns semantic search on or off for this session, or shows its state. |
97
+ | `/tuck` | Says in words what pi-tuck is doing in this session: the version this session loaded (an open session keeps it until Pi restarts), how many cuts and retries pi-tuck made and the last cut's size before and after, whether the cut point adapts or is fixed by `cutAt`, and, since 1.1.1, `standing down:` with the reason when pi-tuck is not acting. It is for you; the model sees nothing new. |
108
98
  | `/tuck-incident on\|next\|off\|status` | Records this session's compaction decisions to a file you can attach to a bug report. |
109
99
 
110
100
  Since 1.1.1, pi-tuck stands down to native Pi when it cannot do its job safely: with an unknown context window (0, missing or not a number), with a Pi virtual model, or with Pi's auto-compaction turned off. It then does exactly what native Pi does, and `/tuck` says `standing down:` with the reason. Refusal, overflow and manual-cut notices also reach stderr when there is no UI (`pi -p`, JSON runs), as the output-limit notice already did.
@@ -132,22 +122,21 @@ Known limits today:
132
122
  - Small window, after a stopped run (1.0.8 and 1.0.9 only; fixed in 1.0.10): Pi's default `compaction.keepRecentTokens` (20,000) can exceed pi-tuck's input room, which was the window less the larger of `compaction.reserveTokens` and the model's maximum output (16,384 at a 32k window with the default reserve). After a run that is stopped (Esc, or a time limit) with the context above the room, every later prompt could be refused with "The request needs a cut and Pi has none to make (Nothing to compact (session too small))", and the session stayed stuck. In one check at these defaults (pi-tuck 1.0.8, 32k window, one session of 30 tasks, one local model), 28 tasks were lost, tasks 3 to 30 ([`benchmark/RESULTS-DEFAULTS.md`](benchmark/RESULTS-DEFAULTS.md)). If you are on 1.0.8 or 1.0.9, upgrade to 1.0.10. In 1.0.10 the cut a prompt needs is pi-tuck's own, so `keepRecentTokens` no longer leaves it with nothing to cut. A rerun of the same check on the 1.0.10 candidate had no refusal and no stuck session. It had two caveats: two of its tasks had a first request the local server never answered, and 8 of its 30 tasks began without their prompt, which the refusal counter cannot see (fixed in 1.0.12; see Benchmarks and [`benchmark/RESULTS-DEFAULTS-1010.md`](benchmark/RESULTS-DEFAULTS-1010.md)). Windows of 128k and up were not affected at the defaults.
133
123
  - A prompt could be lost, with no notice (1.0.10 and 1.0.11; fixed in 1.0.12). When a new prompt arrived over the cut point and pi-tuck's cut kept nothing of the conversation before it, which happens when everything since the last cut is one long turn, the prompt was dropped from the request and from the saved session. The model never saw it and usually went on with the previous task, so work you asked for could be lost, and could look answered. The next prompt ran normally. If you used 1.0.10 or 1.0.11 and a reply ignored what you had just asked, this is the likely cause. Upgrade to 1.0.12 ([`CHANGELOG.md`](CHANGELOG.md) 1.0.12).
134
124
  - A host that patches a large section into the system prompt could get a refusal that a cut would have fit (1.0.0 to 1.0.16; fixed in 1.0.17). pi-tuck plans a prompt's cut when the prompt arrives, before other extensions change the system prompt. A host engine that adds a section of thousands of tokens for one turn could push that turn's first request over the room, and the final guard refused it. Now the guard plans the cut against the system prompt as finally sent, and refuses only if that cut does not fit either ([`CHANGELOG.md`](CHANGELOG.md) 1.0.17).
135
- - Semantic recall never started in `pi -p` (1.0.0 to 1.0.20; fixed in 1.0.21). pi-tuck skipped semantic recall whenever Pi ran with no UI, to keep a one-shot run from starting the first-time download, and that also skipped a runtime that was already installed. Jobs run with `pi -p` searched by keyword only, while `tuck_search` said semantic recall was being set up. RPC mode was not affected ([`CHANGELOG.md`](CHANGELOG.md) 1.0.21).
136
125
  - pi-tuck refused requests that fit the window, and could strand a session (1.0.0 to 1.0.21; fixed in 1.0.22). It refused at the room, the window less the full reply reserve, where native Pi still sends. With Pi's defaults and a large setup, a session could be refused at every prompt. The final refusal now sits at the window less a reply floor ([`CHANGELOG.md`](CHANGELOG.md) 1.0.22).
137
126
  - pi-tuck 1.0.25 failed to load in an installed Pi ("Cannot find module '@earendil-works/pi-ai/utils/estimate'"); fixed in 1.0.26, and 1.0.25 is deprecated. Since 1.0.23, the check of Pi's own reply cap also never ran in an installed Pi, for the same reason: Pi's extension loader resolves only a few pi-ai entry points for an installed package. It loaded only in tests and the eval harness, and the installed package fell back to the same 4,096-token margin without it. Fixed in 1.0.26, which was loaded in a real installed Pi before publishing ([`CHANGELOG.md`](CHANGELOG.md) 1.0.26).
138
127
  - A request above the room could be admitted and then refused, leaving the session stuck where native Pi would have sent (1.0.22 to 1.0.24; fixed in 1.0.25). pi-tuck checked its line in its own corrected token count, while Pi's reply cap uses Pi's own estimate, which is higher when the provider counts fewer tokens than pi-tuck's raw measure ([`CHANGELOG.md`](CHANGELOG.md) 1.0.25).
139
128
  - Near the 1.0.22 refusal line, replies were cut to a few hundred tokens (1.0.22; fixed in 1.0.23). 1.0.22 left only its reply floor and did not count Pi's 4,096-token margin on the reply cap ([`CHANGELOG.md`](CHANGELOG.md) 1.0.23).
140
129
  - Cost of the 1.0.22 change: between the room and the window, the reply reserve no longer cushions a wrong count. At a cold start an undercount can reach the provider. A provider that errors is caught and learned from; a server that truncates silently truncates, as it does for native Pi. With a setup above the room, cuts are forced and frequent, each freeing little, which beats a stranded session ([`CHANGELOG.md`](CHANGELOG.md) 1.0.22).
130
+ - Fixed in 1.2.0: kept reads could quote a stale or partial file as if it were whole and current. A cut's summary now keeps only whole reads, and drops a read when a later shell command that is not read-only names the file, or when a git command such as `checkout`, `stash`, `restore` or `reset` ran. In the live gate, kept-read records quoting a partial or stale read were 0 against 141 ([`CHANGELOG.md`](CHANGELOG.md) 1.2.0).
131
+ - Fixed in 1.1.3: a steering message after a very large tool round could end the run with a false refusal. When the user or a harness sent a message while the agent was working, right after a round of tool results too large for the window, pi-tuck planned that cut as if a new run were starting. The summary could then leave out the prompt that started the run, and pi-tuck's own prompt check refused with "the request is missing the whole text of the prompt that started this run". The cut now keeps the running task's prompt and the fresh tool round, as a cut at a tool boundary does ([`CHANGELOG.md`](CHANGELOG.md) 1.1.3).
141
132
  - Fixed in 1.1.1: a resumed session forgot what pi-tuck had learned about the provider's token counts. pi-tuck saved its calibration only inside a cut, so after quitting and resuming Pi before the next cut it counted at 1x again and could send a request the provider truncated or refused, where native Pi succeeded. pi-tuck now saves a small private entry in the session when what a resume would learn changes, not every turn, and reads it back on resume. The entry never reaches the model ([`CHANGELOG.md`](CHANGELOG.md) 1.1.1).
142
- - Fixed in 1.1.1: pi-tuck refused prompts that native Pi would have sent when the context window was unknown, the model was a Pi virtual model, or Pi's auto-compaction was turned off. It now stands down to native in those cases. Also fixed in 1.1.1: refusal, overflow and manual-cut notices were silent without a UI, so a run in `pi -p` or JSON mode could end with no word; the semantic search status could claim "ready" when it was turned off or had failed; and a retry after a reply hit the output limit skipped a check that a pending cut had really been saved in the session ([`CHANGELOG.md`](CHANGELOG.md) 1.1.1).
133
+ - Fixed in 1.1.1: pi-tuck refused prompts that native Pi would have sent when the context window was unknown, the model was a Pi virtual model, or Pi's auto-compaction was turned off. It now stands down to native in those cases. Also fixed in 1.1.1: refusal, overflow and manual-cut notices were silent without a UI, so a run in `pi -p` or JSON mode could end with no word; and a retry after a reply hit the output limit skipped a check that a pending cut had really been saved in the session ([`CHANGELOG.md`](CHANGELOG.md) 1.1.1).
143
134
  - Fixed in 1.0.33: a file read's recall number pointed at the read call, not at what the read returned. The summary lists each file the session read with a `tuck_recall` number, and that number brought back the call's arguments instead of the file's contents, so recalling a read cost a turn and showed nothing useful. It now brings back the read's output ([`CHANGELOG.md`](CHANGELOG.md) 1.0.33).
144
- - Fixed in 1.0.32: background indexing never started at the cuts pi-tuck makes itself. Pi announces only its own compactions, so cuts pi-tuck saved after a tool round, at the end of a run, or before retrying a reply that hit the output limit started no indexing ([`CHANGELOG.md`](CHANGELOG.md) 1.0.32).
145
135
  - Fixed in 1.0.31: input that arrived after a tool round had been checked, such as another extension's context or a newly enabled tool, could push the next request past the hard line, and the final check refused a request that pi-tuck could still cut. It now cuts at that check, carries the cut in that request, saves it at the next boundary, and refuses only when no cut can fit ([`CHANGELOG.md`](CHANGELOG.md) 1.0.31).
146
136
  - Fixed in 1.0.29, when Pi's configured window was larger than the server's: a session could get stuck after one overflow, because pi-tuck mistook a cut Pi had saved for one Pi had failed to save. And a server that silently shrinks the reply to fit its real window went unnoticed, so pi-tuck answered fewer prompts than plain Pi. A reply that stops for length below the reply cap Pi sent is now read as the server's real window: pi-tuck learns it, keeps it for the model in the session, plans with the smaller window, and retries that turn once ([`CHANGELOG.md`](CHANGELOG.md) 1.0.29).
147
- - 1.0.28 moved each piece of state that had several owners to one owner: the pending cut, the run, reply fit and semantic setup. Requests were unchanged. It also fixed a plan made for a prompt that another extension handled, which could still answer Pi's own compaction check before a later run and make a cut deeper than needed ([`CHANGELOG.md`](CHANGELOG.md) 1.0.28).
137
+ - 1.0.28 moved each piece of state that had several owners to one owner: the pending cut, the run and reply fit. Requests were unchanged. It also fixed a plan made for a prompt that another extension handled, which could still answer Pi's own compaction check before a later run and make a cut deeper than needed ([`CHANGELOG.md`](CHANGELOG.md) 1.0.28).
148
138
  - A run that a custom message started could lose that message after a cut in the middle of the run (fixed in 1.0.27). pi-tuck protected only a prompt the user typed, so a tool-loop cut in a run an extension started with a custom message kept the message neither whole nor quoted, and later requests lacked the instruction that started the run. Now such a message gets the same protection as a typed prompt: it is kept, or quoted whole in the summary, and the guard checks it. A custom message with no text has nothing to quote and stays unprotected ([`CHANGELOG.md`](CHANGELOG.md) 1.0.27).
149
139
  - A prompt's cut could reach a run it was not planned for (fixed in 1.0.24). pi-tuck plans a prompt's cut when the prompt arrives. When another extension handled that prompt, no run started, and the plan waited for the next run. A run started by a custom message carried a cut sized for the prompt that never ran, deeper than needed. After a move in the session tree (`/tree`), the plan was applied on the new branch, where its kept entry was not present, so the request lost the custom message that started the run, even on a branch that needed no cut ([`CHANGELOG.md`](CHANGELOG.md) 1.0.24).
150
- - Four `tuck_search` faults, fixed in 1.0.23: it said semantic recall was still indexing when the history was fully indexed; in the turn after a prompt's cut it ranked nothing ("nothing is out of view"); a keyword-search timeout on a very long history failed the whole search, where now the semantic results still answer; and the timeout message named a pattern instead of the history's size ([`CHANGELOG.md`](CHANGELOG.md) 1.0.23).
151
140
  - pi-tuck cut earlier than native Pi when a model's reply cap is above Pi's reserve (1.0.0 to 1.0.19; fixed in 1.0.20). It reserved the larger of Pi's `compaction.reserveTokens` and the model's `maxTokens`: with `maxTokens` 32,768 and a reserve of 16,384 on an 81,920 window, its room fell to 49,152 tokens, where native Pi compacts at 65,536 ([`CHANGELOG.md`](CHANGELOG.md) 1.0.20).
152
141
  - A summary could drop the task a session was working on (1.0.0 to 1.0.17; fixed in 1.0.18). Until 1.0.15 a summary quoted only the session's first user turn, up to 12,000 characters, and the newest one, so in a long session the current task, an older turn followed by short steps, was clipped or dropped while a finished first task stayed whole, and agents acted on a days-old task. 1.0.16 added more quotes. From 1.0.13 to 1.0.17, separate rules decided what a summary quoted and what the kept tail held, and the prompt that set the current task, or the first prompt, could lose its opening after a cut: the stress test found it 40 times in 32 cells on 1.0.16 and 1.0.17. Since 1.0.18 one ranked list fills a cut's room, and the stress test finds no lost opening in 287 cells. Short sessions, and the SWE-bench chains behind our benchmarks, keep each task's prompt in the kept tail and never hit it. Upgrade to 1.0.18 ([`CHANGELOG.md`](CHANGELOG.md) 1.0.18).
153
142
  - pi-tuck 1.0.16 cost more in live chains than its notes first said. Against 1.0.13 at an 81,920 window, it took 1.48 times the turns on the tasks both resolved (95% interval 1.34 to 1.64), 74% more cuts and 1.66 times the tokens, with 56 of 60 tasks resolved against 55. Replay of single-task sessions cannot show this cost. 1.0.18 replaced its quote rules; in the 1.0.18 gate it took 22.27 turns per task against 29.35 for 1.0.16 and 20.22 for the 1.0.13 arm (different pairs of runs; reported, not claimed) ([`benchmark/RESULTS-V1016.md`](benchmark/RESULTS-V1016.md), [`CHANGELOG.md`](CHANGELOG.md) 1.0.18).
@@ -155,7 +144,6 @@ Known limits today:
155
144
  - The cut point adapts by itself since 1.0.13; before it, pi-tuck cut too often at small windows or with a large setup (1.0.11 and 1.0.12). The trade, from the changelog: on windows that cut too often, each request now carries more context. Cuts, re-processing and request time fall, and billed tokens rise on paid models. On replay of real sessions at an 81,920 window, cuts went from 22.3 to 9.3 per 100 requests, request time was about 16 to 20% lower, and billed tokens were 16 to 19% higher; at a 65,536 window billed tokens rose by as much as 35%. A very large setup at a small window, such as 40k at 65,536, still leaves too little free room for a good rhythm: cuts stay frequent and free little ([`CHANGELOG.md`](CHANGELOG.md) 1.0.13).
156
145
  - Still applying (1.0.11 to 1.0.16): a fresh assistant message larger than the free room is refused, and a short next prompt recovers (in an unattended `pi -p` run, a refusal ends the run). A reply that reports more than the window reads to Pi as a silent overflow; when nothing can be cut, pi-tuck refuses the next prompt, and the prompt after that runs. If a provider keeps rejecting requests in a wording Pi does not class as a context overflow, or with a bare HTTP 413, pi-tuck does not recover on its own: the session stays intact, and every prompt can fail until the request shrinks. Try `/compact` ([`CHANGELOG.md`](CHANGELOG.md) 1.0.13).
157
146
  - Other extensions (1.0.10): a prompt's cut no longer goes through Pi's `session_before_compact`, so another extension's veto there no longer stops it. It never stopped a cut between tool rounds. Pi's own threshold and overflow cuts, and `/compact`, still ask other extensions as before.
158
- - Semantic search (`tuck_search`) needs a Mac with Metal (Apple silicon). Elsewhere, compaction and `tuck_recall`'s word search work, there is no `tuck_search`, and nothing is downloaded.
159
147
 
160
148
  ## Benchmarks
161
149
 
@@ -166,15 +154,16 @@ Each row says what was measured, under which conditions, and where the data is.
166
154
  | Pi's default compaction settings, 32k window, pi-tuck 1.0.10 candidate | Passed as registered: 0 dead tasks and 0 stuck sessions on 30 tasks, on a slow local server (27 of 30 tasks hit the 30-minute wall cap, and 2 had a first request the server never answered). 6 resolved. A counter written later, which counts a task with no token as dead, would count those 2. **The registered counter counts refusals and cannot see a task that began without its prompt**: in 8 of the 30 tasks (4, 8, 9, 10, 13, 14, 17, 21) a cut at the prompt kept no turn, none of the 8 resolved, and 6 ended with an empty patch. So the pass shows no refusal, not that every task began with its prompt. The 1.0.11 candidate on the same test had 7 of 30 such tasks, 1 resolved. Fixed in 1.0.12 | Candidate `a67ec30` of 1.0.10, `mac-studio/main`, window 32,768, output cap 16,384, Pi's default `reserveTokens` 16,384 and `keepRecentTokens` 20,000, one session of chain t06. One mid-run refusal (a round with 9,020 tokens of reasoning against the 16,384-token room). One session per arm, one model. In 12 of the 15 tasks across both arms the model's own first messages show it lacked the prompt; the other 3 are not clear from the records | [`benchmark/RESULTS-DEFAULTS-1010.md`](benchmark/RESULTS-DEFAULTS-1010.md) |
167
155
  | Pi's default compaction settings, 32k window, pi-tuck 1.0.8 | 28 of 30 tasks lost (tasks 3 to 30, each refused at its prompt); 1 resolved. Fails the pre-registered bar of 0 lost tasks | pi-tuck 1.0.8 (`86935e9`), `mac-studio/main`, window 32,768, output cap 16,384, `reserveTokens` 16,384 and `keepRecentTokens` 20,000 (larger than the room), one session of chain t06. One session, one model, one build: it shows that the failure occurs at these settings, not how often. Not comparable with other rows | [`benchmark/RESULTS-DEFAULTS.md`](benchmark/RESULTS-DEFAULTS.md) |
168
156
  | Tasks resolved, 32k window | Pi's built-in compaction 94 of 150; pi-tuck 120 of 150 (+17.3 points, 95% lower bound +10.7); observation masking 117 of 150 (pi-tuck +2.0, lower bound −2.7: no difference shown). Turns per task: 9.4 (built-in), 24.0 (pi-tuck), 11.9 (masking). Tokens per session: 6.10 M, 6.39 M, 7.02 M. Spend per arm for the five sessions: $0.87, $0.55, $0.94 | pi-tuck 1.0.5 (commit `aa30824`, the 1.0.5 code; 1.0.6 and 1.0.7 are not measured). DeepSeek V4.1 Flash pinned to one upstream, window 32,768, reserve 16,384, 5 chains of 30 SWE-bench Verified tasks, paired by task, one-sided bootstrap over tasks. **Limits:** only pi-tuck is held to the 16,384-token room (the built-in sent a request over it in 97 of 150 tasks, masking in 73, so the window is nominal for them). The difference by chain is +10.0, −3.3, +50.0, +16.7 and +13.3 points; leaving out chain t03 it is +9.2. The bootstrap resamples tasks, not chains. The pi-tuck arm ran at a different time from the others. One model, one window. pi-tuck refused to cut mid-run in 5 tasks, where one fresh tool result was larger than the room; they count as unresolved. In the same setup pi-tuck 1.0.3 resolved 72 of 150, with 52 dead tasks (tasks refused at their prompt after an earlier failure). In the pi-tuck arm of this row there was 1 dead task (t03 task 24: refused at its prompt with "Nothing to compact"; the next task ran normally), so this build missed the pre-registered acceptance bar of zero dead tasks by one task (the other part of the bar, no loss against 1.0.3 by more than 3 points, was met) | [`benchmark/RESULTS-32K-ACCEPT.md`](benchmark/RESULTS-32K-ACCEPT.md) |
157
+ | pi-tuck 1.2.0: live gate against 1.1.2, and replay against 1.1.3 | Live gate, 10 paired tasks at room 16,384: solved wins minus losses +1 (bar: at least −1), turn-cap stops 3 against 4, doubt moments 6 against 9, 0 lost tasks; kept-read records quoting a partial or stale read 0 against 141. Replay against 1.1.3 (byte-identical to 1.1.2): 29 recordings, cuts 1,975 to 1,869 and clips 16 to 8 with the smaller tool list and the stricter kept reads, 0 lost or dead tasks, 0 faults | Ten tasks on NIM Nemotron, one model, one room, one run per arm: no effectiveness claim is made. The gate found one false refusal after a steering message, fixed in 1.1.3 and pinned by tests built from that run. Strict stress: 322 cells, 0 findings. Tests and CI on macOS and Ubuntu; the full suite also passed on Windows | [`CHANGELOG.md`](CHANGELOG.md) 1.2.0 |
169
158
  | Kept reads (1.1.0): 5-task check against 1.0.31, and replay against 1.0.33 | No breakage in 5 of 5 tasks, and all 5 solved on both builds. Re-checks after a doubt 22 against 45; doubt moments 9 against 24; cuts 22 against 26; turns 305 against 384. One heavy task went worse: 90 turns against 59, 9 cuts against 4, 3 doubts against 1. Replay against 1.0.33: 13,946 requests, 0 lost or dead tasks, clips 17 to 16, cuts 1,946 to 1,971; in every recording that differs, the first difference is the first summary carrying a kept read, and 11 of 29 never differ | Five tasks, before the Tier 1. This is not an effectiveness result and no effectiveness claim is made for kept reads. The Tier 1 against 1.0.33 is still running; if it fails, npm and installs go back to 1.0.33. Strict stress: 0 findings in 313 cells on Pi 1.2.0 and the newest Pi | [`CHANGELOG.md`](CHANGELOG.md) 1.1.0 |
170
159
  | pi-tuck 1.0.18 against the recorded 1.0.16 arm, 81,920 window | Registered bar (Tier 1) met: both arms resolved the same 56 of 60 tasks (+0.0 points, one-sided 95% lower bound +0.0, against a bar of above −10); 0 lost tasks: dead tasks, mid-run refusals and dropped prompts are 0 in both arms, and the audit listed one candidate task (t06 task 21), which, with the two other candidate tasks that had a cut at a prompt (t06 task 8, t07 task 24), was read by hand and works on its own task. Readouts: turns per task 22.27 against 29.35, cuts 57 against 61, total tokens 40.3 M against 62.1 M. Against the recorded 1.0.13 arm of the adaptive gate, a different pair of runs a day apart, 1.0.18 is at 22.27 turns per task against 20.22 and 40.3 M tokens against 37.4 M | Pre-registered gate. pi-tuck 1.0.18 (`2d1f830`, tag `v1.0.18`), run from the unpacked npm tarball; its `src/` is byte-identical to `1ea1e1e`, the commit replay and the stress test measured, ran alone on chains t06 and t07 (60 tasks) against the recorded 1.0.16 arm; the arms did not run side by side, the base earlier the same day, so seconds are not compared. One model, one window, one run per arm. The resolved result is a bound, not a gain. The turn, cut and token readouts are reported, not claimed | [`benchmark/RESULTS-V1018.md`](benchmark/RESULTS-V1018.md) |
171
160
  | pi-tuck 1.0.16 against the recorded 1.0.13 arm, 81,920 window | Registered bar (Tier 1) met: resolved 56 of 60 against 55 (+1.7 points, one-sided 95% lower bound +0.0, against a bar of above −10); 0 lost tasks. Readouts: turns per task 29.35 against 20.22 (1.48 times on the 55 tasks both resolved, 95% interval 1.34 to 1.64), cuts 61 against 35, total tokens 62.1 M against 37.4 M | Pre-registered gate. pi-tuck 1.0.16 (`dee0eab`) ran alone on chains t06 and t07 (60 tasks) against the recorded 1.0.13 arm from the adaptive gate; the two arms did not run side by side, the base a day earlier, so seconds are not compared. One model, one window, one run per arm. The resolved result is a bound, not a gain. The cost readouts are reported, not claimed. 1.0.18 replaced this build's quote rules | [`benchmark/RESULTS-V1016.md`](benchmark/RESULTS-V1016.md) |
172
161
  | The adaptive cut point (1.0.13) against 1.0.12, 81,920 window | Registered bar (Tier 2) met: resolved 131 of 150 in both arms (+0.0 points, one-sided 95% lower bound −1.3, against a bar of above −5); 0 lost tasks in the candidate arm. The 0 counts dead tasks, tasks whose prompt was dropped at a cut, and tasks an audit found started without their prompt; all 11 tasks with a cut at a prompt, in both arms, were also read by hand, and in each the model's first messages work on that task | Pre-registered gate. pi-tuck 1.0.13 (`6f13685`) is the exact code the gate measured (`882f6f6`); only the version and the notes changed. It was measured against pi-tuck 1.0.12, `mac-studio/main` at xhigh, window 81,920, reserve 16,384, `keepRecentTokens` 20,000, 5 chains (t06 to t10) of 30 tasks, 150 paired tasks, one run per arm, one model throughout. The resolved result is a bound, not a gain. Turns, tokens and seconds are in the file and are not claimed here. Nothing about other windows, models or builds | [`benchmark/RESULTS-ADAPTIVE.md`](benchmark/RESULTS-ADAPTIVE.md) |
173
162
  | The 1.0.10 candidate against 1.0.9, 32k window | 0 dead tasks in both arms; no mid-run refusal. Resolved 50 of 60 (1.0.9) and 49 of 60 (1.0.10 candidate): −1.7 points, 95% lower bound −8.3. **The gate failed as registered, by one task**; 1.0.10 shipped as an exception because of the small-window defect. 6 of the 1.0.10 candidate's 60 tasks began without their prompt (4 of them resolved), against 0 in the 1.0.9 arm; fixed in 1.0.12. Turns per task 25.08 and 29.12; cuts 731 and 884; total tokens 13.07 M and 15.12 M | Pre-registered gate. pi-tuck `a67ec30` against 1.0.9 (`cd4626b`). DeepSeek V4.1 Flash pinned to one upstream, window 32,768, reserve 16,384, `keepRecentTokens` 3,333, chains t01 and t02, 60 paired tasks. One model, one window, one run per arm; 60 tasks cannot separate a one-task difference from run-to-run variation | [`benchmark/RESULTS-V110.md`](benchmark/RESULTS-V110.md) |
174
- | The 1.0.8 candidate against 1.0.7, 32k window | 0 dead tasks in both arms. Resolved 46 of 60 in both (+0.0 points, 95% lower bound −6.7). No mid-run refusal in either arm. Turns per task 25.37 (1.0.7) and 26.10 (1.0.8) | Pre-registered gate, passed as registered. pi-tuck `a2e7d1a` (the tool-result clip and the cut at the end of a run, on 1.0.6) against 1.0.7. Released 1.0.8 is that build merged with 1.0.7's Metal-only recall; its replay requests are reported byte-identical to the gated build on 29 recordings (stated in the source file, not re-run for this README). DeepSeek V4.1 Flash pinned to one upstream, window 32,768, reserve 16,384, chains t01 and t02, 60 paired tasks, both arms run together. One model, one window, one run per arm; 60 tasks cannot show a difference smaller than the bound. The run shows that the change introduced no refusal; no refusal occurred in the 1.0.7 arm for the clip to prevent | [`benchmark/RESULTS-V108.md`](benchmark/RESULTS-V108.md) |
163
+ | The 1.0.8 candidate against 1.0.7, 32k window | 0 dead tasks in both arms. Resolved 46 of 60 in both (+0.0 points, 95% lower bound −6.7). No mid-run refusal in either arm. Turns per task 25.37 (1.0.7) and 26.10 (1.0.8) | Pre-registered gate, passed as registered. pi-tuck `a2e7d1a` (the tool-result clip and the cut at the end of a run, on 1.0.6) against 1.0.7. Released 1.0.8 is that build merged with 1.0.7's change; its replay requests are reported byte-identical to the gated build on 29 recordings (stated in the source file, not re-run for this README). DeepSeek V4.1 Flash pinned to one upstream, window 32,768, reserve 16,384, chains t01 and t02, 60 paired tasks, both arms run together. One model, one window, one run per arm; 60 tasks cannot show a difference smaller than the bound. The run shows that the change introduced no refusal; no refusal occurred in the 1.0.7 arm for the clip to prevent | [`benchmark/RESULTS-V108.md`](benchmark/RESULTS-V108.md) |
175
164
  | Cut time, live, 128k | pi-tuck median 0.081 s (46 cuts; 90th percentile 0.279 s). Pi's compaction median 235.3 s (48 cuts; 90th percentile 403.8 s). Context carried after a cut, median: 26,790 tokens (pi-tuck), 27,750 (Pi's compaction) | pi-tuck 1.0.1, Pi 1.4.0, SWE-bench Verified, 10 chains of 30 tasks, window 128,000, reply reserve 32,768, `mac-studio/main:xhigh` writing Pi's summaries. The built-in time depends on that model and on server load. pi-tuck's time is an upper bound, read from the session file: the time between the entry written just before the cut and the compaction entry, so it includes anything between the last message and the cut (pi-tuck's tool-loop cuts emit no compaction events). The 44 failed compaction attempts in chain s09-A have no compaction entry and are not in the counts | [`benchmark/RESULTS-MAIN.md`](benchmark/RESULTS-MAIN.md) test 3 |
176
165
  | Cut time, paired replay, 128k | pi-tuck median 0.061 s (95 cuts). Pi's compaction prompts on mac-studio/main:xhigh 154.6 s (86 cuts). Pi's compaction prompts on GPT-6.1 Terra 53.2 s (87 cuts, 19 recordings). Context carried after a cut, median: 27,656, 25,790 and 22,784 tokens; median summary 85,561, 23,598 and 11,200 characters | The same recorded sessions cut at the same raw positions. pi-tuck 1.0.1. Terra's cuts ran through Codex, not on the local server | [`benchmark/RESULTS-MAIN.md`](benchmark/RESULTS-MAIN.md) test 3 |
177
- | Retention, 128k, test 1a: pi-tuck with its recall tools against Pi's compaction prompts on mac-studio/main:xhigh | Registered claim: not more than 3 points below, on these probes (cuts 1 to 4 only) (supported). Accuracy on the probes each was asked: 89.7% (783 probes) and 61.8% (1,677). Difference over the 783 shared probes, which come from the 43 of pi-tuck's 95 answer sets that did not abort: +25.7 points, one-sided 95% lower bound +22.0 (+22.3 clustered by chain). By probe type, pi-tuck / comparator: error class 80.2 / 24.7, files changed 84.5 / 78.9, result-line rule 100.0 / 100.0, required tag 100.0 / 99.3, test-runner summary 90.1 / 31.6 | pi-tuck 1.0.1, 20 recordings, mechanical probes only, evidence at least 35,000 raw tokens before the cut. pi-tuck answered with its recall tools and the comparators with none, from the summary and the kept recent messages. Every one of the 43 asks behind the 783 probes made recall calls (1.25 per probe on average), so no pi-tuck answer lacked the tools; the run cannot show how much of the result comes from the summary and how much from recall. No pi-tuck arm without recall tools exists. The comparators' agents had unrestricted bash, and the logs cannot rule out that one read a recording; nothing shows it. pi-tuck's accuracy does not rise with more calls per probe (87.9%, 90.8%, 90.0% by thirds; post hoc, descriptive). The 783 shared probes are fewer than the 2,969 needed to certify a difference near the margin | [`benchmark/RESULTS-MAIN.md`](benchmark/RESULTS-MAIN.md) test 1a |
166
+ | Retention, 128k, test 1a: pi-tuck with its recall tools against Pi's compaction prompts on mac-studio/main:xhigh | Registered claim: not more than 3 points below, on these probes (cuts 1 to 4 only) (supported). Accuracy on the probes each was asked: 89.7% (783 probes) and 61.8% (1,677). Difference over the 783 shared probes, which come from the 43 of pi-tuck's 95 answer sets that did not abort: +25.7 points, one-sided 95% lower bound +22.0 (+22.3 clustered by chain). By probe type, pi-tuck / comparator: error class 80.2 / 24.7, files changed 84.5 / 78.9, result-line rule 100.0 / 100.0, required tag 100.0 / 99.3, test-runner summary 90.1 / 31.6 | pi-tuck 1.0.1, 20 recordings, mechanical probes only, evidence at least 35,000 raw tokens before the cut. pi-tuck answered with its recall tools (1.0.1 had a second recall tool, since removed) and the comparators with none, from the summary and the kept recent messages. Every one of the 43 asks behind the 783 probes made recall calls (1.25 per probe on average), so no pi-tuck answer lacked the tools; the run cannot show how much of the result comes from the summary and how much from recall. No pi-tuck arm without recall tools exists. The comparators' agents had unrestricted bash, and the logs cannot rule out that one read a recording; nothing shows it. pi-tuck's accuracy does not rise with more calls per probe (87.9%, 90.8%, 90.0% by thirds; post hoc, descriptive). The 783 shared probes are fewer than the 2,969 needed to certify a difference near the margin | [`benchmark/RESULTS-MAIN.md`](benchmark/RESULTS-MAIN.md) test 1a |
178
167
  | Retention, 128k, test 1b-Terra: pi-tuck with its recall tools against Pi's compaction prompts on GPT-6.1 Terra | Registered claim: not more than 3 points below, on these probes (cuts 1 to 4 only) (supported). Accuracy on the probes each was asked: 89.7% (783) and 57.8% (1,685). Difference over the 728 shared probes, from the same 43 of pi-tuck's 95 answer sets: +33.7 points, one-sided 95% lower bound +30.4 (+30.1 clustered by chain). By probe type, pi-tuck / Terra: error class 80.2 / 14.7, files changed 84.5 / 72.3, result-line rule 100.0 / 100.0, required tag 100.0 / 93.3, test-runner summary 90.1 / 38.1 | As test 1a, on 19 of the 20 recordings: s09-A is missing because its Terra cut job hit a Codex usage limit, and the set was closed at 19 before any Terra result was read. The claim is non-inferiority. The same limits as test 1a apply | [`benchmark/RESULTS-MAIN.md`](benchmark/RESULTS-MAIN.md) test 1b-Terra |
179
168
  | Tasks resolved, 128k, test 2 | Pi's compaction 251 of 300, pi-tuck 258 of 300. Registered claim: no loss larger than 0.4 points. All 10 chains: +2.3 points, lower bound +0.3. Without chain s09: +1.5 points, lower bound −0.4 | pi-tuck 1.0.1, 10 chains of 30 tasks, paired by task, bootstrap over chains. In s09-A Pi's compaction failed 44 times ("generation hit the token cap") from task 23 on, and no other chain has a failed compaction; that is why the bound changes without s09 | [`benchmark/RESULTS-MAIN.md`](benchmark/RESULTS-MAIN.md) test 2 |
180
169
  | Tokens per session, input plus output without cache reads, 128k | 241,000 fewer for pi-tuck per session on average, one-sided 95% upper bound −21,000, with all 10 chains. Without chain s09 the mean is −174,000 and the upper bound +43,000 | pi-tuck 1.0.1, paired by chain, bootstrap over sessions. The line holds only with all chains | [`benchmark/RESULTS-MAIN.md`](benchmark/RESULTS-MAIN.md) test 3 |
@@ -192,14 +181,13 @@ Notes:
192
181
 
193
182
  ## Settings
194
183
 
195
- pi-tuck needs none. Two are optional. Put them in `pi-tuck.json` in Pi's agent folder (`~/.pi/agent`, or the folder `PI_CODING_AGENT_DIR` names):
184
+ pi-tuck needs none. One is optional. Put them in `pi-tuck.json` in Pi's agent folder (`~/.pi/agent`, or the folder `PI_CODING_AGENT_DIR` names):
196
185
 
197
186
  ```json
198
- { "cutAt": 0.8, "semanticRecall": true }
187
+ { "cutAt": 0.8 }
199
188
  ```
200
189
 
201
190
  - **`cutAt`** (above 0, at most 1; not set by default) is the part of the input room a request may fill before pi-tuck cuts. With no `cutAt`, the cut point adapts to the session since 1.0.13: it follows what the setup and the last cut left, plus half a tail of room to grow, never below 60% of the room and capped just under the room. Setting `cutAt` fixes it as a fraction of the room, and an explicit value keeps the earlier formula, so remove one you set by hand to stop frequent cuts. `{ "cutAt": 1 }` cuts at the full room. A lower value cuts earlier and smaller. The whole room still decides which request pi-tuck refuses.
202
- - **`semanticRecall`** (`false` turns semantic search off, on Apple silicon). Nothing is then downloaded, and `tuck_search` uses keywords only.
203
191
 
204
192
  A bad file is reported at session start, and pi-tuck uses the defaults.
205
193
 
@@ -219,43 +207,24 @@ If you reach the model through OpenRouter, you can also pin one upstream, so tha
219
207
  { "providers": { "openrouter": { "compat": { "openRouterRouting": { "only": ["your-upstream"], "allow_fallbacks": false } } } } }
220
208
  ```
221
209
 
222
- ## Semantic search
223
-
224
- Semantic search is on by default on macOS with Apple silicon. It runs entirely on your Mac: an embedding model, [EmbeddingGemma-2](https://huggingface.co/google/embeddinggemma-2), served by [llama.cpp](https://github.com/ggml-org/llama.cpp) on your Mac's GPU (Metal). No text leaves your machine. Elsewhere (Linux, Intel Macs) there is no `tuck_search`, and nothing is downloaded; compaction and `tuck_recall` work. On a Mac where Metal fails to start, semantic recall goes off with the reason "Semantic recall needs Metal; word recall still works".
225
-
226
- The first time a session starts, pi-tuck downloads what it needs, once, about 390 MB, in the background. Keyword search works meanwhile:
227
-
228
- | File | From |
229
- |---|---|
230
- | EmbeddingGemma-2, 8-bit GGUF (310 MB) and its tokenizer (32 MB) | huggingface.co |
231
- | llama.cpp release b11476 for macOS arm64 (12 MB) | github.com/ggml-org/llama.cpp |
232
- | CPython 3.13 (25 MB) and 16 Python packages for the tokenizer (9 MB) | github.com/astral-sh/python-build-standalone, pypi.org |
233
-
234
- Every file is pinned to a SHA-256 in [src/assets.ts](src/assets.ts) and checked before use. Everything goes to `~/.pi/agent/pi-tuck`; to remove it, delete that folder. Setup needs about 6.5 GB of free disk space while it runs, and uses 460 MB after. If it fails, for example offline, pi-tuck says so and tries again at the next session start. The first-time setup needs one interactive start: one-shot runs (`pi -p`) do not start the download. Since 1.0.21, a `pi -p` run starts semantic search when the runtime is already installed. If it is not installed, pi-tuck says so and starts no download. With no UI, an off or failing semantic recall, or a bad settings file, is written once per message per session to stderr, never into the model's context.
235
-
236
- Since 1.0.32, at every cut pi-tuck indexes in the background what the cut moved out of view, so a first `tuck_search` finds it without embedding it then. One background indexer runs per machine at a time, holding a lock in the index folder, so several Pi sessions do not each load the encoder. A search never waits for that lock, the worker is given back once the window is indexed, and the cut itself never waits for indexing. Semantic search is off when Pi runs in a folder that contains Pi's agent folder, such as your home folder, because its own files live there. Open Pi in a project folder.
237
-
238
210
  ## Use from code
239
211
 
240
212
  The package also exports its parts for hosts that embed Pi through its SDK:
241
213
 
242
214
  ```ts
243
- import { installCompaction, createSemanticRecall, ensureSemanticRuntime } from "pi-tuck";
215
+ import { installCompaction } from "pi-tuck";
244
216
 
245
- const config = JSON.parse(readFileSync(await ensureSemanticRuntime("/abs/path/outside/projects"), "utf8"));
246
- const semanticRecall = createSemanticRecall(config);
247
- const handle = await installCompaction(pi, { semanticRecall });
248
- await handle.setSemanticEnabled(true, ctx); // e.g. in a session_start handler
217
+ const handle = await installCompaction(pi);
249
218
  ```
250
219
 
251
- `installCompaction` options (reply reserve, host-injected messages, recall policy, `cutAt` and others) are documented in [src/compaction.ts](src/compaction.ts). `handle.close()` stops the semantic worker; call it before disposing a session.
220
+ `installCompaction` options (reply reserve, host-injected messages, recall policy, `cutAt` and others) are documented in [src/compaction.ts](src/compaction.ts). `handle.close()` stops the incident recorder; call it before disposing a session.
252
221
 
253
222
  ## Development
254
223
 
255
224
  ```sh
256
225
  npm install
257
226
  npm run check # types
258
- npm test # unit tests (Vitest) and the Python runtime tests
227
+ npm test # unit tests (Vitest)
259
228
  npm run build # dist/ for the library export
260
229
  ```
261
230
 
@@ -263,7 +232,7 @@ Changes are listed in [CHANGELOG.md](CHANGELOG.md). Releases are published from
263
232
 
264
233
  ## Credits
265
234
 
266
- pi-tuck grew out of [pi-vcc](https://github.com/sting8k/pi-vcc) by sting8k and includes code from [pi-blackhole](https://github.com/k0valik/pi-blackhole) by k0valik and from [Pi](https://github.com/earendil-works/pi) by Mario Zechner, all MIT; their notices are in [LICENSE](LICENSE). The downloaded model is Apache-2.0, llama.cpp is MIT, and CPython is under the PSF license.
235
+ pi-tuck grew out of [pi-vcc](https://github.com/sting8k/pi-vcc) by sting8k and includes code from [pi-blackhole](https://github.com/k0valik/pi-blackhole) by k0valik and from [Pi](https://github.com/earendil-works/pi) by Mario Zechner, all MIT; their notices are in [LICENSE](LICENSE).
267
236
 
268
237
  ## License
269
238
 
package/dist/index.d.ts CHANGED
@@ -2,12 +2,8 @@ import { type ExtensionAPI } from "@earendil-works/pi-coding-agent";
2
2
  export type { CompactionOptions } from "./src/compaction.js";
3
3
  export { installCompaction } from "./src/compaction.js";
4
4
  export { inspectIncident, readableIncident } from "./src/diagnostic-replay.js";
5
- export { createSemanticRecall, SemanticRecallController } from "./src/semantic-recall.js";
6
- export type { SemanticRecallConfig, PriorResult, SemanticState, SemanticSetup } from "./src/semantic-recall.js";
7
- export { ensureSemanticRuntime } from "./src/setup.js";
8
- /** pi-tuck as a Pi extension: compaction and history recall always; semantic recall too, unless `pi-tuck.json` in Pi's agent folder
9
- * says `{"semanticRecall": false}`. Its runtime is set up in the background the first time a session starts. The same file's `"cutAt"`
10
- * (a number above 0 and at most 1) is the fraction of the input room a cut is triggered at, 0.6 by default. */
5
+ /** pi-tuck as a Pi extension: compaction and history recall. `"cutAt"` in `pi-tuck.json` in Pi's agent folder (a number above 0 and at most
6
+ * 1) fixes the cut point as a fraction of the input room; without it, the cut point adapts. */
11
7
  /** The oldest Pi with every hook and API pi-tuck uses, and the oldest its tests pass on (Pi 1.2 added the custom message that starts a
12
8
  * run to before_agent_start, which the prompt's cut counts). */
13
9
  export declare const PI_FLOOR = "1.2.0";
package/dist/index.js CHANGED
@@ -1,18 +1,14 @@
1
1
  import { VERSION, getAgentDir } from "@earendil-works/pi-coding-agent";
2
- import { existsSync, readFileSync, realpathSync } from "node:fs";
3
- import { join, sep } from "node:path";
2
+ import { readFileSync } from "node:fs";
3
+ import { join } from "node:path";
4
4
  import { installCompaction } from "./src/compaction.js";
5
5
  import { validCutAt } from "./src/budget.js";
6
- import { createSemanticRecall } from "./src/semantic-recall.js";
7
- import { defaultRoot, runtimeConfigPath } from "./src/assets.js";
8
- import { ensureSemanticRuntime } from "./src/setup.js";
6
+ import { notify } from "./src/notify.js";
7
+ import { cleanupLegacyFiles } from "./src/legacy-cleanup.js";
9
8
  export { installCompaction } from "./src/compaction.js";
10
9
  export { inspectIncident, readableIncident } from "./src/diagnostic-replay.js";
11
- export { createSemanticRecall, SemanticRecallController } from "./src/semantic-recall.js";
12
- export { ensureSemanticRuntime } from "./src/setup.js";
13
- /** pi-tuck as a Pi extension: compaction and history recall always; semantic recall too, unless `pi-tuck.json` in Pi's agent folder
14
- * says `{"semanticRecall": false}`. Its runtime is set up in the background the first time a session starts. The same file's `"cutAt"`
15
- * (a number above 0 and at most 1) is the fraction of the input room a cut is triggered at, 0.6 by default. */
10
+ /** pi-tuck as a Pi extension: compaction and history recall. `"cutAt"` in `pi-tuck.json` in Pi's agent folder (a number above 0 and at most
11
+ * 1) fixes the cut point as a fraction of the input room; without it, the cut point adapts. */
16
12
  /** The oldest Pi with every hook and API pi-tuck uses, and the oldest its tests pass on (Pi 1.2 added the custom message that starts a
17
13
  * run to before_agent_start, which the prompt's cut counts). */
18
14
  export const PI_FLOOR = "1.2.0";
@@ -41,99 +37,16 @@ export default async function (pi) {
41
37
  });
42
38
  return;
43
39
  }
44
- const semanticRecall = createSemanticRecall();
45
- // `/tuck-semantic off` holds for the rest of the session, including over a setup that finishes later.
46
40
  const settings = readSettings(join(getAgentDir(), "pi-tuck.json"));
47
- // Semantic recall runs on Metal, so only on Apple silicon; elsewhere the model is not offered tuck_search at all.
48
- const appleSilicon = process.platform === "darwin" && process.arch === "arm64";
49
- const handle = await installCompaction(pi, { semanticRecall, search: appleSilicon, cutAt: settings.cutAt, onSemanticSetting: async (enabled) => {
50
- if (!enabled)
51
- semanticRecall.setSetup("off-user");
52
- else if (semanticRecall.status().setup === "off-user")
53
- semanticRecall.setSetup("starting", { installed: existsSync(runtimeConfigPath(defaultRoot())) });
54
- } });
55
- if (settings.semanticRecall === false) {
56
- semanticRecall.setSetup("off-settings");
57
- pi.on("session_start", () => { semanticRecall.setSetup("off-settings"); });
58
- return;
59
- }
60
- let session = 0, said = "", announced = false, setup;
61
- // A context outlives its session (a setup can finish after /new); a notice to an ended session is dropped.
62
- // With no UI (pi -p), Pi shows no notices, so a settings error or an off or failing semantic recall would go unsaid: write each to stderr
63
- // instead, once per session. stderr is the operator's; it never enters the model's context.
64
- const stderrSaid = new Set();
65
- const say = (ctx, message, level) => {
66
- if (!ctx.hasUI) {
67
- if (!stderrSaid.has(message)) {
68
- stderrSaid.add(message);
69
- try {
70
- process.stderr.write(message + "\n");
71
- }
72
- catch { /* closed */ }
73
- }
74
- return;
75
- }
76
- try {
77
- ctx.ui.notify(message, level);
78
- }
79
- catch { /* ended */ }
80
- };
81
- const once = (ctx, message, level) => { if (said !== message) {
82
- said = message;
83
- say(ctx, message, level);
84
- } };
85
- const announce = (ctx, state, detail) => {
86
- semanticRecall.setSetup(state, detail);
87
- const notice = semanticRecall.setupNotice();
88
- if (notice)
89
- (state === "off-platform" || state === "off-project" ? once : say)(ctx, notice.message, notice.level);
90
- };
91
- pi.on("session_shutdown", () => { session++; });
92
- pi.on("session_start", (_event, ctx) => {
93
- const current = ++session;
94
- stderrSaid.clear();
41
+ const handle = await installCompaction(pi, { cutAt: settings.cutAt });
42
+ let said = false;
43
+ pi.on("session_start", async (_event, ctx) => {
44
+ await cleanupLegacyFiles(ctx);
95
45
  if (handle.state?.(ctx).kind === "standingDown")
96
46
  return;
97
- if (settings.error)
98
- once(ctx, `pi-tuck: ${settings.error}; using the defaults.`, "warning");
99
- if (!appleSilicon)
100
- return announce(ctx, "off-platform");
101
- // Semantic recall keeps its runtime and indexes outside the project it serves, so not when Pi runs in a folder that holds its
102
- // agent folder, such as the home folder.
103
- if (within(real(getAgentDir()), real(ctx.cwd)))
104
- return announce(ctx, "off-project");
105
- // A run with no UI (pi -p, RPC, JSON) uses a runtime that is already installed: that needs no download. It does not start a first-time
106
- // setup, which would outlast a one-shot run, and it says why, so tuck_search and /tuck name the real state.
107
- const installed = existsSync(runtimeConfigPath(defaultRoot()));
108
- if (!ctx.hasUI && !installed)
109
- return announce(ctx, "not-installed");
110
- // The download's announcement outlives the session that made it: a session that starts while the shared setup is still running
111
- // owes the "set up" notice once, as before the refactor.
112
- semanticRecall.setSetup("starting", { installed, announced });
113
- setup ??= ensureSemanticRuntime(defaultRoot(), message => {
114
- announced = true;
115
- if (current === session && semanticRecall.status().setup !== "off-user")
116
- announce(ctx, "starting", { installed, notice: message, announced: true });
117
- });
118
- setup.then(async () => {
119
- if (current !== session || semanticRecall.status().setup === "off-user")
120
- return;
121
- try {
122
- await handle.setSemanticEnabled(true, ctx);
123
- if (current === session && semanticRecall.status().setup !== "off-user") {
124
- announce(ctx, "ready", { announced });
125
- announced = false;
126
- }
127
- }
128
- catch (error) {
129
- if (current === session && semanticRecall.status().setup !== "off-user")
130
- announce(ctx, "failed", { stage: "start", reason: reason(error) });
131
- }
132
- }, error => {
133
- setup = undefined; // the next session start tries again
134
- if (current === session && semanticRecall.status().setup !== "off-user")
135
- announce(ctx, "failed", { stage: "setup", reason: reason(error) });
136
- });
47
+ if (settings.error && !said) {
48
+ said = notify(ctx, `pi-tuck: ${settings.error}; using the defaults.`, "warning");
49
+ }
137
50
  });
138
51
  }
139
52
  function readSettings(path) {
@@ -146,18 +59,10 @@ function readSettings(path) {
146
59
  }
147
60
  try {
148
61
  const value = JSON.parse(text);
149
- if (value && typeof value === "object" && (value.semanticRecall === undefined || typeof value.semanticRecall === "boolean") &&
62
+ if (value && typeof value === "object" &&
150
63
  (value.cutAt === undefined || validCutAt(value.cutAt)))
151
- return value;
64
+ return { cutAt: value.cutAt };
152
65
  }
153
66
  catch { /* reported below */ }
154
- return { error: `${path} should be a JSON object like {"semanticRecall": false, "cutAt": 0.8}, with cutAt a number above 0 and at most 1` };
155
- }
156
- const reason = (error) => error instanceof Error ? error.message : String(error);
157
- const within = (path, folder) => path === folder || path.startsWith(folder.endsWith(sep) ? folder : folder + sep);
158
- const real = (path) => { try {
159
- return realpathSync(path);
67
+ return { error: `${path} should be a JSON object like {"cutAt": 0.8}, with cutAt a number above 0 and at most 1` };
160
68
  }
161
- catch {
162
- return path;
163
- } };
@@ -0,0 +1,8 @@
1
+ /** Classify the recorded shell independently of the host OS. Both kept-result lanes use this decision. */
2
+ export declare function classifyBash(command: string, cwd?: string): {
3
+ words: string[];
4
+ windows: boolean;
5
+ readOnly: boolean;
6
+ mutatesAll: boolean;
7
+ directory: string | undefined;
8
+ };