pi-dynamic-context-pruning 0.1.5 → 0.1.6
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/README.md +78 -11
- package/index.ts +171 -21
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -230,19 +230,32 @@ never required to exist. Full shape, with defaults:
|
|
|
230
230
|
|
|
231
231
|
Notes:
|
|
232
232
|
|
|
233
|
-
- `thresholds.minCharsSaved` is
|
|
234
|
-
|
|
235
|
-
|
|
233
|
+
- `thresholds.minCharsSaved` is a minimum-size floor enforced against fresh
|
|
234
|
+
**automatic** strategy proposals only, before the net-benefit gate runs: a
|
|
235
|
+
text-only candidate whose raw character savings (original text chars minus
|
|
236
|
+
placeholder chars) fall below this value is dropped up front and never
|
|
237
|
+
reaches gate or batch consideration. A tool-result candidate containing one
|
|
238
|
+
or more image blocks bypasses this raw-text floor (images do not receive
|
|
239
|
+
synthetic character counts) and is evaluated by the existing token-based
|
|
240
|
+
net-benefit gate. Manual prunes (`/prune`) and already-persisted/replayed
|
|
241
|
+
decisions always bypass this floor, same as the gate. Set to `0` to disable
|
|
242
|
+
filtering entirely. This is independent of the net-benefit gate's
|
|
243
|
+
break-even math (`gate.*`), which is a separate, later check on whatever
|
|
244
|
+
survives this floor.
|
|
236
245
|
- `gate.breakEvenThresholdByState` lets `idle` vs `mid_loop` agent states use
|
|
237
246
|
different thresholds; both default to `gate.breakEvenThreshold`. Real
|
|
238
|
-
mid-loop/idle detection
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
247
|
+
mid-loop/idle detection is wired through the `context` event handler
|
|
248
|
+
(pe-zy4s): the state is classified straight from the message payload —
|
|
249
|
+
`idle` if the most recent relevant message is a user message (this is the
|
|
250
|
+
first LLM call of the turn), `mid_loop` if it's an assistant message or a
|
|
251
|
+
tool result (the agent is iterating mid-turn). The representative-corpus
|
|
252
|
+
benchmark (see [Roadmap](#roadmap)) was re-derived against this same
|
|
253
|
+
runtime-observable definition and found the state-split REVERSED from an
|
|
254
|
+
earlier turn-end-based analysis: at r=0.1, `idle` candidates now carry
|
|
255
|
+
essentially all the realized net benefit and `mid_loop` candidates carry
|
|
256
|
+
essentially none. Since `idle` is not the worthless state under this
|
|
257
|
+
definition, both states are kept at parity (`22`/`22`) rather than forcing
|
|
258
|
+
a stricter default in either direction.
|
|
246
259
|
- `gate.breakEvenThreshold`'s default of `22` is calibrated from the
|
|
247
260
|
representative-corpus benchmark at `cachedPriceRatio` r=0.1 (aggressive
|
|
248
261
|
prompt caching, the common case) — see [Roadmap](#roadmap) for the full
|
|
@@ -296,8 +309,46 @@ Options:
|
|
|
296
309
|
- `--ratio R`: cached-price ratio(s) to model; repeatable and/or
|
|
297
310
|
comma-separated (e.g. `--ratio 0.1,0.2`). Default: `0.1`.
|
|
298
311
|
- `--json`: emit a full machine-readable JSON dump instead of aligned text.
|
|
312
|
+
- `--simulate-compression`: additionally SIMULATE v2-style range compression
|
|
313
|
+
(docs/v2-design.md §1/§4 go/no-go evidence) alongside — never mixed into —
|
|
314
|
+
the deterministic results. See below.
|
|
315
|
+
- `--sim-summary-fraction F`: summary size as a fraction of range tokens;
|
|
316
|
+
repeatable/comma-separated (e.g. `--sim-summary-fraction 0.1,0.15,0.3`).
|
|
317
|
+
Default: `0.15`.
|
|
318
|
+
- `--sim-summary-min-tokens N`: floor on summary tokens regardless of
|
|
319
|
+
fraction. Default: `200`.
|
|
320
|
+
- `--sim-summarizer-cost-mult M`: relative per-token price of the summarizer
|
|
321
|
+
call vs. the main model. Default: `1.0` (same per-token price; a
|
|
322
|
+
deliberate simplification that ignores summarizer latency/availability).
|
|
323
|
+
- `--sim-min-range-tokens N`: minimum contiguous range size to be
|
|
324
|
+
considered. Default: `2000`.
|
|
299
325
|
- `--help`: print usage.
|
|
300
326
|
|
|
327
|
+
### Compression-simulation mode (`--simulate-compression`)
|
|
328
|
+
|
|
329
|
+
This is a v2 go/no-go evidence generator that does **not** require building
|
|
330
|
+
v2: it identifies plausible v2-style `compress` (range mode) opportunities —
|
|
331
|
+
contiguous spans of complete, non-recent, non-protected messages, never
|
|
332
|
+
splitting a toolCall/toolResult pair — during the same replay pass, and
|
|
333
|
+
models the outcome:
|
|
334
|
+
|
|
335
|
+
```text
|
|
336
|
+
summaryTokens = max(fraction * rangeTokens, summaryMinTokens)
|
|
337
|
+
oneTimeCost = cacheBustPenalty(earliest range position)
|
|
338
|
+
+ summarizerCostMult * (rangeTokens + summaryTokens)
|
|
339
|
+
recurringSaving = r * (rangeTokens - summaryTokens)
|
|
340
|
+
realizedNetBenefit = actualRemainingCalls * recurringSaving - oneTimeCost
|
|
341
|
+
```
|
|
342
|
+
|
|
343
|
+
Each distinct range is recorded once, at the earliest call boundary where it
|
|
344
|
+
first exists and meets `--sim-min-range-tokens`; ranges never overlap. The
|
|
345
|
+
same auto-expanding break-even threshold sweep as the deterministic
|
|
346
|
+
strategies runs against this separate SIMULATED population, reported
|
|
347
|
+
side-by-side with (but never combined with) the deterministic results — the
|
|
348
|
+
two populations are computed **independently**; a simulated range may fully
|
|
349
|
+
contain deterministic candidates, and no overlap/interaction between the two
|
|
350
|
+
is modeled or netted out.
|
|
351
|
+
|
|
301
352
|
With no positional paths, it defaults to every `*.jsonl` file found
|
|
302
353
|
recursively under `~/.pi/agent/sessions`.
|
|
303
354
|
|
|
@@ -387,6 +438,22 @@ realized benefit across the whole 1,390-session corpus is only ~20.6k
|
|
|
387
438
|
token-units — economically marginal, on the order of pennies. Savings only
|
|
388
439
|
become material at weaker caching, r>=0.25.
|
|
389
440
|
|
|
441
|
+
**pe-zy4s update (2026-07-08): this idle/mid_loop split used a turn-END
|
|
442
|
+
definition** ("idle" = this call IS the turn's final assistant message, only
|
|
443
|
+
knowable in hindsight via replay) **that was never runtime-observable.** Once
|
|
444
|
+
real runtime agent-state detection landed (turn-START definition: "idle" =
|
|
445
|
+
this is the FIRST LLM call of a turn; see the config-notes bullet above), the
|
|
446
|
+
benchmark's candidate labeling was aligned to that same definition and
|
|
447
|
+
re-derived on the representative corpus (460 gate-eligible candidates on the
|
|
448
|
+
current `~/.the-last-harness/agent/sessions` corpus). The split **reverses**:
|
|
449
|
+
at r=0.1, `idle` (T=22, ~20.6k realized net benefit) now carries essentially
|
|
450
|
+
all the value, and `mid_loop` (T=1, ~0 realized net benefit) carries
|
|
451
|
+
essentially none. Per the decision rule (stricter idle default only if idle
|
|
452
|
+
is shown ~worthless), this evidence does **not** support a stricter idle
|
|
453
|
+
default — parity (`22`/`22`) is kept. The table above is retained as the
|
|
454
|
+
historical turn-END-definition record; it no longer reflects how the runtime
|
|
455
|
+
classifies agent state.
|
|
456
|
+
|
|
390
457
|
**This reframes, rather than weakens, the case for v2.** Small deterministic
|
|
391
458
|
removals (dedupe/error-purge/superseded-file-ops) structurally cannot beat
|
|
392
459
|
the cache-bust penalty at r=0.1 — there just isn't enough single-message
|
package/index.ts
CHANGED
|
@@ -165,10 +165,16 @@ export interface PruneProtections {
|
|
|
165
165
|
|
|
166
166
|
export interface PruneThresholds {
|
|
167
167
|
/**
|
|
168
|
-
* Minimum characters a prune must remove
|
|
169
|
-
*
|
|
170
|
-
* (
|
|
171
|
-
*
|
|
168
|
+
* Minimum raw text characters a fresh AUTOMATIC prune proposal must remove
|
|
169
|
+
* (original text chars minus placeholder chars) to be considered at all
|
|
170
|
+
* (pe-qdzb). Enforced by `runDynamicContextPruningPipeline` BEFORE the
|
|
171
|
+
* net-benefit gate (see `PruneGateConfig`/`gate`, which uses break-even token
|
|
172
|
+
* math and is a separate, later check): text-only candidates below this floor
|
|
173
|
+
* are dropped up front and never reach gate/batch consideration. Image-bearing
|
|
174
|
+
* tool-result candidates bypass this raw-text floor (images receive no
|
|
175
|
+
* synthetic character count) and proceed to the token-based gate. Manual
|
|
176
|
+
* prunes and already-persisted/replayed decisions always bypass this floor,
|
|
177
|
+
* same as the gate. A value of 0 disables the floor (no filtering).
|
|
172
178
|
*/
|
|
173
179
|
minCharsSaved: number;
|
|
174
180
|
}
|
|
@@ -194,19 +200,42 @@ export type GateMode = "on" | "off" | "always-apply";
|
|
|
194
200
|
* making tool calls) vs idle (waiting on the user). Both states default to
|
|
195
201
|
* the same threshold today.
|
|
196
202
|
*
|
|
197
|
-
* pe-c5n9 evidence
|
|
198
|
-
*
|
|
199
|
-
*
|
|
200
|
-
* default. However, the only live runtime
|
|
201
|
-
* handler below)
|
|
202
|
-
*
|
|
203
|
-
*
|
|
204
|
-
*
|
|
205
|
-
*
|
|
206
|
-
*
|
|
207
|
-
*
|
|
208
|
-
*
|
|
209
|
-
*
|
|
203
|
+
* pe-c5n9 evidence (turn-END definition, since superseded -- see below):
|
|
204
|
+
* the representative-corpus benchmark showed mid_loop candidates carrying
|
|
205
|
+
* ~all realized net benefit while idle candidates carried ~none. That would
|
|
206
|
+
* have argued for a stricter idle default. However, the only live runtime
|
|
207
|
+
* caller (the `context` event handler below) did not yet perform real
|
|
208
|
+
* mid-loop/idle detection at the time, so no default change was made.
|
|
209
|
+
*
|
|
210
|
+
* pe-zy4s update (2026-07-08): real runtime mid_loop/idle detection is now
|
|
211
|
+
* wired through the `context` event handler (`classifyAgentStateFromMessages`),
|
|
212
|
+
* using a turn-START definition (idle = this is the first LLM call of a turn;
|
|
213
|
+
* mid_loop = the agent already made a call or received a tool result this
|
|
214
|
+
* turn) -- see that function's doc comment for the exact runtime-observable
|
|
215
|
+
* semantics. The benchmark's candidate labeling was aligned to this SAME
|
|
216
|
+
* definition (retiring the old turn-END definition above, which was never
|
|
217
|
+
* runtime-observable), and the state-split was re-derived on the
|
|
218
|
+
* representative corpus (~/.the-last-harness/agent/sessions, 460 candidates)
|
|
219
|
+
* under it.
|
|
220
|
+
*
|
|
221
|
+
* The result REVERSES the earlier (turn-END) finding: at r=0.1 the
|
|
222
|
+
* turn-START "idle" population (calls made at the start of a turn) carries
|
|
223
|
+
* essentially ALL the realized net benefit (idle-optimal T=22, total realized
|
|
224
|
+
* net benefit ~20,594 token-units), while "mid_loop" carries essentially NONE
|
|
225
|
+
* (mid_loop-optimal T=1, total realized net benefit ~0.0 -- i.e. no mid_loop
|
|
226
|
+
* candidate is ever worth accepting at r=0.1 under this definition). This is
|
|
227
|
+
* the OPPOSITE of what the pe-c5n9 evidence (measured under the old,
|
|
228
|
+
* non-runtime-observable turn-END definition) suggested.
|
|
229
|
+
*
|
|
230
|
+
* Per the pe-zy4s decision rule (stricter idle default only if idle itself is
|
|
231
|
+
* shown to be ~worthless): idle is NOT worthless here -- it is the ONLY state
|
|
232
|
+
* carrying value at r=0.1 -- so no state-conditioned strictness is justified
|
|
233
|
+
* in either direction. The per-state split is therefore kept at PARITY
|
|
234
|
+
* (`breakEvenThresholdByState: { idle: DEFAULT_BREAK_EVEN_THRESHOLD, mid_loop:
|
|
235
|
+
* DEFAULT_BREAK_EVEN_THRESHOLD }`), both config-overridable. A future ticket
|
|
236
|
+
* could consider a stricter mid_loop default given this evidence, but that is
|
|
237
|
+
* a new, unreviewed direction outside this ticket's authorized decision rule
|
|
238
|
+
* and is left for a follow-up.
|
|
210
239
|
*/
|
|
211
240
|
export type AgentState = "idle" | "mid_loop";
|
|
212
241
|
|
|
@@ -397,6 +426,41 @@ export function estimateTokensForContent(content: string | (MinimalTextContent |
|
|
|
397
426
|
|
|
398
427
|
export type TokenEstimator = (text: string) => number;
|
|
399
428
|
|
|
429
|
+
/**
|
|
430
|
+
* Classify the agent's current state from the message payload alone (pe-zy4s):
|
|
431
|
+
* this is the runtime-observable definition used both by the live `context`
|
|
432
|
+
* event handler and (via re-export) by the offline benchmark, so the two can
|
|
433
|
+
* never drift apart.
|
|
434
|
+
*
|
|
435
|
+
* Walk backwards from the end of `messages`, skipping any message that is
|
|
436
|
+
* neither `user`, `assistant`, nor `toolResult` (e.g. system-role bookkeeping
|
|
437
|
+
* entries). The first such message found determines the state:
|
|
438
|
+
* - `user` (a plain user turn message) => "idle": this call is the FIRST LLM
|
|
439
|
+
* call of a turn, i.e. the decision is being made from a turn-start state.
|
|
440
|
+
* - `assistant` or `toolResult` (mid-chain) => "mid_loop": the agent is
|
|
441
|
+
* iterating (already made at least one call this turn, or is reacting to a
|
|
442
|
+
* tool result).
|
|
443
|
+
* - No such message found (empty history, or system-only) => "idle" (safe
|
|
444
|
+
* default: nothing suggests an in-progress loop).
|
|
445
|
+
*
|
|
446
|
+
* The benchmark (scripts/benchmark.mjs) reclassifies its candidate labels to
|
|
447
|
+
* this SAME definition (pe-zy4s), reusing this function directly, so the
|
|
448
|
+
* defaults below rest on evidence measured with the exact definition the
|
|
449
|
+
* runtime observes. (An earlier turn-end-based benchmark definition -- "idle"
|
|
450
|
+
* meant "this IS the turn's last assistant message", only knowable in
|
|
451
|
+
* hindsight -- has been retired: the runtime cannot know in advance whether a
|
|
452
|
+
* call is a turn's last one, so that definition was never runtime-observable.)
|
|
453
|
+
*/
|
|
454
|
+
export function classifyAgentStateFromMessages(messages: MinimalMessage[]): AgentState {
|
|
455
|
+
for (let i = messages.length - 1; i >= 0; i--) {
|
|
456
|
+
const role = messages[i].role;
|
|
457
|
+
if (role === "user") return "idle";
|
|
458
|
+
if (role === "assistant" || role === "toolResult") return "mid_loop";
|
|
459
|
+
// Any other role (e.g. "system") is skipped: keep walking further back.
|
|
460
|
+
}
|
|
461
|
+
return "idle";
|
|
462
|
+
}
|
|
463
|
+
|
|
400
464
|
/** Resolve which break-even threshold applies for a given agent state (pe-s2ho state-conditioning hook). */
|
|
401
465
|
export function resolveBreakEvenThreshold(gateConfig: PruneGateConfig, agentState: AgentState): number {
|
|
402
466
|
const override = gateConfig.breakEvenThresholdByState[agentState];
|
|
@@ -892,6 +956,20 @@ function contentTextLength(content: (MinimalTextContent | MinimalImageContent)[]
|
|
|
892
956
|
return content.reduce((sum, block) => (block.type === "text" ? sum + block.text.length : sum), 0);
|
|
893
957
|
}
|
|
894
958
|
|
|
959
|
+
/** Return true when a decision targets a tool result containing one or more images. */
|
|
960
|
+
function isImageBearingToolResultTarget(
|
|
961
|
+
messages: MinimalMessage[],
|
|
962
|
+
decision: PruneDecisionRecord,
|
|
963
|
+
pairIndex?: Map<string, ToolCallPairIndices>,
|
|
964
|
+
): boolean {
|
|
965
|
+
if (decision.kind !== "tool_result_content" || decision.correlation.type !== "toolCallId") return false;
|
|
966
|
+
const pair = findToolCallPairIndices(messages, decision.correlation.toolCallId, pairIndex);
|
|
967
|
+
if (pair.resultIndex === undefined) return false;
|
|
968
|
+
const target = messages[pair.resultIndex];
|
|
969
|
+
if (target?.role !== "toolResult") return false;
|
|
970
|
+
return (target as MinimalToolResultMessage).content.some((block) => block.type === "image");
|
|
971
|
+
}
|
|
972
|
+
|
|
895
973
|
export interface ApplyResult {
|
|
896
974
|
applied: boolean;
|
|
897
975
|
charsRemoved: number;
|
|
@@ -1050,6 +1128,55 @@ export function estimateDecisionSavings(
|
|
|
1050
1128
|
return undefined;
|
|
1051
1129
|
}
|
|
1052
1130
|
|
|
1131
|
+
/**
|
|
1132
|
+
* Estimate the character savings of a single decision (pe-qdzb), i.e. the
|
|
1133
|
+
* same before/after delta basis as `estimateDecisionSavings` but measured in
|
|
1134
|
+
* raw characters rather than estimated tokens. Used by the pipeline to
|
|
1135
|
+
* enforce `thresholds.minCharsSaved` against fresh automatic proposals
|
|
1136
|
+
* *before* they reach the net-benefit gate. Returns undefined under the same
|
|
1137
|
+
* conditions as `estimateDecisionSavings` (target absent / would not apply).
|
|
1138
|
+
* Mirrors `estimateDecisionSavings`'s `Math.max(0, ...)` clamp, so a
|
|
1139
|
+
* decision whose placeholder text would be LONGER than the original content
|
|
1140
|
+
* (negative savings) is reported as 0 chars saved, not a negative number.
|
|
1141
|
+
*/
|
|
1142
|
+
export function estimateDecisionCharsSaved(
|
|
1143
|
+
messages: MinimalMessage[],
|
|
1144
|
+
decision: PruneDecisionRecord,
|
|
1145
|
+
pairIndex?: Map<string, ToolCallPairIndices>,
|
|
1146
|
+
): number | undefined {
|
|
1147
|
+
if (decision.correlation.type !== "toolCallId") return undefined;
|
|
1148
|
+
const pair = findToolCallPairIndices(messages, decision.correlation.toolCallId, pairIndex);
|
|
1149
|
+
|
|
1150
|
+
// Same non-mutating preview approach as `estimateDecisionSavings`.
|
|
1151
|
+
const preview = messages.slice();
|
|
1152
|
+
const result = applyPruneDecision(preview, decision, pairIndex);
|
|
1153
|
+
if (!result.applied) return undefined;
|
|
1154
|
+
|
|
1155
|
+
if (decision.kind === "tool_result_content") {
|
|
1156
|
+
if (pair.resultIndex === undefined) return undefined;
|
|
1157
|
+
const before = messages[pair.resultIndex] as MinimalToolResultMessage;
|
|
1158
|
+
const after = preview[pair.resultIndex] as MinimalToolResultMessage;
|
|
1159
|
+
const charsBefore = contentTextLength(before.content);
|
|
1160
|
+
const charsAfter = contentTextLength(after.content);
|
|
1161
|
+
return Math.max(0, charsBefore - charsAfter);
|
|
1162
|
+
}
|
|
1163
|
+
|
|
1164
|
+
if (decision.kind === "tool_call_input") {
|
|
1165
|
+
if (pair.assistantIndex === undefined || pair.toolCallBlockIndex === undefined) return undefined;
|
|
1166
|
+
const beforeBlock = (messages[pair.assistantIndex] as MinimalAssistantMessage).content[
|
|
1167
|
+
pair.toolCallBlockIndex
|
|
1168
|
+
] as MinimalToolCallContent;
|
|
1169
|
+
const afterBlock = (preview[pair.assistantIndex] as MinimalAssistantMessage).content[
|
|
1170
|
+
pair.toolCallBlockIndex
|
|
1171
|
+
] as MinimalToolCallContent;
|
|
1172
|
+
const charsBefore = JSON.stringify(beforeBlock.arguments ?? {}).length;
|
|
1173
|
+
const charsAfter = JSON.stringify(afterBlock.arguments ?? {}).length;
|
|
1174
|
+
return Math.max(0, charsBefore - charsAfter);
|
|
1175
|
+
}
|
|
1176
|
+
|
|
1177
|
+
return undefined;
|
|
1178
|
+
}
|
|
1179
|
+
|
|
1053
1180
|
/**
|
|
1054
1181
|
* Cache-aware cost model (pe-s2ho ticket NOTES, binding over the looser prose
|
|
1055
1182
|
* in the ticket body): prompt caches are prefix-based, so pruning at message
|
|
@@ -1877,7 +2004,29 @@ export function runDynamicContextPruningPipeline(input: PipelineInput): Pipeline
|
|
|
1877
2004
|
// against the pre-mutation `messages` clone, before the apply loop below
|
|
1878
2005
|
// mutates anything.
|
|
1879
2006
|
const freshManual = dedupedFresh.filter((decision) => decision.source === "manual");
|
|
1880
|
-
const
|
|
2007
|
+
const freshAutomaticUnfiltered = dedupedFresh.filter((decision) => decision.source !== "manual");
|
|
2008
|
+
|
|
2009
|
+
// Minimum-size floor (pe-qdzb): drop fresh automatic proposals whose
|
|
2010
|
+
// character savings (original content chars minus placeholder chars) fall
|
|
2011
|
+
// below `thresholds.minCharsSaved`, BEFORE gate evaluation so dropped
|
|
2012
|
+
// candidates never consume batch/earliest-position gate consideration.
|
|
2013
|
+
// Applies to automatic proposals only; manual (`freshManual` above) and
|
|
2014
|
+
// already-persisted decisions (`input.persistedDecisions`, applied later)
|
|
2015
|
+
// bypass this floor entirely, same as the net-benefit gate. Tool-result
|
|
2016
|
+
// candidates containing images also bypass this raw-text floor because
|
|
2017
|
+
// images have no character count; their token savings still go through the
|
|
2018
|
+
// existing net-benefit gate. A floor of 0 (the config default before
|
|
2019
|
+
// pe-c5n9's DEFAULT_MIN_CHARS_SAVED constant was introduced) is a no-op:
|
|
2020
|
+
// every non-negative delta clears it.
|
|
2021
|
+
const minCharsSaved = input.config.thresholds.minCharsSaved;
|
|
2022
|
+
const freshAutomatic =
|
|
2023
|
+
minCharsSaved <= 0
|
|
2024
|
+
? freshAutomaticUnfiltered
|
|
2025
|
+
: freshAutomaticUnfiltered.filter((decision) => {
|
|
2026
|
+
if (isImageBearingToolResultTarget(messages, decision, pairIndex)) return true;
|
|
2027
|
+
const charsSaved = estimateDecisionCharsSaved(messages, decision, pairIndex);
|
|
2028
|
+
return charsSaved !== undefined && charsSaved >= minCharsSaved;
|
|
2029
|
+
});
|
|
1881
2030
|
|
|
1882
2031
|
// Collapse fresh AUTOMATIC candidates that target the same (kind,
|
|
1883
2032
|
// correlation) down to a single decision (pe-j7sb). Two strategies (e.g.
|
|
@@ -2360,9 +2509,10 @@ export default function dynamicContextPruningExtension(pi: ExtensionAPI) {
|
|
|
2360
2509
|
persistedDecisions,
|
|
2361
2510
|
knownIdempotencyKeys,
|
|
2362
2511
|
restoredIdempotencyKeys,
|
|
2363
|
-
// Real mid-loop/idle agent-state detection
|
|
2364
|
-
//
|
|
2365
|
-
|
|
2512
|
+
// Real mid-loop/idle agent-state detection (pe-zy4s): derived straight from
|
|
2513
|
+
// the message payload via classifyAgentStateFromMessages -- see its doc
|
|
2514
|
+
// comment for the exact runtime-observable definition.
|
|
2515
|
+
agentState: classifyAgentStateFromMessages(event.messages as unknown as MinimalMessage[]),
|
|
2366
2516
|
cwd: ctx.sessionManager.getCwd(),
|
|
2367
2517
|
});
|
|
2368
2518
|
|