@diegopetrucci/pi-extensions 0.1.67 → 0.1.68
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.
|
@@ -130,10 +130,10 @@ Where `r` is `gate.cachedPriceRatio` — the fraction of full price still paid
|
|
|
130
130
|
for cached tokens (default `0.1`, i.e. cached tokens cost ~10% of fresh
|
|
131
131
|
tokens). `breakEvenCalls` is how many subsequent LLM calls are needed to
|
|
132
132
|
recoup the one-time cache-bust cost via the recurring saving. The gate accepts
|
|
133
|
-
a batch of candidates only if `breakEvenCalls
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
[Roadmap](#roadmap) evidence).
|
|
133
|
+
a batch of candidates only if `breakEvenCalls` is at most the effective
|
|
134
|
+
threshold for the current state (`idle=22`, `mid_loop=1` by default,
|
|
135
|
+
calibrated from the representative-corpus benchmark — see the calibration
|
|
136
|
+
note under [Configuration](#configuration) and the [Roadmap](#roadmap) evidence).
|
|
137
137
|
|
|
138
138
|
All candidates proposed in the same `context` call share one cache bust (since
|
|
139
139
|
a prompt cache is a single linear prefix), so they're evaluated and
|
|
@@ -179,7 +179,7 @@ branch:
|
|
|
179
179
|
/context-pruning gate <on|off|always-apply>
|
|
180
180
|
```
|
|
181
181
|
|
|
182
|
-
- `status`: enabled state, gate mode/
|
|
182
|
+
- `status`: enabled state, gate mode/effective per-state thresholds/ratio, per-strategy on/off
|
|
183
183
|
state, protection counts, last call's raw/effective/saved token snapshot,
|
|
184
184
|
and current context usage.
|
|
185
185
|
- `stats`: cumulative tokens saved, overall and per strategy.
|
|
@@ -223,7 +223,7 @@ never required to exist. Full shape, with defaults:
|
|
|
223
223
|
"mode": "on",
|
|
224
224
|
"cachedPriceRatio": 0.1,
|
|
225
225
|
"breakEvenThreshold": 22,
|
|
226
|
-
"breakEvenThresholdByState": { "idle": 22, "mid_loop":
|
|
226
|
+
"breakEvenThresholdByState": { "idle": 22, "mid_loop": 1 }
|
|
227
227
|
}
|
|
228
228
|
}
|
|
229
229
|
```
|
|
@@ -243,7 +243,8 @@ Notes:
|
|
|
243
243
|
break-even math (`gate.*`), which is a separate, later check on whatever
|
|
244
244
|
survives this floor.
|
|
245
245
|
- `gate.breakEvenThresholdByState` lets `idle` vs `mid_loop` agent states use
|
|
246
|
-
different thresholds;
|
|
246
|
+
different thresholds; `idle` defaults to `22` and
|
|
247
|
+
`mid_loop` defaults to `1`. Real
|
|
247
248
|
mid-loop/idle detection is wired through the `context` event handler
|
|
248
249
|
(pe-zy4s): the state is classified straight from the message payload —
|
|
249
250
|
`idle` if the most recent relevant message is a user message (this is the
|
|
@@ -253,9 +254,15 @@ Notes:
|
|
|
253
254
|
runtime-observable definition and found the state-split REVERSED from an
|
|
254
255
|
earlier turn-end-based analysis: at r=0.1, `idle` candidates now carry
|
|
255
256
|
essentially all the realized net benefit and `mid_loop` candidates carry
|
|
256
|
-
essentially none.
|
|
257
|
-
|
|
258
|
-
|
|
257
|
+
essentially none. At r=0.1, the measured corpus therefore supports a
|
|
258
|
+
conservative `mid_loop=1` default, while `idle` remains `22`. Mid-loop
|
|
259
|
+
pruning can amortize over enough subsequent calls, but the observed
|
|
260
|
+
candidates did not justify a more permissive threshold. Turn-start
|
|
261
|
+
classification does not imply the provider cache is cold. The reported
|
|
262
|
+
field capture (2026-09-08: a mid_loop prune at `T=22` invalidated 81% of a
|
|
263
|
+
warm request prefix between consecutive LLM calls separated only by a
|
|
264
|
+
toolResult) illustrates cache invalidation, not proof that amortization is
|
|
265
|
+
impossible. Set `mid_loop` back to `22` to restore the old parity behavior.
|
|
259
266
|
- `gate.breakEvenThreshold`'s default of `22` is calibrated from the
|
|
260
267
|
representative-corpus benchmark at `cachedPriceRatio` r=0.1 (aggressive
|
|
261
268
|
prompt caching, the common case) — see [Roadmap](#roadmap) for the full
|
|
@@ -448,11 +455,13 @@ re-derived on the representative corpus (460 gate-eligible candidates on the
|
|
|
448
455
|
current `~/.the-last-harness/agent/sessions` corpus). The split **reverses**:
|
|
449
456
|
at r=0.1, `idle` (T=22, ~20.6k realized net benefit) now carries essentially
|
|
450
457
|
all the value, and `mid_loop` (T=1, ~0 realized net benefit) carries
|
|
451
|
-
essentially none.
|
|
452
|
-
is shown ~worthless),
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
458
|
+
essentially none. Under that ticket's decision rule (stricter idle default
|
|
459
|
+
only if idle is shown ~worthless), parity (`22`/`22`) was retained at the time.
|
|
460
|
+
The 2026-09-08 follow-up supersedes that default with `idle=22` / `mid_loop=1`,
|
|
461
|
+
using the measured mid-loop result to choose a conservative threshold (see
|
|
462
|
+
[Configuration](#configuration) for the evidence and limitations). The table
|
|
463
|
+
above is retained as the historical turn-END-definition record; it no longer
|
|
464
|
+
reflects how the runtime classifies agent state.
|
|
456
465
|
|
|
457
466
|
**This reframes, rather than weakens, the case for v2.** Small deterministic
|
|
458
467
|
removals (dedupe/error-purge/superseded-file-ops) structurally cannot beat
|
|
@@ -114,6 +114,22 @@ const DEFAULT_CACHED_PRICE_RATIO = 0.1;
|
|
|
114
114
|
*/
|
|
115
115
|
const DEFAULT_BREAK_EVEN_THRESHOLD = 22;
|
|
116
116
|
|
|
117
|
+
/**
|
|
118
|
+
* Default mid_loop break-even threshold (pe-zy4s follow-up). The package's own
|
|
119
|
+
* representative-corpus benchmark (turn-START state definition — the same one
|
|
120
|
+
* the runtime `context` handler uses) favored rejecting mid_loop candidates
|
|
121
|
+
* at cachedPriceRatio r=0.1 (mid_loop-optimal T=1, total realized
|
|
122
|
+
* net benefit ~0.0). This supports a conservative default for the measured
|
|
123
|
+
* corpus, not a universal claim that mid_loop pruning cannot pay off.
|
|
124
|
+
* The reported 2026-09-08 byte-level capture (a mid_loop prune at T=22
|
|
125
|
+
* invalidating 81% of a warm request prefix) illustrates cache invalidation,
|
|
126
|
+
* not an inability to amortize it: enough subsequent calls can recoup a
|
|
127
|
+
* one-time bust. Idle keeps T=22; turn-start classification does not imply
|
|
128
|
+
* the provider cache is cold. Users who want the old behavior can override
|
|
129
|
+
* via gate.breakEvenThresholdByState.mid_loop.
|
|
130
|
+
*/
|
|
131
|
+
const DEFAULT_MID_LOOP_BREAK_EVEN_THRESHOLD = 1;
|
|
132
|
+
|
|
117
133
|
/** Tool names never pruned by default: orchestration/subagent-style tools and todo-like state. */
|
|
118
134
|
const DEFAULT_PROTECTED_TOOL_NAMES = [
|
|
119
135
|
"todo",
|
|
@@ -222,20 +238,19 @@ export type GateMode = "on" | "off" | "always-apply";
|
|
|
222
238
|
* turn-START "idle" population (calls made at the start of a turn) carries
|
|
223
239
|
* essentially ALL the realized net benefit (idle-optimal T=22, total realized
|
|
224
240
|
* net benefit ~20,594 token-units), while "mid_loop" carries essentially NONE
|
|
225
|
-
* (mid_loop-optimal T=1, total realized net benefit ~0.0
|
|
226
|
-
* candidate is ever worth accepting at r=0.1 under this definition). This is
|
|
241
|
+
* (mid_loop-optimal T=1, total realized net benefit ~0.0 on this corpus). This is
|
|
227
242
|
* the OPPOSITE of what the pe-c5n9 evidence (measured under the old,
|
|
228
243
|
* non-runtime-observable turn-END definition) suggested.
|
|
229
244
|
*
|
|
230
245
|
* Per the pe-zy4s decision rule (stricter idle default only if idle itself is
|
|
231
246
|
* shown to be ~worthless): idle is NOT worthless here -- it is the ONLY state
|
|
232
|
-
* carrying value at r=0.1 -- so
|
|
233
|
-
*
|
|
234
|
-
* (
|
|
235
|
-
*
|
|
236
|
-
*
|
|
237
|
-
*
|
|
238
|
-
*
|
|
247
|
+
* carrying value at r=0.1 -- so the idle default stays at
|
|
248
|
+
* DEFAULT_BREAK_EVEN_THRESHOLD. The mid_loop default, by the same benchmark,
|
|
249
|
+
* is now DEFAULT_MID_LOOP_BREAK_EVEN_THRESHOLD (=1): the measured candidates
|
|
250
|
+
* did not justify a more permissive threshold at r=0.1. Mid_loop pruning can
|
|
251
|
+
* still amortize over enough subsequent calls; state alone does not establish
|
|
252
|
+
* cache warmth or profitability. Both defaults remain config-overridable via
|
|
253
|
+
* gate.breakEvenThresholdByState.
|
|
239
254
|
*/
|
|
240
255
|
export type AgentState = "idle" | "mid_loop";
|
|
241
256
|
|
|
@@ -285,7 +300,7 @@ export function defaultConfig(): DynamicContextPruningConfig {
|
|
|
285
300
|
mode: "on",
|
|
286
301
|
cachedPriceRatio: DEFAULT_CACHED_PRICE_RATIO,
|
|
287
302
|
breakEvenThreshold: DEFAULT_BREAK_EVEN_THRESHOLD,
|
|
288
|
-
breakEvenThresholdByState: { idle: DEFAULT_BREAK_EVEN_THRESHOLD, mid_loop:
|
|
303
|
+
breakEvenThresholdByState: { idle: DEFAULT_BREAK_EVEN_THRESHOLD, mid_loop: DEFAULT_MID_LOOP_BREAK_EVEN_THRESHOLD },
|
|
289
304
|
},
|
|
290
305
|
};
|
|
291
306
|
}
|
|
@@ -2410,7 +2425,7 @@ export function formatStatusReport(input: StatusReportInput): string[] {
|
|
|
2410
2425
|
const lines: string[] = [];
|
|
2411
2426
|
lines.push(`Dynamic context pruning: ${config.enabled ? "ENABLED" : "disabled"}`);
|
|
2412
2427
|
lines.push(
|
|
2413
|
-
`Gate: mode=${config.gate.mode}
|
|
2428
|
+
`Gate: mode=${config.gate.mode} thresholds={idle:${resolveBreakEvenThreshold(config.gate, "idle")}, mid_loop:${resolveBreakEvenThreshold(config.gate, "mid_loop")}} cachedPriceRatio=${config.gate.cachedPriceRatio}`,
|
|
2414
2429
|
);
|
|
2415
2430
|
lines.push("Strategies:");
|
|
2416
2431
|
lines.push(` dedupe: ${config.strategies.dedupe.enabled ? "on" : "off"}`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@diegopetrucci/pi-extensions",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.68",
|
|
4
4
|
"description": "A collection of pi extensions and skills for annotation UIs, context management, workflow audits, contrarian review, review-comment triage, notifications, brrr push alerts, safety guards, GitHub research, repo-local knowledge, todos, tool rendering, model/provider helpers, and Xiaohei-style article illustrations.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|