pi-dynamic-context-pruning 0.1.11 → 0.1.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +6 -38
  2. package/index.ts +2124 -1980
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -145,7 +145,7 @@ recoup the one-time cache-bust cost via the recurring saving. The gate accepts
145
145
  a batch of candidates only if `breakEvenCalls` is at most the effective
146
146
  threshold for the current state (`idle=22`, `mid_loop=1` by default,
147
147
  calibrated from the representative-corpus benchmark — see the calibration
148
- note under [Configuration](#configuration) and the [Roadmap](#roadmap) evidence).
148
+ note under [Configuration](#configuration)).
149
149
 
150
150
  All candidates proposed in the same `context` call share one cache bust (since
151
151
  a prompt cache is a single linear prefix), so they're evaluated and
@@ -262,7 +262,7 @@ Notes:
262
262
  `idle` if the most recent relevant message is a user message (this is the
263
263
  first LLM call of the turn), `mid_loop` if it's an assistant message or a
264
264
  tool result (the agent is iterating mid-turn). The representative-corpus
265
- benchmark (see [Roadmap](#roadmap)) was re-derived against this same
265
+ benchmark was re-derived against this same
266
266
  runtime-observable definition and found the state-split REVERSED from an
267
267
  earlier turn-end-based analysis: at r=0.1, `idle` candidates now carry
268
268
  essentially all the realized net benefit and `mid_loop` candidates carry
@@ -277,8 +277,7 @@ Notes:
277
277
  impossible. Set `mid_loop` back to `22` to restore the old parity behavior.
278
278
  - `gate.breakEvenThreshold`'s default of `22` is calibrated from the
279
279
  representative-corpus benchmark at `cachedPriceRatio` r=0.1 (aggressive
280
- prompt caching, the common case) — see [Roadmap](#roadmap) for the full
281
- evidence and its ratio-sensitivity caveats. It is **provider/ratio-
280
+ prompt caching, the common case). It is **provider/ratio-
282
281
  dependent**: the optimal threshold rises as caching gets weaker (T=29 at
283
282
  r=0.25, T=54 at r=0.5, T=58 at r=0.9 on the same corpus).
284
283
 
@@ -440,40 +439,9 @@ candidates — see the corpus-choice note above) produced:
440
439
  more amortization runway than the earlier small-corpus run showed, because
441
440
  this corpus is dominated by long, tool-heavy agent sessions rather than
442
441
  short orchestrator sessions.
443
- - **Hindsight-optimal break-even threshold `T`** (maximizes total *realized*
444
- net benefit), by cached-price ratio `r`, split overall / mid_loop / idle:
445
-
446
- | ratio `r` | overall `T` (benefit) | mid_loop `T` (benefit) | idle `T` (benefit) |
447
- | --- | --- | --- | --- |
448
- | 0.1 | T=22 (~20.6k) | T=22 (~20.6k) | T=1 (0 — zero benefit) |
449
- | 0.25 | T=29 (~1.54M) | T=29 (~1.54M) | T=12 (~4.0k) |
450
- | 0.5 | T=54 (~8.06M) | T=54 (~8.06M) | T=27 (~37.2k) |
451
- | 0.9 | T=58 (~24.7M) | T=58 (~24.2M) | T=21 (~459k) |
452
-
453
- **Reading**: `mid_loop` candidates carry essentially all of the realized
454
- benefit; `idle` candidates carry essentially none (literally zero at r=0.1).
455
- At r=0.1 (aggressive prompt caching, the common Anthropic case) the total
456
- realized benefit across the whole 1,390-session corpus is only ~20.6k
457
- token-units — economically marginal, on the order of pennies. Savings only
458
- become material at weaker caching, r>=0.25.
459
-
460
- **pe-zy4s update (2026-07-08): this idle/mid_loop split used a turn-END
461
- definition** ("idle" = this call IS the turn's final assistant message, only
462
- knowable in hindsight via replay) **that was never runtime-observable.** Once
463
- real runtime agent-state detection landed (turn-START definition: "idle" =
464
- this is the FIRST LLM call of a turn; see the config-notes bullet above), the
465
- benchmark's candidate labeling was aligned to that same definition and
466
- re-derived on the representative corpus (460 gate-eligible candidates on the
467
- current `~/.the-last-harness/agent/sessions` corpus). The split **reverses**:
468
- at r=0.1, `idle` (T=22, ~20.6k realized net benefit) now carries essentially
469
- all the value, and `mid_loop` (T=1, ~0 realized net benefit) carries
470
- essentially none. Under that ticket's decision rule (stricter idle default
471
- only if idle is shown ~worthless), parity (`22`/`22`) was retained at the time.
472
- The 2026-09-08 follow-up supersedes that default with `idle=22` / `mid_loop=1`,
473
- using the measured mid-loop result to choose a conservative threshold (see
474
- [Configuration](#configuration) for the evidence and limitations). The table
475
- above is retained as the historical turn-END-definition record; it no longer
476
- reflects how the runtime classifies agent state.
442
+
443
+ Shipped gate defaults remain `idle=22` / `mid_loop=1` (see
444
+ [Configuration](#configuration)).
477
445
 
478
446
  **This reframes, rather than weakens, the case for v2.** Small deterministic
479
447
  removals (dedupe/error-purge/superseded-file-ops) structurally cannot beat