pi-tuck 1.2.0 → 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.
- package/CHANGELOG.md +18 -0
- package/README.md +28 -59
- package/dist/src/bash-command.d.ts +8 -0
- package/dist/src/bash-command.js +116 -0
- package/dist/src/build-id.d.ts +1 -1
- package/dist/src/build-id.js +1 -1
- package/dist/src/diagnostic-replay.js +1 -1
- package/dist/src/diagnostics.d.ts +1 -1
- package/dist/src/kept-reads.js +5 -114
- package/dist/src/kept-searches.d.ts +11 -0
- package/dist/src/kept-searches.js +202 -0
- package/dist/src/tuck/core/content.d.ts +0 -11
- package/dist/src/tuck/core/content.js +0 -47
- package/dist/src/tuck/core/search-entries.d.ts +5 -28
- package/dist/src/tuck/core/search-entries.js +13 -155
- package/dist/src/tuck.d.ts +7 -15
- package/dist/src/tuck.js +32 -28
- package/package.json +1 -1
- package/src/bash-command.ts +59 -0
- package/src/build-id.ts +1 -1
- package/src/diagnostic-replay.ts +1 -1
- package/src/kept-reads.ts +5 -56
- package/src/kept-searches.ts +163 -0
- package/src/tuck/core/content.ts +0 -43
- package/src/tuck/core/search-entries.ts +14 -201
- package/src/tuck.ts +33 -34
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,24 @@
|
|
|
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
|
+
|
|
6
24
|
## [1.2.0] - 2026-11-15
|
|
7
25
|
|
|
8
26
|
### Added
|
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
|
|
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
|
|
40
|
+
The agent searches its history by keyword with `tuck_recall`:
|
|
42
41
|
|
|
43
42
|
```json
|
|
44
|
-
{ "query": "
|
|
43
|
+
{ "query": "retry token refresh" }
|
|
45
44
|
```
|
|
46
45
|
|
|
47
|
-
It gets back
|
|
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
|
-
|
|
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.
|
|
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
|
|
66
|
-
-
|
|
67
|
-
-
|
|
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.
|
|
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
|
|
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
|
|
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
|
|
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`,
|
|
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;
|
|
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
|
|
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
|
|
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.
|
|
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
|
|
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
|
|
215
|
+
import { installCompaction } from "pi-tuck";
|
|
244
216
|
|
|
245
|
-
const
|
|
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
|
|
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)
|
|
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).
|
|
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
|
|
|
@@ -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
|
+
};
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { posix } from "node:path";
|
|
2
|
+
// A deliberately bounded shell recognizer: substitutions, redirections and
|
|
3
|
+
// unrecognized composition never certify a command as read-only.
|
|
4
|
+
function shellWords(command, windows) {
|
|
5
|
+
const words = [];
|
|
6
|
+
let word = "", quote = "", started = false, simple = true;
|
|
7
|
+
const flush = () => { if (started)
|
|
8
|
+
words.push(word); word = ""; started = false; };
|
|
9
|
+
for (let i = 0; i < command.length; i++) {
|
|
10
|
+
const c = command[i];
|
|
11
|
+
if (quote === "'") {
|
|
12
|
+
if (c === quote)
|
|
13
|
+
quote = "";
|
|
14
|
+
else
|
|
15
|
+
word += c;
|
|
16
|
+
continue;
|
|
17
|
+
}
|
|
18
|
+
if (c === "\\" && !windows) {
|
|
19
|
+
if (command[i + 1] === "\n") {
|
|
20
|
+
i++;
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
started = true;
|
|
24
|
+
if (i + 1 < command.length)
|
|
25
|
+
word += command[++i];
|
|
26
|
+
else
|
|
27
|
+
simple = false;
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
if (c === "$" || c === "`")
|
|
31
|
+
simple = false;
|
|
32
|
+
if (windows && (c === "%" || c === "^"))
|
|
33
|
+
simple = false;
|
|
34
|
+
if (quote) {
|
|
35
|
+
if (c === quote)
|
|
36
|
+
quote = "";
|
|
37
|
+
else
|
|
38
|
+
word += c;
|
|
39
|
+
continue;
|
|
40
|
+
}
|
|
41
|
+
if (c === "'" || c === '"') {
|
|
42
|
+
quote = c;
|
|
43
|
+
started = true;
|
|
44
|
+
}
|
|
45
|
+
else if (/\s/u.test(c)) {
|
|
46
|
+
flush();
|
|
47
|
+
if (c === "\n") {
|
|
48
|
+
words.push(";");
|
|
49
|
+
simple = false;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
else if (/[|&;<>]/u.test(c)) {
|
|
53
|
+
flush();
|
|
54
|
+
const op = command[i + 1] === c ? c + command[++i] : c;
|
|
55
|
+
words.push(op);
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
word += c;
|
|
59
|
+
started = true;
|
|
60
|
+
if (/[(){}]/u.test(c))
|
|
61
|
+
simple = false;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
flush();
|
|
65
|
+
return { words, simple: simple && !quote };
|
|
66
|
+
}
|
|
67
|
+
const readers = new Set(["ls", "cat", "head", "tail", "wc", "pwd", "echo", "tree", "file", "stat", "grep", "rg"]);
|
|
68
|
+
const windowsReaders = new Set(["type", "dir", "get-content", "get-childitem", "select-string", "findstr"]);
|
|
69
|
+
const windowsMutators = new Set(["set-content", "add-content", "out-file", "remove-item", "move-item", "copy-item", "new-item", "del", "move", "copy", "ren"]);
|
|
70
|
+
const gitMutations = new Set(["checkout", "restore", "stash", "apply", "reset", "pull", "merge", "rebase", "am"]);
|
|
71
|
+
function mutatingGit(words) {
|
|
72
|
+
return words.some((word, at) => {
|
|
73
|
+
if (posix.basename(word.replace(/\\/gu, "/")).replace(/\.exe$/iu, "").toLowerCase() !== "git")
|
|
74
|
+
return false;
|
|
75
|
+
for (let i = at + 1; i < words.length; i++) {
|
|
76
|
+
const arg = words[i];
|
|
77
|
+
if (["-C", "-c", "--git-dir", "--work-tree", "--namespace", "--config-env"].includes(arg)) {
|
|
78
|
+
i++;
|
|
79
|
+
continue;
|
|
80
|
+
}
|
|
81
|
+
if (arg.startsWith("-"))
|
|
82
|
+
continue;
|
|
83
|
+
return gitMutations.has(arg);
|
|
84
|
+
}
|
|
85
|
+
return false;
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
function readOnly(words, simple) {
|
|
89
|
+
if (!simple)
|
|
90
|
+
return false;
|
|
91
|
+
if (words[0] === "cd" && words[2] === "&&")
|
|
92
|
+
words = words.slice(3);
|
|
93
|
+
if (!words.length || words.some(word => ["&&", "||", "&", ";", ">", ">>", "<", "<<"].includes(word)))
|
|
94
|
+
return false;
|
|
95
|
+
const commands = [[]];
|
|
96
|
+
for (const word of words) {
|
|
97
|
+
if (word === "|")
|
|
98
|
+
commands.push([]);
|
|
99
|
+
else
|
|
100
|
+
commands.at(-1).push(word);
|
|
101
|
+
}
|
|
102
|
+
return commands.every(([name, ...args]) => readers.has(name) || windowsReaders.has(name?.toLowerCase() ?? "") ||
|
|
103
|
+
name === "find" && !args.some(arg => /^-(exec|ok|delete|fprint)/u.test(arg)) ||
|
|
104
|
+
name === "sed" && args.includes("-n") && !args.some(arg => /^-[^-]*i|^--in-place/u.test(arg)) ||
|
|
105
|
+
name === "git" && ["status", "log", "diff", "show"].includes(args[0]));
|
|
106
|
+
}
|
|
107
|
+
/** Classify the recorded shell independently of the host OS. Both kept-result lanes use this decision. */
|
|
108
|
+
export function classifyBash(command, cwd) {
|
|
109
|
+
const commandName = command.trim().split(/\s/u)[0].toLowerCase();
|
|
110
|
+
const windows = /^[a-z]:[\\/]|\\/iu.test(cwd ?? "") || /[a-z]:\\/iu.test(command) ||
|
|
111
|
+
windowsReaders.has(commandName) || windowsMutators.has(commandName);
|
|
112
|
+
const { words, simple } = shellWords(command, windows);
|
|
113
|
+
return { words, windows, readOnly: readOnly(words, simple),
|
|
114
|
+
mutatesAll: mutatingGit(words) || !simple && mutatingGit(command.split(/[\s'"`();|&]+/u)),
|
|
115
|
+
directory: words[0] === "cd" && words[2] === "&&" ? words[1] : undefined };
|
|
116
|
+
}
|
package/dist/src/build-id.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const BUILD_ID = "
|
|
1
|
+
export declare const BUILD_ID = "cf1509ac0cd19e83fc1fa7ab43c0639d57a02dac127a7e7639e79b9b00b58092";
|
package/dist/src/build-id.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const BUILD_ID = "
|
|
1
|
+
export const BUILD_ID = "cf1509ac0cd19e83fc1fa7ab43c0639d57a02dac127a7e7639e79b9b00b58092";
|
|
@@ -12,7 +12,7 @@ export function inspectIncident(records) {
|
|
|
12
12
|
if (i.branchEntryIds?.length)
|
|
13
13
|
manager.branch(i.branchEntryIds.at(-1));
|
|
14
14
|
const ctx = { sessionManager: manager, cwd: '/offline-compaction-replay', model: { contextWindow: i.contextWindow } };
|
|
15
|
-
const draft = tuckObservedDraft(tuck, { branchEntries: manager.getBranch(), tokensBefore: i.tokensBefore, previousSummary: i.previousSummary
|
|
15
|
+
const draft = tuckObservedDraft(tuck, { branchEntries: manager.getBranch(), tokensBefore: i.tokensBefore, previousSummary: i.previousSummary }, ctx, i.reserve, messages => measurableConversationTokens(messages, ctx), {}, i.retainCurrentInput);
|
|
16
16
|
const proposal = records.find(r => r.kind === 'proposal' && r.data?.details?.diagnosticReceipt?.id === i.receiptId)?.data;
|
|
17
17
|
const matchesRecordedProposal = proposal && draft.compaction ? proposal.summary === draft.compaction.summary && proposal.firstKeptEntryId === draft.compaction.firstKeptEntryId : null;
|
|
18
18
|
return { mode: 'deterministic-selection-replay', draft, receiptId: i.receiptId ?? null, matchesRecordedProposal, notice: 'Supplied permitted originals and resolved state only; no tools, inference, meaning preservation, persistence or transmission claim.' };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type RecallPolicy } from './recall.js';
|
|
2
2
|
import type { SessionEntry } from '@earendil-works/pi-coding-agent';
|
|
3
|
-
export declare const DIAGNOSTIC_BUILD = "
|
|
3
|
+
export declare const DIAGNOSTIC_BUILD = "cf1509ac0cd19e83fc1fa7ab43c0639d57a02dac127a7e7639e79b9b00b58092";
|
|
4
4
|
export interface Receipt {
|
|
5
5
|
id: string;
|
|
6
6
|
build: string;
|
package/dist/src/kept-reads.js
CHANGED
|
@@ -1,112 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { classifyBash } from "./bash-command.js";
|
|
2
2
|
import { pathKey } from "./path-key.js";
|
|
3
3
|
import { isTextOnly, textOf } from "./tuck/core/content.js";
|
|
4
4
|
import { extractPath } from "./tuck/core/tool-args.js";
|
|
5
|
-
// A deliberately bounded shell recognizer: substitutions, redirections and
|
|
6
|
-
// unrecognized composition never certify a command as read-only.
|
|
7
|
-
function shellWords(command, windows) {
|
|
8
|
-
const words = [];
|
|
9
|
-
let word = "", quote = "", started = false, simple = true;
|
|
10
|
-
const flush = () => { if (started)
|
|
11
|
-
words.push(word); word = ""; started = false; };
|
|
12
|
-
for (let i = 0; i < command.length; i++) {
|
|
13
|
-
const c = command[i];
|
|
14
|
-
if (quote === "'") {
|
|
15
|
-
if (c === quote)
|
|
16
|
-
quote = "";
|
|
17
|
-
else
|
|
18
|
-
word += c;
|
|
19
|
-
continue;
|
|
20
|
-
}
|
|
21
|
-
if (c === "\\" && !windows) {
|
|
22
|
-
if (command[i + 1] === "\n") {
|
|
23
|
-
i++;
|
|
24
|
-
continue;
|
|
25
|
-
}
|
|
26
|
-
started = true;
|
|
27
|
-
if (i + 1 < command.length)
|
|
28
|
-
word += command[++i];
|
|
29
|
-
else
|
|
30
|
-
simple = false;
|
|
31
|
-
continue;
|
|
32
|
-
}
|
|
33
|
-
if (c === "$" || c === "`")
|
|
34
|
-
simple = false;
|
|
35
|
-
if (windows && (c === "%" || c === "^"))
|
|
36
|
-
simple = false;
|
|
37
|
-
if (quote) {
|
|
38
|
-
if (c === quote)
|
|
39
|
-
quote = "";
|
|
40
|
-
else
|
|
41
|
-
word += c;
|
|
42
|
-
continue;
|
|
43
|
-
}
|
|
44
|
-
if (c === "'" || c === '"') {
|
|
45
|
-
quote = c;
|
|
46
|
-
started = true;
|
|
47
|
-
}
|
|
48
|
-
else if (/\s/u.test(c)) {
|
|
49
|
-
flush();
|
|
50
|
-
if (c === "\n") {
|
|
51
|
-
words.push(";");
|
|
52
|
-
simple = false;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
else if (/[|&;<>]/u.test(c)) {
|
|
56
|
-
flush();
|
|
57
|
-
const op = command[i + 1] === c ? c + command[++i] : c;
|
|
58
|
-
words.push(op);
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
word += c;
|
|
62
|
-
started = true;
|
|
63
|
-
if (/[(){}]/u.test(c))
|
|
64
|
-
simple = false;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
flush();
|
|
68
|
-
return { words, simple: simple && !quote };
|
|
69
|
-
}
|
|
70
|
-
const readers = new Set(["ls", "cat", "head", "tail", "wc", "pwd", "echo", "tree", "file", "stat", "grep", "rg"]);
|
|
71
|
-
const windowsReaders = new Set(["type", "dir", "get-content", "get-childitem", "select-string", "findstr"]);
|
|
72
|
-
const windowsMutators = new Set(["set-content", "add-content", "out-file", "remove-item", "move-item", "copy-item", "new-item", "del", "move", "copy", "ren"]);
|
|
73
|
-
const gitMutations = new Set(["checkout", "restore", "stash", "apply", "reset", "pull", "merge", "rebase", "am"]);
|
|
74
|
-
function mutatingGit(words) {
|
|
75
|
-
return words.some((word, at) => {
|
|
76
|
-
if (posix.basename(word.replace(/\\/gu, "/")).replace(/\.exe$/iu, "").toLowerCase() !== "git")
|
|
77
|
-
return false;
|
|
78
|
-
for (let i = at + 1; i < words.length; i++) {
|
|
79
|
-
const arg = words[i];
|
|
80
|
-
if (["-C", "-c", "--git-dir", "--work-tree", "--namespace", "--config-env"].includes(arg)) {
|
|
81
|
-
i++;
|
|
82
|
-
continue;
|
|
83
|
-
}
|
|
84
|
-
if (arg.startsWith("-"))
|
|
85
|
-
continue;
|
|
86
|
-
return gitMutations.has(arg);
|
|
87
|
-
}
|
|
88
|
-
return false;
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
function readOnly(words, simple) {
|
|
92
|
-
if (!simple)
|
|
93
|
-
return false;
|
|
94
|
-
if (words[0] === "cd" && words[2] === "&&")
|
|
95
|
-
words = words.slice(3);
|
|
96
|
-
if (!words.length || words.some(word => ["&&", "||", "&", ";", ">", ">>", "<", "<<"].includes(word)))
|
|
97
|
-
return false;
|
|
98
|
-
const commands = [[]];
|
|
99
|
-
for (const word of words) {
|
|
100
|
-
if (word === "|")
|
|
101
|
-
commands.push([]);
|
|
102
|
-
else
|
|
103
|
-
commands.at(-1).push(word);
|
|
104
|
-
}
|
|
105
|
-
return commands.every(([name, ...args]) => readers.has(name) || windowsReaders.has(name?.toLowerCase() ?? "") ||
|
|
106
|
-
name === "find" && !args.some(arg => /^-(exec|delete|fprint)/u.test(arg)) ||
|
|
107
|
-
name === "sed" && args.includes("-n") && !args.some(arg => /^-[^-]*i|^--in-place/u.test(arg)) ||
|
|
108
|
-
name === "git" && ["status", "log", "diff", "show"].includes(args[0]));
|
|
109
|
-
}
|
|
110
5
|
/** Whole successful text reads, newest result first. Mutations invalidate earlier calls even when they fail or have no result. */
|
|
111
6
|
export function keptReadCandidates(entries, indices, resolvable) {
|
|
112
7
|
const cwd = entries.find((entry) => entry.type === "session")?.cwd;
|
|
@@ -125,18 +20,14 @@ export function keptReadCandidates(entries, indices, resolvable) {
|
|
|
125
20
|
if (block.name === "bash") {
|
|
126
21
|
if (!reads.size || typeof args.command !== "string")
|
|
127
22
|
continue;
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
const windows = /^[a-z]:[\\/]|\\/iu.test(cwd ?? "") || /[a-z]:\\/iu.test(args.command) ||
|
|
131
|
-
windowsReaders.has(commandName) || windowsMutators.has(commandName);
|
|
132
|
-
const { words, simple } = shellWords(args.command, windows);
|
|
133
|
-
if (readOnly(words, simple))
|
|
23
|
+
const command = classifyBash(args.command, cwd), { words } = command;
|
|
24
|
+
if (command.readOnly)
|
|
134
25
|
continue;
|
|
135
|
-
if (
|
|
26
|
+
if (command.mutatesAll) {
|
|
136
27
|
allMutated = order;
|
|
137
28
|
continue;
|
|
138
29
|
}
|
|
139
|
-
const base =
|
|
30
|
+
const base = command.directory === undefined ? cwd : pathKey(command.directory, cwd);
|
|
140
31
|
const names = [...words, ...args.command.split(/[\s'"`=;|&()<>{},]+/u)];
|
|
141
32
|
for (const name of names)
|
|
142
33
|
if (name) {
|