pi-tuck 1.1.2 → 1.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,25 @@
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.1.3] - 2026-11-15
7
+
8
+ ### Fixed
9
+
10
+ - **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
11
+ 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
12
+ were starting. The summary could then leave out the prompt that started the run, and pi-tuck's own prompt check refused with "the
13
+ 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
14
+ round, as a cut at a tool boundary does. Cuts without a steering message are unchanged.
15
+
16
+ ### Release gates
17
+
18
+ - **Shipped without a live gate: replay matches 1.1.2 byte for byte.** 29 recordings, 13,946 of 13,946 requests identical, 0 lost or
19
+ dead tasks; none of them contains a mid-run steer.
20
+ - **The defect is pinned by two tests that fail on 1.1.2 and pass here:** a scripted large parallel round followed by a steer, and a
21
+ replay of the recorded session where it was found (a public benchmark task, paths scrubbed).
22
+ - **Strict stress:** 322 cells, including 4 new steer cells, and the resumed-session and stand-down suites; 0 findings. Lifecycle with 40
23
+ seeds. Tests and CI. The packed tarball loaded in the real installed Pi.
24
+
6
25
  ## [1.1.2] - 2026-11-14
7
26
 
8
27
  ### Changed
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), 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.0`.
68
- - To pin a version, add it: `pi install npm:pi-tuck@1.1.0`.
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`.
69
69
 
70
70
  ## Uninstall
71
71
 
@@ -103,10 +103,12 @@ pi-tuck's tools appear only after its first cut. Before that there is nothing ou
103
103
 
104
104
  | Command | Does |
