pi-tuck 1.0.16 → 1.0.17
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 +25 -0
- package/README.md +6 -4
- package/dist/src/build-id.d.ts +1 -1
- package/dist/src/build-id.js +1 -1
- package/dist/src/compaction.js +23 -4
- package/dist/src/diagnostics.d.ts +1 -1
- package/package.json +1 -1
- package/src/build-id.ts +1 -1
- package/src/compaction.ts +20 -5
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,31 @@
|
|
|
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.0.17] - 2026-11-08
|
|
7
|
+
|
|
8
|
+
### Fixed
|
|
9
|
+
|
|
10
|
+
- **A host that patches a large section into the system prompt could get a refusal a cut would fit (1.0.0 to 1.0.16).** pi-tuck plans a prompt's cut when
|
|
11
|
+
the prompt arrives, before other extensions change the system prompt. A host engine that adds a section of thousands of tokens for one turn, as an
|
|
12
|
+
orchestrator does for its stand-off, could push that turn's first request over the room, and the final guard refused it. The guard now reduces first:
|
|
13
|
+
when the run's first request is over the room and no cut is planned, it plans the prompt's cut there, against the system prompt as finally sent, and
|
|
14
|
+
refuses only if that cut does not fit either. It works whatever order the extensions load in.
|
|
15
|
+
|
|
16
|
+
### Added
|
|
17
|
+
|
|
18
|
+
- Stress cells for a host that patches an 8k then 24k system section, at 65,536 and 81,920, registered before and after pi-tuck, with the section arriving
|
|
19
|
+
on a stand-off or on the first step turn after one and removed at the next stand-off. 1.0.16 refuses in the four cells at 81,920; 1.0.17 in none.
|
|
20
|
+
|
|
21
|
+
### Changed
|
|
22
|
+
|
|
23
|
+
- When queued input alone exceeds the room, the refusal names it as incoming input that cannot fit, instead of complete context. It still fails closed
|
|
24
|
+
with no cut.
|
|
25
|
+
|
|
26
|
+
### Release gates
|
|
27
|
+
|
|
28
|
+
- Replay matches 1.0.16: 0 of 13,946 requests differ on 29 recordings, 0 lost or dead tasks. Shipped without a live gate as a replay-matching patch.
|
|
29
|
+
Tests; CI; the stress test, with no cell worse than 1.0.16.
|
|
30
|
+
|
|
6
31
|
## [1.0.16] - 2026-11-08
|
|
7
32
|
|
|
8
33
|
### Fixed
|
package/README.md
CHANGED
|
@@ -64,8 +64,8 @@ Then start a new Pi session. That is all. pi-tuck takes over Pi's compaction, bo
|
|
|
64
64
|
|
|
65
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
66
|
- On macOS with Apple silicon, the first session also downloads a local search model in the background (about 390 MB, once). 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.0.
|
|
68
|
-
- To pin a version, add it: `pi install npm:pi-tuck@1.0.
|
|
67
|
+
- Prefer GitHub? `pi install git:github.com/galyavin/pi-tuck@v1.0.16`.
|
|
68
|
+
- To pin a version, add it: `pi install npm:pi-tuck@1.0.16`.
|
|
69
69
|
|
|
70
70
|
## How it works
|
|
71
71
|
|
|
@@ -74,7 +74,7 @@ When context fills up, pi-tuck replaces the older turns with one summary. The su
|
|
|
74
74
|
- **The dialogue.** What you asked and what the agent answered, in order, word for word. If it is too long for the room, it shrinks: the oldest assistant text is clipped first, then older prompts. Clipped text says how to read it in full.
|
|
75
75
|
- **The files.** Files the agent read, wrote or edited, newest first (up to 60), each with a pointer to read it back.
|
|
76
76
|
- **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.
|
|
77
|
-
- **Your first prompt
|
|
77
|
+
- **Your prompts, quoted from both ends** (1.0.16 and later): first the opening of every recent answered turn, then the first prompt's opening (up to 2,000 characters), then more of the newest turns, then the rest of the first prompt. A turn that does not fit keeps its opening and a locator to the rest. The budget is 15% of the room and never less than 12,000 characters. When room is tight, the quotes shrink step by step: the extensions first, then the openings, then the first prompt alone. Before 1.0.16 a summary quoted only the first prompt (up to 12,000 characters) and the newest turn; see Known limits.
|
|
78
78
|
|
|
79
79
|
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.
|
|
80
80
|
|
|
@@ -114,8 +114,10 @@ Known limits today:
|
|
|
114
114
|
- Small windows: an upstream that spends far more context on tool schemas than others (some OpenRouter upstreams do) can leave a small input room too little space. pi-tuck then refuses to cut rather than overflow. This made 1.0.1 refuse at a 32k window with Pi's default 16,384 reserve. Version 1.0.4 added a notice that says when the provider counts far above pi-tuck's estimate. In 1.0.4, after an oversize tool result or a "Nothing to compact" error from Pi, a session could keep refusing later prompts; 1.0.5 fixed both. Version 1.0.8 clips a fresh tool result that is too large for the room (its head and tail, with a `tuck_recall` locator to the rest) instead of refusing the run. If a small window still refuses, pin a different upstream, lower the reserve, or use a larger window; see [Small windows](#small-windows).
|
|
115
115
|
- 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 is 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.
|
|
116
116
|
- 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).
|
|
117
|
+
- A long session could lose the task it was working on (1.0.0 to 1.0.15; fixed in 1.0.16). A summary quoted only the session's first user turn, up to 12,000 characters, and the newest one. Every other user turn competed in the shrunk dialogue, which in a long session clips user turns to a few words and drops the oldest. In a session that runs task after task, the current task is an older turn followed by short steps, so it was clipped or dropped while a finished first task stayed whole, and agents acted on a days-old task. 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.16 ([`CHANGELOG.md`](CHANGELOG.md) 1.0.16).
|
|
118
|
+
- At very small free room (a few thousand tokens or less), the quotes give way and an older prompt can still lose its opening, in 1.0.16: 40 findings in 32 stress cells, against 447 in 168 cells on 1.0.15 ([`CHANGELOG.md`](CHANGELOG.md) 1.0.16).
|
|
117
119
|
- 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).
|
|
118
|
-
- Still applying (1.0.11 to 1.0.
|
|
120
|
+
- 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).
|
|
119
121
|
- 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.
|
|
120
122
|
- 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.
|
|
121
123
|
|
package/dist/src/build-id.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const BUILD_ID = "
|
|
1
|
+
export declare const BUILD_ID = "27bb99fa3ca595dac73089d18c4c3506073c5d3e3f778ea572708f6e7a49ffc3";
|
package/dist/src/build-id.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const BUILD_ID = "
|
|
1
|
+
export const BUILD_ID = "27bb99fa3ca595dac73089d18c4c3506073c5d3e3f778ea572708f6e7a49ffc3";
|
package/dist/src/compaction.js
CHANGED
|
@@ -542,7 +542,7 @@ export async function installCompaction(pi, options = {}) {
|
|
|
542
542
|
// custom message starts). The cut is pi-tuck's own, planned as at a tool boundary. It is not Pi's: Pi's cut finder keeps the last
|
|
543
543
|
// keepRecentTokens, and where those are the whole conversation it has nothing to cut, so every later prompt was refused for good (t06 at
|
|
544
544
|
// Pi's defaults on a 32k window). Each request of the run carries the cut, and the run's first boundary saves it.
|
|
545
|
-
const preflight =
|
|
545
|
+
const preflight = (ctx, incomingPart, observedPrompt, tools) => {
|
|
546
546
|
promptCut = undefined;
|
|
547
547
|
promptCutAt = ctx.sessionManager.getBranch().length;
|
|
548
548
|
if (!active())
|
|
@@ -807,22 +807,41 @@ export async function installCompaction(pi, options = {}) {
|
|
|
807
807
|
throw missingModel();
|
|
808
808
|
// The complete request, counted after Pi's conversion (summary/custom/bash envelopes), with the effective system once.
|
|
809
809
|
// Pi applies a forced prompt after this hook; the public prompt already observes it.
|
|
810
|
-
|
|
810
|
+
let messages = event.messages, tokens = requestTokens(messages, ctx.getSystemPrompt());
|
|
811
|
+
// The run's first request is over the room although the prompt's decision found it fit: something changed the request after that decision
|
|
812
|
+
// (another extension patching the system prompt in before_agent_start, whatever the load order). Reduce here rather than refuse: plan the
|
|
813
|
+
// prompt's cut against the request as it now is, carry it in memory, and save it at the first boundary, as any prompt's cut is saved.
|
|
814
|
+
if (!fits(tokens, limits(ctx).room, ctx) && !promptCut) {
|
|
815
|
+
const branch = ctx.sessionManager.getBranch(), last = branch.at(-1);
|
|
816
|
+
if (last?.type === "message" && last.message.role === "user") {
|
|
817
|
+
const header = ctx.sessionManager.getHeader();
|
|
818
|
+
const before = header && SessionManager.inMemory(ctx.cwd, undefined, [header, ...branch.slice(0, -1)]);
|
|
819
|
+
if (before) {
|
|
820
|
+
preflight(Object.create(ctx, { sessionManager: { value: before } }), incomingTokens(typeof last.message.content === "string" ? last.message.content : last.message.content.flatMap(b => b.type === "text" ? [b.text] : []).join("\n"), typeof last.message.content === "string" ? [] : last.message.content.filter((b) => b.type === "image")), ctx.getSystemPrompt(), pi.getActiveTools());
|
|
821
|
+
if (promptCut) {
|
|
822
|
+
messages = cutRequest(event.messages, ctx, promptCut);
|
|
823
|
+
tokens = requestTokens(messages, ctx.getSystemPrompt());
|
|
824
|
+
}
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
}
|
|
811
828
|
if (!fits(tokens, limits(ctx).room, ctx))
|
|
812
829
|
throw new CapacityError("Complete Pi context and response reserve exceed the estimated request budget");
|
|
813
830
|
if (recorder.enabled && !recorder.waitingForCut)
|
|
814
831
|
recorder.measureInline(() => {
|
|
815
832
|
recorder.request();
|
|
816
833
|
// No system prompt or hidden assistant blocks; no provider payload/headers.
|
|
817
|
-
const permitted =
|
|
834
|
+
const permitted = messages.filter(m => m.role !== "system" &&
|
|
818
835
|
!(m.role === "assistant" && m.content.some(b => b.type === "thinking")) &&
|
|
819
836
|
!(m.role === "custom" && options.recallPolicy?.privateCustomTypes?.includes(m.customType)));
|
|
820
837
|
recorder.capture("prepared-request", "public-context-with-system-hook-before-later-transforms-not-wire", { messages: permitted, estimatedInputTokens: tokens }, permitted.length !== event.messages.length);
|
|
821
838
|
});
|
|
822
839
|
if (tokens > 0 && Number.isSafeInteger(tokens))
|
|
823
840
|
pending = {
|
|
824
|
-
identity: identityFor(ctx), tokens, messages
|
|
841
|
+
identity: identityFor(ctx), tokens, messages, snapshot: structuredClone(convertToLlm(messages)),
|
|
825
842
|
};
|
|
843
|
+
if (messages !== event.messages)
|
|
844
|
+
return { messages };
|
|
826
845
|
}
|
|
827
846
|
catch (error) {
|
|
828
847
|
fail(error, ctx);
|
|
@@ -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 = "27bb99fa3ca595dac73089d18c4c3506073c5d3e3f778ea572708f6e7a49ffc3";
|
|
4
4
|
export interface Receipt {
|
|
5
5
|
id: string;
|
|
6
6
|
build: string;
|
package/package.json
CHANGED
package/src/build-id.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const BUILD_ID = "
|
|
1
|
+
export const BUILD_ID = "27bb99fa3ca595dac73089d18c4c3506073c5d3e3f778ea572708f6e7a49ffc3";
|
package/src/compaction.ts
CHANGED
|
@@ -8,7 +8,7 @@ import { projectedMessages } from "./omissions.js";
|
|
|
8
8
|
import { applyClips, clipBudgets, clipFor, type Clip } from "./clip.js";
|
|
9
9
|
import { DEFAULT_CUT_AT, bandOf, chooseCut, conversationTokens, decideCut, gateCut, incomingEventTokens, incomingTokens, measurableConversationTokens, planningReserve, projectedConversationTokens, requestTokens, systemPart, validCutAt,
|
|
10
10
|
type AgentMessage, type Messages, type Plan, type Target, type ToolShape } from "./budget.js";
|
|
11
|
-
import { isContextOverflow, type ToolResultMessage } from "@earendil-works/pi-ai";
|
|
11
|
+
import { isContextOverflow, type ImageContent, type ToolResultMessage } from "@earendil-works/pi-ai";
|
|
12
12
|
import { convertToLlm, SessionManager, SettingsManager, type ExtensionAPI, type ExtensionContext, type SessionEntry } from "@earendil-works/pi-coding-agent";
|
|
13
13
|
import { Type } from "typebox";
|
|
14
14
|
import { Check } from "typebox/value";
|
|
@@ -479,7 +479,7 @@ export async function installCompaction(pi: ExtensionAPI, options: CompactionOpt
|
|
|
479
479
|
// custom message starts). The cut is pi-tuck's own, planned as at a tool boundary. It is not Pi's: Pi's cut finder keeps the last
|
|
480
480
|
// keepRecentTokens, and where those are the whole conversation it has nothing to cut, so every later prompt was refused for good (t06 at
|
|
481
481
|
// Pi's defaults on a 32k window). Each request of the run carries the cut, and the run's first boundary saves it.
|
|
482
|
-
const preflight =
|
|
482
|
+
const preflight = (ctx: ExtensionContext, incomingPart: number, observedPrompt: string, tools: readonly string[]) => {
|
|
483
483
|
promptCut = undefined;
|
|
484
484
|
promptCutAt = ctx.sessionManager.getBranch().length;
|
|
485
485
|
if (!active()) return;
|
|
@@ -699,20 +699,35 @@ export async function installCompaction(pi: ExtensionAPI, options: CompactionOpt
|
|
|
699
699
|
if (!ctx.model) throw missingModel();
|
|
700
700
|
// The complete request, counted after Pi's conversion (summary/custom/bash envelopes), with the effective system once.
|
|
701
701
|
// Pi applies a forced prompt after this hook; the public prompt already observes it.
|
|
702
|
-
|
|
702
|
+
let messages = event.messages, tokens = requestTokens(messages, ctx.getSystemPrompt());
|
|
703
|
+
// The run's first request is over the room although the prompt's decision found it fit: something changed the request after that decision
|
|
704
|
+
// (another extension patching the system prompt in before_agent_start, whatever the load order). Reduce here rather than refuse: plan the
|
|
705
|
+
// prompt's cut against the request as it now is, carry it in memory, and save it at the first boundary, as any prompt's cut is saved.
|
|
706
|
+
if (!fits(tokens, limits(ctx).room, ctx) && !promptCut) {
|
|
707
|
+
const branch = ctx.sessionManager.getBranch(), last = branch.at(-1);
|
|
708
|
+
if (last?.type === "message" && last.message.role === "user") {
|
|
709
|
+
const header = ctx.sessionManager.getHeader();
|
|
710
|
+
const before = header && SessionManager.inMemory(ctx.cwd, undefined, [header, ...branch.slice(0, -1)]);
|
|
711
|
+
if (before) {
|
|
712
|
+
preflight(Object.create(ctx, { sessionManager: { value: before } }), incomingTokens(typeof last.message.content === "string" ? last.message.content : last.message.content.flatMap(b => b.type === "text" ? [b.text] : []).join("\n"), typeof last.message.content === "string" ? [] : last.message.content.filter((b): b is ImageContent => b.type === "image")), ctx.getSystemPrompt(), pi.getActiveTools());
|
|
713
|
+
if (promptCut) { messages = cutRequest(event.messages, ctx, promptCut); tokens = requestTokens(messages, ctx.getSystemPrompt()); }
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
}
|
|
703
717
|
if (!fits(tokens, limits(ctx).room, ctx))
|
|
704
718
|
throw new CapacityError("Complete Pi context and response reserve exceed the estimated request budget");
|
|
705
719
|
if (recorder.enabled && !recorder.waitingForCut) recorder.measureInline(() => {
|
|
706
720
|
recorder.request();
|
|
707
721
|
// No system prompt or hidden assistant blocks; no provider payload/headers.
|
|
708
|
-
const permitted =
|
|
722
|
+
const permitted = messages.filter(m => m.role !== "system" &&
|
|
709
723
|
!(m.role === "assistant" && m.content.some(b => b.type === "thinking")) &&
|
|
710
724
|
!(m.role === "custom" && options.recallPolicy?.privateCustomTypes?.includes(m.customType)));
|
|
711
725
|
recorder.capture("prepared-request", "public-context-with-system-hook-before-later-transforms-not-wire", { messages: permitted, estimatedInputTokens: tokens }, permitted.length !== event.messages.length);
|
|
712
726
|
});
|
|
713
727
|
if (tokens > 0 && Number.isSafeInteger(tokens)) pending = {
|
|
714
|
-
identity: identityFor(ctx), tokens, messages
|
|
728
|
+
identity: identityFor(ctx), tokens, messages, snapshot: structuredClone(convertToLlm(messages)),
|
|
715
729
|
};
|
|
730
|
+
if (messages !== event.messages) return { messages };
|
|
716
731
|
|
|
717
732
|
} catch (error) { fail(error, ctx); }
|
|
718
733
|
});
|