105
105
  |---|---|
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`, and how search works here. It is for you; the model sees nothing new. |
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
107
  | `/tuck-semantic on\|off\|status` | Turns semantic search on or off for this session, or shows its state. |
108
108
  | `/tuck-incident on\|next\|off\|status` | Records this session's compaction decisions to a file you can attach to a bug report. |
109
109
 
110
+ 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.
111
+
110
112
  `/compact` works as usual. Text after it does not steer the summary, because pi-tuck builds the summary from the session itself: since 1.0.19 it cuts as plain `/compact` does and says the text was not used. Pi's own setting `"compaction": { "enabled": false }` turns compaction off.
111
113
 
112
114
  ## What is proven, and what is not
@@ -136,6 +138,8 @@ Known limits today:
136
138
  - 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).
137
139
  - 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).
138
140
  - 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).
141
+ - 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).
139
143
  - 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).
140
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).
141
145
  - 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).
@@ -1 +1 @@
1
- export declare const BUILD_ID = "e36f2c823c0d56405dab4cda3f16894a034bdb082d322c30587474d15b332b70";
1
+ export declare const BUILD_ID = "d3c9d03a4fd2a19793701c4c043b680a24b0a5f219c4c3ab6f7c3a232feb333e";
@@ -1 +1 @@
1
- export const BUILD_ID = "e36f2c823c0d56405dab4cda3f16894a034bdb082d322c30587474d15b332b70";
1
+ export const BUILD_ID = "d3c9d03a4fd2a19793701c4c043b680a24b0a5f219c4c3ab6f7c3a232feb333e";
@@ -837,8 +837,9 @@ export async function installCompaction(pi, options = {}) {
837
837
  // The cut before a run, decided on `input` while the session is idle; before_agent_start decides only for a run no input started (one a
838
838
  // 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
839
839
  // keepRecentTokens, and where those are the whole conversation it has nothing to cut, so every later prompt was refused for good (t06 at
840
- // Pi's defaults on a 32k window). Each request of the run carries the cut, and the run's first boundary saves it.
841
- const preflight = (ctx, incomingPart, incomingMessages, observedPrompt, tools, hostSnapshot) => {
840
+ // Pi's defaults on a 32k window). Each request carries the cut until the next boundary saves it. A late steer uses the same path with
841
+ // its existing run owner's entry protected; an incoming prompt that starts a run has no saved owner yet.
842
+ const preflight = (ctx, incomingPart, incomingMessages, observedPrompt, tools, hostSnapshot, protectedId) => {
842
843
  if (standDown(ctx))
843
844
  return;
844
845
  run.cut.clear();
@@ -874,7 +875,9 @@ export async function installCompaction(pi, options = {}) {
874
875
  const reserve = planReserve(target, targetRoom, targetBand, mandatory, ctx);
875
876
  // Only a due cut re-renders a summary that sits alone in the session: inside the band a cut is opportunistic, and a smaller summary
876
877
  // there buys nothing the request needed and costs history the next recall would have found.
877
- const draft = tuckObservedDraft(tuck, { branchEntries: ctx.sessionManager.getBranch(), tokensBefore: before, previousSummary, newPrompt: true, reRenderSummary: !opportunistic }, ctx, reserve, plannerMeasureFor(ctx), options.recallPolicy, false);
878
+ // A steer joins the admitted run: keep its starting prompt and the unexposed tool round, just as at a tool boundary.
879
+ const draft = tuckObservedDraft(tuck, { branchEntries: ctx.sessionManager.getBranch(), tokensBefore: before, previousSummary,
880
+ newPrompt: !protectedId, protectedPromptEntryId: protectedId, reRenderSummary: !opportunistic }, ctx, reserve, plannerMeasureFor(ctx), options.recallPolicy, Boolean(protectedId));
878
881
  if (!draft.compaction)
879
882
  return { draft: false, capacityRejected: Boolean(draft.capacityRejected), reason: draft.unavailable };
880
883
  const candidate = new PendingCut();
@@ -889,7 +892,7 @@ export async function installCompaction(pi, options = {}) {
889
892
  if (hardLine > room && (decision.kind === "defer" || decision.kind === "fault")) {
890
893
  decision = fits(before + mandatory, hardLine, ctx) ? { kind: "none" } :
891
894
  fits(mandatory, hardLine, ctx) ? decide(hardLine, hardLine, false) : { kind: "defer" };
892
- decision = clampAboveRoom(decision, ctx, room, hardLine, candidate => (candidate.kind === "cut" ? candidate.plan.after : before) + mandatory, candidate => projectedRequest(candidate.kind === "cut" ? candidate.plan.messages : saved, ctx, hostInput, incomingMessages, observedPrompt, tools, candidate.kind === "cut"), target => decide(target, target <= room ? band : target, false), () => deepestDecision(ctx, true, false));
895
+ decision = clampAboveRoom(decision, ctx, room, hardLine, candidate => (candidate.kind === "cut" ? candidate.plan.after : before) + mandatory, candidate => projectedRequest(candidate.kind === "cut" ? candidate.plan.messages : saved, ctx, hostInput, incomingMessages, observedPrompt, tools, candidate.kind === "cut"), target => decide(target, target <= room ? band : target, false), () => deepestDecision(ctx, !protectedId, Boolean(protectedId)));
893
896
  }
894
897
  if (decision.kind === "defer")
895
898
  return;
@@ -898,7 +901,7 @@ export async function installCompaction(pi, options = {}) {
898
901
  return;
899
902
  if (decision.kind === "fault")
900
903
  throw new (decision.capacity ? CapacityError : Refusal)(decision.message);
901
- const compaction = captureDraft(decision.plan.compaction, ctx, decision.plan.reserve, "prompt", before, false, false, previousSummary, { response, host, mandatory, target: decision.target, margin: room - band });
904
+ const compaction = captureDraft(decision.plan.compaction, ctx, decision.plan.reserve, "prompt", before, Boolean(protectedId), false, previousSummary, { response, host, mandatory, target: decision.target, margin: room - band });
902
905
  run.cut.plan({ type: "compaction", summary: compaction.summary, firstKeptEntryId: compaction.firstKeptEntryId, tokensBefore: before, details: compaction.details }, branchLength);
903
906
  };
904
907
  pi.on("before_agent_start", async (event, ctx) => {
@@ -953,7 +956,7 @@ export async function installCompaction(pi, options = {}) {
953
956
  const system = requestSystemPart(ctx.getSystemPrompt(), pi.getActiveTools(), saved, ctx.getSystemPrompt());
954
957
  if (fits(conversationTokens(saved) + system + incoming + host, limits(ctx).room, ctx))
955
958
  return;
956
- preflight(ctx, incoming, [message], ctx.getSystemPrompt(), pi.getActiveTools(), hostInput);
959
+ preflight(ctx, incoming, [message], ctx.getSystemPrompt(), pi.getActiveTools(), hostInput, protectedPrompt(ctx));
957
960
  syncHistoryTools(ctx);
958
961
  }
959
962
  catch (error) {
@@ -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 = "e36f2c823c0d56405dab4cda3f16894a034bdb082d322c30587474d15b332b70";
3
+ export declare const DIAGNOSTIC_BUILD = "d3c9d03a4fd2a19793701c4c043b680a24b0a5f219c4c3ab6f7c3a232feb333e";
4
4
  export interface Receipt {
5
5
  id: string;
6
6
  build: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-tuck",
3
- "version": "1.1.2",
3
+ "version": "1.1.3",
4
4
  "description": "Deterministic compaction for Pi with no model call, plus exact recall of earlier history. Search by meaning on Apple silicon.",
5
5
  "keywords": [
6
6
  "pi-package",
package/src/build-id.ts CHANGED
@@ -1 +1 @@
1
- export const BUILD_ID = "e36f2c823c0d56405dab4cda3f16894a034bdb082d322c30587474d15b332b70";
1
+ export const BUILD_ID = "d3c9d03a4fd2a19793701c4c043b680a24b0a5f219c4c3ab6f7c3a232feb333e";
package/src/compaction.ts CHANGED
@@ -728,8 +728,9 @@ export async function installCompaction(pi: ExtensionAPI, options: CompactionOpt
728
728
  // The cut before a run, decided on `input` while the session is idle; before_agent_start decides only for a run no input started (one a
729
729
  // 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
730
730
  // keepRecentTokens, and where those are the whole conversation it has nothing to cut, so every later prompt was refused for good (t06 at
731
- // Pi's defaults on a 32k window). Each request of the run carries the cut, and the run's first boundary saves it.
732
- const preflight = (ctx: ExtensionContext, incomingPart: number, incomingMessages: Messages, observedPrompt: string, tools: readonly string[], hostSnapshot?: Messages) => {
731
+ // Pi's defaults on a 32k window). Each request carries the cut until the next boundary saves it. A late steer uses the same path with
732
+ // its existing run owner's entry protected; an incoming prompt that starts a run has no saved owner yet.
733
+ const preflight = (ctx: ExtensionContext, incomingPart: number, incomingMessages: Messages, observedPrompt: string, tools: readonly string[], hostSnapshot?: Messages, protectedId?: string) => {
733
734
  if (standDown(ctx)) return;
734
735
  run!.cut.clear();
735
736
  const branchLength = ctx.sessionManager.getBranch().length;
@@ -760,7 +761,9 @@ export async function installCompaction(pi: ExtensionAPI, options: CompactionOpt
760
761
  const reserve = planReserve(target, targetRoom, targetBand, mandatory, ctx);
761
762
  // Only a due cut re-renders a summary that sits alone in the session: inside the band a cut is opportunistic, and a smaller summary
762
763
  // there buys nothing the request needed and costs history the next recall would have found.
763
- const draft = tuckObservedDraft(tuck, { branchEntries: ctx.sessionManager.getBranch(), tokensBefore: before, previousSummary, newPrompt: true, reRenderSummary: !opportunistic }, ctx, reserve, plannerMeasureFor(ctx), options.recallPolicy, false);
764
+ // A steer joins the admitted run: keep its starting prompt and the unexposed tool round, just as at a tool boundary.
765
+ const draft = tuckObservedDraft(tuck, { branchEntries: ctx.sessionManager.getBranch(), tokensBefore: before, previousSummary,
766
+ newPrompt: !protectedId, protectedPromptEntryId: protectedId, reRenderSummary: !opportunistic }, ctx, reserve, plannerMeasureFor(ctx), options.recallPolicy, Boolean(protectedId));
764
767
  if (!draft.compaction) return { draft: false, capacityRejected: Boolean(draft.capacityRejected), reason: draft.unavailable };
765
768
  const candidate = new PendingCut();
766
769
  candidate.plan({ type: "compaction", ...draft.compaction, tokensBefore: before }, branchLength);
@@ -778,13 +781,13 @@ export async function installCompaction(pi: ExtensionAPI, options: CompactionOpt
778
781
  candidate => (candidate.kind === "cut" ? candidate.plan.after : before) + mandatory,
779
782
  candidate => projectedRequest(candidate.kind === "cut" ? candidate.plan.messages : saved, ctx, hostInput, incomingMessages, observedPrompt, tools, candidate.kind === "cut"),
780
783
  target => decide(target, target <= room ? band : target, false),
781
- () => deepestDecision(ctx, true, false));
784
+ () => deepestDecision(ctx, !protectedId, Boolean(protectedId)));
782
785
  }
783
786
  if (decision.kind === "defer") return;
784
787
  // An opportunistic cut inside the band that cannot reach it is no fault: the request goes to the guard.
785
788
  if (decision.kind === "none") return;
786
789
  if (decision.kind === "fault") throw new (decision.capacity ? CapacityError : Refusal)(decision.message);
787
- const compaction = captureDraft(decision.plan.compaction, ctx, decision.plan.reserve, "prompt", before, false, false, previousSummary,
790
+ const compaction = captureDraft(decision.plan.compaction, ctx, decision.plan.reserve, "prompt", before, Boolean(protectedId), false, previousSummary,
788
791
  { response, host, mandatory, target: decision.target, margin: room - band });
789
792
  run!.cut.plan({ type: "compaction", summary: compaction.summary, firstKeptEntryId: compaction.firstKeptEntryId, tokensBefore: before, details: compaction.details }, branchLength);
790
793
  };
@@ -829,7 +832,7 @@ export async function installCompaction(pi: ExtensionAPI, options: CompactionOpt
829
832
  const hostInput = hostMessages(ctx), host = conversationTokens(hostInput);
830
833
  const system = requestSystemPart(ctx.getSystemPrompt(), pi.getActiveTools(), saved, ctx.getSystemPrompt());
831
834
  if (fits(conversationTokens(saved) + system + incoming + host, limits(ctx).room, ctx)) return;
832
- preflight(ctx, incoming, [message], ctx.getSystemPrompt(), pi.getActiveTools(), hostInput);
835
+ preflight(ctx, incoming, [message], ctx.getSystemPrompt(), pi.getActiveTools(), hostInput, protectedPrompt(ctx));
833
836
  syncHistoryTools(ctx);
834
837
  } catch (error) { fail(error, ctx); }
835
838
  });