agentfootprint 9.53.0 → 9.55.0
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/CLAUDE.md +3 -1
- package/dist/core/agent/stages/window.js +7 -0
- package/dist/core/agent/stages/window.js.map +1 -1
- package/dist/core/agent/window/currentRequest.js +95 -0
- package/dist/core/agent/window/currentRequest.js.map +1 -0
- package/dist/core/agent/window/notice.js +26 -8
- package/dist/core/agent/window/notice.js.map +1 -1
- package/dist/core/agent/window/strategies/drop.js +26 -10
- package/dist/core/agent/window/strategies/drop.js.map +1 -1
- package/dist/core/agent/window/strategy.js +6 -3
- package/dist/core/agent/window/strategy.js.map +1 -1
- package/dist/core/agent/window/summarize.js +5 -1
- package/dist/core/agent/window/summarize.js.map +1 -1
- package/dist/core/agent/window/turns.js +8 -0
- package/dist/core/agent/window/turns.js.map +1 -1
- package/dist/core/tools.js.map +1 -1
- package/dist/esm/core/agent/stages/window.js +7 -0
- package/dist/esm/core/agent/stages/window.js.map +1 -1
- package/dist/esm/core/agent/window/currentRequest.d.ts +70 -0
- package/dist/esm/core/agent/window/currentRequest.js +91 -0
- package/dist/esm/core/agent/window/currentRequest.js.map +1 -0
- package/dist/esm/core/agent/window/notice.d.ts +21 -6
- package/dist/esm/core/agent/window/notice.js +26 -8
- package/dist/esm/core/agent/window/notice.js.map +1 -1
- package/dist/esm/core/agent/window/strategies/drop.d.ts +8 -6
- package/dist/esm/core/agent/window/strategies/drop.js +26 -10
- package/dist/esm/core/agent/window/strategies/drop.js.map +1 -1
- package/dist/esm/core/agent/window/strategy.d.ts +9 -6
- package/dist/esm/core/agent/window/strategy.js +6 -3
- package/dist/esm/core/agent/window/strategy.js.map +1 -1
- package/dist/esm/core/agent/window/summarize.d.ts +5 -1
- package/dist/esm/core/agent/window/summarize.js +5 -1
- package/dist/esm/core/agent/window/summarize.js.map +1 -1
- package/dist/esm/core/agent/window/turns.d.ts +11 -0
- package/dist/esm/core/agent/window/turns.js +8 -0
- package/dist/esm/core/agent/window/turns.js.map +1 -1
- package/dist/esm/core/agent/window/types.d.ts +12 -0
- package/dist/esm/core/tools.d.ts +31 -1
- package/dist/esm/core/tools.js.map +1 -1
- package/dist/esm/recorders/observability/StatusRecorder.d.ts +7 -1
- package/dist/esm/recorders/observability/StatusRecorder.js +30 -2
- package/dist/esm/recorders/observability/StatusRecorder.js.map +1 -1
- package/dist/esm/recorders/observability/commentary/commentaryTemplates.js +10 -0
- package/dist/esm/recorders/observability/commentary/commentaryTemplates.js.map +1 -1
- package/dist/esm/recorders/observability/status/statusTemplates.d.ts +87 -8
- package/dist/esm/recorders/observability/status/statusTemplates.js +177 -24
- package/dist/esm/recorders/observability/status/statusTemplates.js.map +1 -1
- package/dist/recorders/observability/StatusRecorder.js +30 -2
- package/dist/recorders/observability/StatusRecorder.js.map +1 -1
- package/dist/recorders/observability/commentary/commentaryTemplates.js +10 -0
- package/dist/recorders/observability/commentary/commentaryTemplates.js.map +1 -1
- package/dist/recorders/observability/status/statusTemplates.js +179 -25
- package/dist/recorders/observability/status/statusTemplates.js.map +1 -1
- package/dist/types/core/agent/stages/window.d.ts.map +1 -1
- package/dist/types/core/agent/window/currentRequest.d.ts +71 -0
- package/dist/types/core/agent/window/currentRequest.d.ts.map +1 -0
- package/dist/types/core/agent/window/notice.d.ts +21 -6
- package/dist/types/core/agent/window/notice.d.ts.map +1 -1
- package/dist/types/core/agent/window/strategies/drop.d.ts +8 -6
- package/dist/types/core/agent/window/strategies/drop.d.ts.map +1 -1
- package/dist/types/core/agent/window/strategy.d.ts +9 -6
- package/dist/types/core/agent/window/strategy.d.ts.map +1 -1
- package/dist/types/core/agent/window/summarize.d.ts +5 -1
- package/dist/types/core/agent/window/summarize.d.ts.map +1 -1
- package/dist/types/core/agent/window/turns.d.ts +11 -0
- package/dist/types/core/agent/window/turns.d.ts.map +1 -1
- package/dist/types/core/agent/window/types.d.ts +12 -0
- package/dist/types/core/agent/window/types.d.ts.map +1 -1
- package/dist/types/core/tools.d.ts +31 -1
- package/dist/types/core/tools.d.ts.map +1 -1
- package/dist/types/recorders/observability/StatusRecorder.d.ts +7 -1
- package/dist/types/recorders/observability/StatusRecorder.d.ts.map +1 -1
- package/dist/types/recorders/observability/commentary/commentaryTemplates.d.ts.map +1 -1
- package/dist/types/recorders/observability/status/statusTemplates.d.ts +87 -8
- package/dist/types/recorders/observability/status/statusTemplates.d.ts.map +1 -1
- package/package.json +1 -1
package/CLAUDE.md
CHANGED
|
@@ -19,7 +19,9 @@ not in this table, search `src/index.ts` for the nearest noun before writing cod
|
|
|
19
19
|
|---|---|---|---|
|
|
20
20
|
| a tool returning numbers WITH the caveats that make them honest — interval/aggregation grain, is-it-a-counter, when the world was measured, which ground was NOT covered — as typed data the model reads compactly and the record keeps whole | `semantic()` + `tools.semantics_declared` (model sees `semanticsForModel` projection; `coverage` field absorbed by the coverage()/absent() channel) | `src/lib/semantics/` | 9.53.0 |
|
|
21
21
|
| a build gate that refuses a triage/inventory tool that forgot its caveats, by tool name and field name | `checkSemantics` + `defineTool({ resultClass })` + bin `agentfootprint-check-semantics` | `src/lib/semantics/check.ts` | 9.53.0 |
|
|
22
|
+
| keeping the user's own request in context while the window shrinks — the task's anchor, un-droppable by every window strategy including one you wrote | `'current-request'` refusal + `currentRequestIndexOf` + `WindowStrategyInput.currentRequestIndex` | `src/core/agent/window/currentRequest.ts` | 9.55.0 |
|
|
22
23
|
| report progress from inside a tool — "hop 3 of 12 done", said mid-call while a long-running `execute` is still working (the record was otherwise atomic: tool_start, silence, tool_end) | `ctx.progress` + `agentfootprint.stream.tool_progress` | `src/core/tools.ts` | 9.52.0 |
|
|
24
|
+
| show tool progress to the user — a mid-call report reaching the live status line / chat bubble, not just the record (`message` shown verbatim, capped; otherwise an honest generic line, never a payload dump) | `selectStatus` + `progressMessageOf` + `tool.progress` templates | `src/recorders/observability/status/statusTemplates.ts` | 9.54.0 |
|
|
23
25
|
| declaring which skills connect — the SkillMap as one named thing (the agent that mounts it is the SkillWalker; there is deliberately no walker class) | `defineSkillMap` + `SkillMap` (permanent reference-equal aliases of `skillGraph`/`SkillGraph`) | `src/lib/injection-engine/skillGraph.ts` | 9.51.0 |
|
|
24
26
|
| guarding a skill transition on state or a tool result's fields — a route condition as DATA (comparable, drawable, evidence-recorded), not an opaque predicate | `guard:` + `compileGuard` + `guard-unsatisfiable` | `src/lib/injection-engine/skillGuard.ts` | 9.51.0 |
|
|
25
27
|
| seeing the skill map in a recording — the author's nodes + edges (guards included) as DATA, never parsed from prose or inferred from fired hops | `skill.graph_declared` + `buildSkillGraphDeclared` | `src/core/agent/skillGraphDeclared.ts` | 9.50.0 |
|
|
@@ -91,7 +93,7 @@ Traps: `src/observability/` holds the finder IMPLEMENTATIONS (canonical home; `d
|
|
|
91
93
|
- $break is the only clean-stop channel; structured fail context rides scope fields (`policyHalt*`, `reliabilityFail*`), decoded post-run by `Agent.finalizeResult` (Agent.ts:884) into typed errors.
|
|
92
94
|
|
|
93
95
|
## Extension points
|
|
94
|
-
- **Tool**: `defineTool` (core/tools.ts:155); shape `Tool = {schema, needs?, execute(args, ctx)}` (:23). `ctx.progress(payload)` (9.52.0) is the tool's OWN emit door — a `Pick<ToolExecutionContext,'progress'>` closure (`toolProgress`, stages/toolCalls.ts, spread at BOTH dispatch sites beside `toolArtifacts`/`sessionContext`) that typedEmits `stream.tool_progress` mid-stage; framework stamps toolCallId/toolName/iteration, author owns `payload` only. ALWAYS present and never fatal (try/catch + dev warn) — the streamless doors (`mcpServe`, traceToolpack `OFFLINE_CONTEXT`) supply the no-op, which is the whole list of places a new required ctx field must also land. Register `AgentBuilder.tool()` (AgentBuilder.ts:184); merged with auto `read_skill` in buildToolRegistry (:65; same-reference skill tools dedupe, any other name collision THROWS at build). Chart-as-tool: `flowchartAsTool` (core/flowchartAsTool.ts:203). MCP: `mcpClient(...).tools()`.
|
|
96
|
+
- **Tool**: `defineTool` (core/tools.ts:155); shape `Tool = {schema, needs?, execute(args, ctx)}` (:23). `ctx.progress(payload)` (9.52.0) is the tool's OWN emit door — a `Pick<ToolExecutionContext,'progress'>` closure (`toolProgress`, stages/toolCalls.ts, spread at BOTH dispatch sites beside `toolArtifacts`/`sessionContext`) that typedEmits `stream.tool_progress` mid-stage; framework stamps toolCallId/toolName/iteration, author owns `payload` only. **Consumed by the live-status projection since 9.54.0** (`selectStatus`, status/statusTemplates.ts): a top-level string `message` renders VERBATIM (trimmed, cut at `PROGRESS_MESSAGE_LIMIT`=120 with the cut stated), anything else renders the generic `tool.progress.generic` line with a per-`toolCallId` count — never a payload dump. Ladder falls through to `tool.<name>`/`tool`, so a pre-9.54.0 template map cannot blank a bubble. Commentary gained `stream.tool_progress` (teaching voice, no payload) to match Lens's `humanizeToolProgressTeaching`. ALWAYS present and never fatal (try/catch + dev warn) — the streamless doors (`mcpServe`, traceToolpack `OFFLINE_CONTEXT`) supply the no-op, which is the whole list of places a new required ctx field must also land. Register `AgentBuilder.tool()` (AgentBuilder.ts:184); merged with auto `read_skill` in buildToolRegistry (:65; same-reference skill tools dedupe, any other name collision THROWS at build). Chart-as-tool: `flowchartAsTool` (core/flowchartAsTool.ts:203). MCP: `mcpClient(...).tools()`.
|
|
95
97
|
- **ToolProvider** (per-iteration visibility): `list(ctx): Tool[]` (tool-providers/types.ts:121); max ONE per agent (AgentBuilder.ts:238 throws on second); combinators staticTools/gatedTools/skillScopedTools chain decorator-style.
|
|
96
98
|
- **LLM provider**: `LLMProvider = {name, complete, stream?}` (adapters/types.ts:230) passed as `AgentOptions.provider`. `provider.name` keys THREE auto-resolutions: cache strategy (cache/strategyRegistry.ts:40), thinking handler (thinking/registry.ts:43), Lens labels.
|
|
97
99
|
- **Recorder, 3 layers**: (1) raw footprintjs CombinedRecorder via `agent.attach()` (RunnerBase.ts:474 — NOT idempotent); (2) typed stream `agent.on(type|'*')`; (3) new built-in = factory taking `{dispatcher, getRunContext}`, registered in the attach block inside `Agent.run()` (Agent.ts:807-845), barreled in src/observe.ts.
|
|
@@ -50,6 +50,7 @@ exports.buildWindowStage = void 0;
|
|
|
50
50
|
const typedEmit_js_1 = require("../../../recorders/core/typedEmit.js");
|
|
51
51
|
const helpers_js_1 = require("../../slots/helpers.js");
|
|
52
52
|
const cost_js_1 = require("../../cost.js");
|
|
53
|
+
const currentRequest_js_1 = require("../window/currentRequest.js");
|
|
53
54
|
const removal_js_1 = require("../window/removal.js");
|
|
54
55
|
const turns_js_1 = require("../window/turns.js");
|
|
55
56
|
/** Build the window stage. */
|
|
@@ -87,8 +88,14 @@ function buildWindowStage(deps) {
|
|
|
87
88
|
}
|
|
88
89
|
const origins = meter.origins();
|
|
89
90
|
const pausedToolCallId = scope.pausedToolCallId;
|
|
91
|
+
// The one message this run is executing (9.55.0). `scope.userMessage` is
|
|
92
|
+
// what the seed stage committed, so the match is against the run's own
|
|
93
|
+
// copy rather than a guess from position — see window/currentRequest.ts
|
|
94
|
+
// for what happens when the window was seeded from somewhere else.
|
|
95
|
+
const currentRequestIndex = (0, currentRequest_js_1.currentRequestIndexOf)(history, scope.userMessage);
|
|
90
96
|
const guards = {
|
|
91
97
|
answeredCallIds: (0, turns_js_1.answeredCallIds)(history),
|
|
98
|
+
...(currentRequestIndex >= 0 && { currentRequestIndex }),
|
|
92
99
|
...(pausedToolCallId !== undefined && { pausedToolCallId }),
|
|
93
100
|
...(scope.pausedCheckIn === true && { pausedCheckIn: true }),
|
|
94
101
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"window.js","sourceRoot":"","sources":["../../../../src/core/agent/stages/window.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;;;AAKH,uEAAiE;AACjE,uDAA+C;AAC/C,2CAAsE;AACtE,qDAAoD;AAEpD,iDAAoG;AA4BpG,8BAA8B;AAC9B,SAAgB,gBAAgB,CAC9B,IAAqB;IAErB,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC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AAC;QACL,CAAC;QAED,sEAAsE;QACtE,EAAE;QACF,uEAAuE;QACvE,wEAAwE;QACxE,wEAAwE;QACxE,yEAAyE;QACzE,uEAAuE;QACvE,qEAAqE;QACrE,IAAI,MAAM,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;YAC/B,IAAA,sBAAY,EACV,KAAc,EACd,IAAI,CAAC,YAAY,EACjB,IAAI,CAAC,UAAU,EACf;gBACE,GAAG,CAAC,QAAQ,CAAC,OAAO,KAAK,SAAS,IAAI,EAAE,QAAQ,EAAE,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;gBACnF,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,KAAK;aAC1B,EACD,MAAM,CAAC,KAAK,CAAC,KAAK,CACnB,CAAC;QACJ,CAAC;QAED,IAAI,MAAM,CAAC,OAAO,KAAK,SAAS,IAAI,CAAC,MAAM,EAAE,CAAC;YAC5C,MAAM,GAAG,IAAI,CAAC;YACd,sCAAsC;YACtC,OAAO,CAAC,IAAI,CAAC,0BAA0B,QAAQ,CAAC,IAAI,KAAK,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;QAC7E,CAAC;IACH,CAAC,CAAC;AACJ,CAAC;AA5KD,4CA4KC"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* window/currentRequest — which message in the window is the thing the run
|
|
4
|
+
* was asked to do.
|
|
5
|
+
*
|
|
6
|
+
* Pattern: One pure function over the window (no scope, no I/O, no clock).
|
|
7
|
+
* Role: core/ layer. Feeds the refusal engine, which is what actually
|
|
8
|
+
* keeps this message in the window (see turns.ts, `'current-request'`).
|
|
9
|
+
* Kept in its own module because "what did the person ask for" is a
|
|
10
|
+
* different question from "where is a turn boundary", and only this
|
|
11
|
+
* one has to know which user-role messages the LIBRARY wrote.
|
|
12
|
+
* Emits: N/A.
|
|
13
|
+
*
|
|
14
|
+
* ## Why this exists
|
|
15
|
+
*
|
|
16
|
+
* Caught in a real recorded run (9.55.0). A ten-iteration tool loop under a
|
|
17
|
+
* small window dropped the window's HEAD at iteration 4 — and the head was
|
|
18
|
+
* the user's own request. The model went on working from tool traffic and a
|
|
19
|
+
* drop notice, with no statement of its objective anywhere in context. It
|
|
20
|
+
* finished that task by momentum; a longer one forgets what it was doing.
|
|
21
|
+
*
|
|
22
|
+
* Every other guard in this family protects the WIRE (do not split a
|
|
23
|
+
* `tool_use` from its `tool_result`) or the near past (`keepRecentTurns`).
|
|
24
|
+
* Nothing protected the one message the whole run is about, because it is the
|
|
25
|
+
* OLDEST message in the window and every strategy here removes the oldest
|
|
26
|
+
* thing first. So it is named, and it refuses.
|
|
27
|
+
*
|
|
28
|
+
* ## Which message, exactly
|
|
29
|
+
*
|
|
30
|
+
* The window is a flat message list. Its `Turn` segmentation is a WIRE
|
|
31
|
+
* boundary (a non-`tool` message plus the `tool` messages answering it), not
|
|
32
|
+
* a conversational one — there is no "turn 3 of this conversation" object in
|
|
33
|
+
* this folder to point at. What the run DOES know is the message it was
|
|
34
|
+
* started with, which the seed stage commits as `scope.userMessage`, and the
|
|
35
|
+
* stage passes it in as `said`.
|
|
36
|
+
*
|
|
37
|
+
* So the answer is, in order:
|
|
38
|
+
*
|
|
39
|
+
* 1. the LAST message the person said whose text is exactly `said` — the
|
|
40
|
+
* message this run is executing, matched by content rather than by
|
|
41
|
+
* position because a restored conversation puts earlier turns in front
|
|
42
|
+
* of it;
|
|
43
|
+
* 2. failing that, the LAST message the person said at all. That is the
|
|
44
|
+
* honest approximation for a window seeded from outside this run, and it
|
|
45
|
+
* is stated rather than hidden: earlier turns of a multi-turn
|
|
46
|
+
* conversation stay droppable exactly as they were.
|
|
47
|
+
*
|
|
48
|
+
* "The person said it" is deliberately narrow. Three kinds of `role: 'user'`
|
|
49
|
+
* message are written by this LIBRARY, not by anybody: a drop notice, a
|
|
50
|
+
* compaction frame, and a message an {@link Injection} delivered (which
|
|
51
|
+
* carries `injectedBy`). None of them may become the anchor — otherwise the
|
|
52
|
+
* window would protect its own bookkeeping and drop the request underneath
|
|
53
|
+
* it, and a tool able to influence an injection could pin its own text in
|
|
54
|
+
* context permanently.
|
|
55
|
+
*/
|
|
56
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
57
|
+
exports.currentRequestIndexOf = void 0;
|
|
58
|
+
const notice_js_1 = require("./notice.js");
|
|
59
|
+
const summarize_js_1 = require("./summarize.js");
|
|
60
|
+
/** True when this message is something a PERSON said, not something we wrote. */
|
|
61
|
+
function isSomethingTheySaid(msg) {
|
|
62
|
+
return (msg.role === 'user' &&
|
|
63
|
+
msg.injectedBy === undefined &&
|
|
64
|
+
!(0, notice_js_1.isDropNotice)(msg) &&
|
|
65
|
+
!(0, summarize_js_1.isCompactedSummary)(msg));
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Index in `history` of the current request — the message no window strategy
|
|
69
|
+
* may drop — or `-1` when this window holds none.
|
|
70
|
+
*
|
|
71
|
+
* `-1` is a real answer, not a failure: a hand-built window of assistant
|
|
72
|
+
* turns, or one whose only user-role messages are this library's own frames,
|
|
73
|
+
* genuinely has no request to protect. Every caller treats it as "the rule
|
|
74
|
+
* does not apply here", which is how the pre-9.55.0 behaviour is still
|
|
75
|
+
* reachable byte for byte.
|
|
76
|
+
*
|
|
77
|
+
* @param history the window, in order
|
|
78
|
+
* @param said the text the run was started with (`scope.userMessage`),
|
|
79
|
+
* when the caller knows it
|
|
80
|
+
*/
|
|
81
|
+
function currentRequestIndexOf(history, said) {
|
|
82
|
+
let latest = -1;
|
|
83
|
+
for (let i = history.length - 1; i >= 0; i--) {
|
|
84
|
+
const msg = history[i];
|
|
85
|
+
if (!isSomethingTheySaid(msg))
|
|
86
|
+
continue;
|
|
87
|
+
if (said !== undefined && msg.content === said)
|
|
88
|
+
return i;
|
|
89
|
+
if (latest === -1)
|
|
90
|
+
latest = i;
|
|
91
|
+
}
|
|
92
|
+
return latest;
|
|
93
|
+
}
|
|
94
|
+
exports.currentRequestIndexOf = currentRequestIndexOf;
|
|
95
|
+
//# sourceMappingURL=currentRequest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"currentRequest.js","sourceRoot":"","sources":["../../../../src/core/agent/window/currentRequest.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDG;;;AAGH,2CAA2C;AAC3C,iDAAoD;AAEpD,iFAAiF;AACjF,SAAS,mBAAmB,CAAC,GAAe;IAC1C,OAAO,CACL,GAAG,CAAC,IAAI,KAAK,MAAM;QACnB,GAAG,CAAC,UAAU,KAAK,SAAS;QAC5B,CAAC,IAAA,wBAAY,EAAC,GAAG,CAAC;QAClB,CAAC,IAAA,iCAAkB,EAAC,GAAG,CAAC,CACzB,CAAC;AACJ,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,SAAgB,qBAAqB,CAAC,OAA8B,EAAE,IAAa;IACjF,IAAI,MAAM,GAAG,CAAC,CAAC,CAAC;IAChB,KAAK,IAAI,CAAC,GAAG,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC7C,MAAM,GAAG,GAAG,OAAO,CAAC,CAAC,CAAE,CAAC;QACxB,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC;YAAE,SAAS;QACxC,IAAI,IAAI,KAAK,SAAS,IAAI,GAAG,CAAC,OAAO,KAAK,IAAI;YAAE,OAAO,CAAC,CAAC;QACzD,IAAI,MAAM,KAAK,CAAC,CAAC;YAAE,MAAM,GAAG,CAAC,CAAC;IAChC,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AATD,sDASC"}
|
|
@@ -21,10 +21,14 @@
|
|
|
21
21
|
* below is written by this library, which is why a drop has no prompt-
|
|
22
22
|
* injection surface to speak of.
|
|
23
23
|
*
|
|
24
|
-
* It appears ONLY when the removal reaches the
|
|
25
|
-
* the
|
|
26
|
-
*
|
|
27
|
-
*
|
|
24
|
+
* It appears ONLY when the removal reaches the front of what may leave. That
|
|
25
|
+
* is the window's head in the ordinary case; since 9.55.0 it is the position
|
|
26
|
+
* just after the CURRENT REQUEST when the request was sitting at the head and
|
|
27
|
+
* refused to go (see currentRequest.ts) — the notice is still the first thing
|
|
28
|
+
* after the last un-droppable message, and it says that the request was kept.
|
|
29
|
+
* A removal further in leaves the original opening turn in place, so there is
|
|
30
|
+
* no wire problem to solve — and splicing a lone `user` message between two
|
|
31
|
+
* assistant turns is its own risk. The ledger names that removal either way.
|
|
28
32
|
*
|
|
29
33
|
* It does not accumulate: the notice is an ordinary oldest turn next time
|
|
30
34
|
* round, so the next drop absorbs it and files a fresh one.
|
|
@@ -36,16 +40,30 @@ exports.DROP_NOTICE_PREFIX = '[dropped history';
|
|
|
36
40
|
/**
|
|
37
41
|
* Build the message that takes the head position after a drop.
|
|
38
42
|
*
|
|
39
|
-
* `role: 'user'` for the same reason the compaction frame is: it
|
|
40
|
-
* of the window, and the head of the window must be a user turn.
|
|
43
|
+
* `role: 'user'` for the same reason the compaction frame is: it takes the
|
|
44
|
+
* head of the window, and the head of the window must be a user turn. (When
|
|
45
|
+
* the CURRENT REQUEST is holding that position it is already a user turn, and
|
|
46
|
+
* the notice follows it — see below.)
|
|
47
|
+
*
|
|
48
|
+
* `currentRequestKept` (9.55.0) is set when the drop stopped short of the
|
|
49
|
+
* window's head because the message the run is executing was sitting there
|
|
50
|
+
* and refused to leave — so the notice takes the position AFTER it rather
|
|
51
|
+
* than the head itself. It says so, because a model reading "3 earlier
|
|
52
|
+
* messages were dropped" and then finding a request above it should be told
|
|
53
|
+
* which of the two facts to trust. Omitted, the notice is byte-identical to
|
|
54
|
+
* the one this library has always written.
|
|
41
55
|
*/
|
|
42
56
|
function buildDropNotice(facts) {
|
|
57
|
+
const kept = facts.currentRequestKept === true
|
|
58
|
+
? `Your current request is kept — it is still in this window, above this line, and no ` +
|
|
59
|
+
`window strategy may drop it. `
|
|
60
|
+
: '';
|
|
43
61
|
return {
|
|
44
62
|
role: 'user',
|
|
45
63
|
content: `${exports.DROP_NOTICE_PREFIX} — ${facts.droppedMessageCount} earlier message(s) were dropped ` +
|
|
46
64
|
`from this window at iteration ${facts.iteration} by the '${facts.strategy}' window ` +
|
|
47
|
-
`strategy. Nothing was summarized: those turns are simply not being re-sent.
|
|
48
|
-
`retained verbatim in this run's commit log.]`,
|
|
65
|
+
`strategy. ${kept}Nothing was summarized: those turns are simply not being re-sent. ` +
|
|
66
|
+
`They are retained verbatim in this run's commit log.]`,
|
|
49
67
|
};
|
|
50
68
|
}
|
|
51
69
|
exports.buildDropNotice = buildDropNotice;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notice.js","sourceRoot":"","sources":["../../../../src/core/agent/window/notice.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"notice.js","sourceRoot":"","sources":["../../../../src/core/agent/window/notice.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;;;AAIH,8EAA8E;AACjE,QAAA,kBAAkB,GAAG,kBAAkB,CAAC;AAErD;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,eAAe,CAAC,KAK/B;IACC,MAAM,IAAI,GACR,KAAK,CAAC,kBAAkB,KAAK,IAAI;QAC/B,CAAC,CAAC,qFAAqF;YACrF,+BAA+B;QACjC,CAAC,CAAC,EAAE,CAAC;IACT,OAAO;QACL,IAAI,EAAE,MAAM;QACZ,OAAO,EACL,GAAG,0BAAkB,MAAM,KAAK,CAAC,mBAAmB,mCAAmC;YACvF,iCAAiC,KAAK,CAAC,SAAS,YAAY,KAAK,CAAC,QAAQ,WAAW;YACrF,aAAa,IAAI,oEAAoE;YACrF,uDAAuD;KAC1D,CAAC;AACJ,CAAC;AAnBD,0CAmBC;AAED,gEAAgE;AAChE,SAAgB,YAAY,CAAC,GAA2B;IACtD,OAAO,GAAG,KAAK,SAAS,IAAI,GAAG,CAAC,IAAI,KAAK,MAAM,IAAI,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,0BAAkB,CAAC,CAAC;AAChG,CAAC;AAFD,oCAEC"}
|
|
@@ -12,12 +12,14 @@
|
|
|
12
12
|
* A drop makes no LLM call and writes no summary. What it must still do is
|
|
13
13
|
* keep the request valid and keep the record honest:
|
|
14
14
|
*
|
|
15
|
-
* • the span comes from the shared refusal engine, so
|
|
16
|
-
* call, the paused tool, a pending check-in and the
|
|
17
|
-
* leave, and each refusal is named;
|
|
18
|
-
* • when the span reaches the
|
|
19
|
-
* position — the window must open on a user turn (see
|
|
20
|
-
* message we are forced to author should tell the
|
|
15
|
+
* • the span comes from the shared refusal engine, so the CURRENT REQUEST,
|
|
16
|
+
* an unanswered tool call, the paused tool, a pending check-in and the
|
|
17
|
+
* recent turns never leave, and each refusal is named;
|
|
18
|
+
* • when the span reaches the front of what may leave, an authored notice
|
|
19
|
+
* takes that position — the window must open on a user turn (see
|
|
20
|
+
* notice.ts), and a message we are forced to author should tell the
|
|
21
|
+
* truth. That position is the window's HEAD in the ordinary case, and the
|
|
22
|
+
* slot just after the kept request when the request was the head;
|
|
21
23
|
* • when it does not, nothing is inserted: the original opening turn is
|
|
22
24
|
* still there, so there is no wire problem to solve.
|
|
23
25
|
*/
|
|
@@ -62,15 +64,26 @@ function dropOldestSpan(input, keepRecentTurns, strategyName) {
|
|
|
62
64
|
let window;
|
|
63
65
|
let insertedAtMs;
|
|
64
66
|
const droppedAtMs = input.now();
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
67
|
+
// The drop stopped one turn short of the head because the CURRENT REQUEST
|
|
68
|
+
// was sitting there and refused (9.55.0). The wire is fine — the request is
|
|
69
|
+
// a user turn, so the window still opens on one — but the notice is still
|
|
70
|
+
// owed: this removal reaches the front of everything that MAY leave, and a
|
|
71
|
+
// model that reads the request must also be told what went missing under
|
|
72
|
+
// it. Read off the refusal the engine already filed rather than re-derived,
|
|
73
|
+
// so the notice can only move for the reason that actually moved the span.
|
|
74
|
+
const keptRequestAtHead = plan.from === 1 &&
|
|
75
|
+
plan.refusals.some((r) => r.reason === 'current-request' && r.turnIndex === 0);
|
|
76
|
+
if (spanStart === 0 || keptRequestAtHead) {
|
|
77
|
+
// The front of the droppable window is leaving: something must occupy
|
|
78
|
+
// that position, and when it is the window's own head it must be a user
|
|
79
|
+
// turn. Author the notice — and refuse the whole drop if that notice
|
|
68
80
|
// would not be smaller than what it replaces, because dropping two tiny
|
|
69
81
|
// turns to insert a longer notice is pure loss.
|
|
70
82
|
const notice = (0, notice_js_1.buildDropNotice)({
|
|
71
83
|
droppedMessageCount: span.length,
|
|
72
84
|
iteration,
|
|
73
85
|
strategy: strategyName,
|
|
86
|
+
...(keptRequestAtHead && { currentRequestKept: true }),
|
|
74
87
|
});
|
|
75
88
|
if (notice.content.length >= (0, turns_js_1.windowChars)(span)) {
|
|
76
89
|
// `'replacement-not-smaller'` since 8.14.0. A drop writes no summary —
|
|
@@ -81,7 +94,10 @@ function dropOldestSpan(input, keepRecentTurns, strategyName) {
|
|
|
81
94
|
...plan.refusals,
|
|
82
95
|
]);
|
|
83
96
|
}
|
|
84
|
-
|
|
97
|
+
// `head` is empty on the ordinary path, so this is byte-for-byte the
|
|
98
|
+
// `[notice, ...tail]` this function has always produced; when the request
|
|
99
|
+
// was kept it is `[request, notice, ...tail]`.
|
|
100
|
+
window = [...head, notice, ...tail];
|
|
85
101
|
insertedAtMs = droppedAtMs;
|
|
86
102
|
}
|
|
87
103
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"drop.js","sourceRoot":"","sources":["../../../../../src/core/agent/window/strategies/drop.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"drop.js","sourceRoot":"","sources":["../../../../../src/core/agent/window/strategies/drop.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAu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;IAC7B,CAAC;SAAM,CAAC;QACN,MAAM,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,IAAI,CAAC,CAAC;IAC9B,CAAC;IAED,MAAM,KAAK,GAAG,KAAK,CAAC,YAAY,CAAC,IAAA,uBAAU,EAAC,SAAS,EAAE,OAAO,CAAC,EAAE,WAAW,CAAC,CAAC;IAC9E,OAAO;QACL,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,MAAM;QACN,MAAM,EAAE;YACN,SAAS,EAAE,IAAI,CAAC,MAAM;YACtB,aAAa,EAAE,IAAI,CAAC,MAAM;YAC1B,GAAG,CAAC,YAAY,KAAK,SAAS,IAAI,EAAE,YAAY,EAAE,CAAC;SACpD;QACD,eAAe,EAAE,KAAK,CAAC,eAAe;QACtC,mBAAmB,EAAE,IAAI,CAAC,MAAM;QAChC,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,iBAAiB,EAAE,WAAW;QAC9B,gBAAgB,EAAE,IAAA,sBAAW,EAAC,MAAM,CAAC;QACrC,WAAW,EAAE,KAAK,CAAC,MAAM;QACzB,UAAU,EAAE,IAAA,uBAAY,EAAC,MAAM,CAAC,CAAC,MAAM;KACxC,CAAC;AACJ,CAAC;AA7FD,wCA6FC"}
|
|
@@ -26,9 +26,12 @@
|
|
|
26
26
|
*
|
|
27
27
|
* 1. **The refusal rules.** `planRemoval` arrives already bound to this
|
|
28
28
|
* iteration's turns and guards. A strategy cannot forget that an
|
|
29
|
-
* unanswered tool call must not leave the window
|
|
30
|
-
*
|
|
31
|
-
*
|
|
29
|
+
* unanswered tool call must not leave the window — or that the CURRENT
|
|
30
|
+
* REQUEST never does (9.55.0) — because it never gets the chance to
|
|
31
|
+
* decide that for itself: it asks, and it is told, with every refusal
|
|
32
|
+
* named. That is safety by construction, not by docs. It is also why a
|
|
33
|
+
* rule added there arrives in every strategy at once, including the ones
|
|
34
|
+
* consumers wrote before the rule existed.
|
|
32
35
|
* 2. **Provenance.** `removalFacts` turns "these indices left" into the
|
|
33
36
|
* stage ids that wrote them and how long each lived. A strategy cannot
|
|
34
37
|
* file a removal it cannot name.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strategy.js","sourceRoot":"","sources":["../../../../src/core/agent/window/strategy.ts"],"names":[],"mappings":";AAAA
|
|
1
|
+
{"version":3,"file":"strategy.js","sourceRoot":"","sources":["../../../../src/core/agent/window/strategy.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG"}
|
|
@@ -85,8 +85,12 @@ function retentionSentence(retain) {
|
|
|
85
85
|
/**
|
|
86
86
|
* Build the message that replaces the folded span IN THE WINDOW.
|
|
87
87
|
*
|
|
88
|
-
* `role: 'user'` because the
|
|
88
|
+
* `role: 'user'` because the fold can reach the window's head, and the
|
|
89
89
|
* providers that care (Anthropic) require the window to open on a user turn.
|
|
90
|
+
* Since 9.55.0 it usually does NOT reach it — the CURRENT REQUEST sits there
|
|
91
|
+
* and refuses to be folded, so the frame lands immediately after it — but the
|
|
92
|
+
* role is right either way and a fold of a window with no identifiable
|
|
93
|
+
* request still opens on one.
|
|
90
94
|
*
|
|
91
95
|
* The label is written by this function and always comes first. `summary` is
|
|
92
96
|
* appended to it verbatim: the library never edits model output, and it never
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"summarize.js","sourceRoot":"","sources":["../../../../src/core/agent/window/summarize.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;;;AAKH,6EAA6E;AAChE,QAAA,sBAAsB,GAAG,oBAAoB,CAAC;AAE3D,kFAAkF;AAClF,MAAM,eAAe,GAAG,kBAAkB,CAAC;AAC3C,MAAM,gBAAgB,GAAG,sBAAsB,CAAC;AAEhD;;;;GAIG;AACU,QAAA,wBAAwB,GAAG;IACtC,wFAAwF;IACxF,kCAAkC;IAClC,EAAE;IACF,kCAAkC,eAAe,QAAQ,gBAAgB,sBAAsB;I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K;QACL,GAAG,CAAC,MAAM,KAAK,SAAS,IAAI,EAAE,MAAM,EAAE,CAAC;KACxC,CAAC,CAAC;IACH,OAAO,EAAE,IAAI,EAAE,QAAQ,CAAC,OAAO,EAAE,KAAK,EAAE,QAAQ,CAAC,KAAK,EAAE,CAAC;AAC3D,CAAC;AAbD,sCAaC"}
|
|
@@ -72,6 +72,14 @@ exports.answeredCallIds = answeredCallIds;
|
|
|
72
72
|
* reading the trace needs to see.
|
|
73
73
|
*/
|
|
74
74
|
function refusalFor(turn, guards) {
|
|
75
|
+
// First, because it is the strongest rule in the family: the message the
|
|
76
|
+
// run is executing is the one thing the model cannot work without. A turn
|
|
77
|
+
// holds at most one non-`tool` message, so this never competes with the
|
|
78
|
+
// reasons below for the same turn.
|
|
79
|
+
const request = guards.currentRequestIndex;
|
|
80
|
+
if (request !== undefined && request >= turn.start && request < turn.start + turn.length) {
|
|
81
|
+
return 'current-request';
|
|
82
|
+
}
|
|
75
83
|
for (const msg of turn.messages) {
|
|
76
84
|
if (msg.role === 'system')
|
|
77
85
|
return 'system-envelope';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"turns.js","sourceRoot":"","sources":["../../../../src/core/agent/window/turns.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;;;AAoBH;;;;;;GAMG;AACH,SAAgB,YAAY,CAAC,OAA8B;IACzD,MAAM,KAAK,GAAW,EAAE,CAAC;IACzB,IAAI,OAAO,GAAiB,EAAE,CAAC;IAC/B,IAAI,KAAK,GAAG,CAAC,CAAC;IAEd,MAAM,KAAK,GAAG,GAAS,EAAE;QACvB,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO;QACjC,KAAK,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;QACtF,OA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,EAAE,CAAC;QACnF,GAAG,CAAC,OAAO,CAAC,gBAAgB,KAAK,SAAS,IAAI,EAAE,gBAAgB,EAAE,OAAO,CAAC,gBAAgB,EAAE,CAAC;QAC7F,2EAA2E;QAC3E,0EAA0E;QAC1E,GAAG,CAAC,OAAO,CAAC,YAAY,KAAK,SAAS,IAAI,EAAE,YAAY,EAAE,OAAO,CAAC,YAAY,EAAE,CAAC;QACjF,GAAG,CAAC,OAAO,CAAC,aAAa,KAAK,SAAS,IAAI,EAAE,aAAa,EAAE,OAAO,CAAC,aAAa,EAAE,CAAC;QACpF,GAAG,CAAC,OAAO,CAAC,WAAW,KAAK,SAAS,IAAI,EAAE,WAAW,EAAE,OAAO,CAAC,WAAW,EAAE,CAAC;QAC9E,OAAO,EAAE,OAAO,CAAC,OAAO;KACzB,CAAC;AACJ,CAAC;AAtDD,gCAsDC"}
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
import { typedEmit } from '../../../recorders/core/typedEmit.js';
|
|
48
48
|
import { fnv1a } from '../../slots/helpers.js';
|
|
49
49
|
import { emitCostTick } from '../../cost.js';
|
|
50
|
+
import { currentRequestIndexOf } from '../window/currentRequest.js';
|
|
50
51
|
import { removalFacts } from '../window/removal.js';
|
|
51
52
|
import { answeredCallIds, planRemoval, segmentTurns } from '../window/turns.js';
|
|
52
53
|
/** Build the window stage. */
|
|
@@ -84,8 +85,14 @@ export function buildWindowStage(deps) {
|
|
|
84
85
|
}
|
|
85
86
|
const origins = meter.origins();
|
|
86
87
|
const pausedToolCallId = scope.pausedToolCallId;
|
|
88
|
+
// The one message this run is executing (9.55.0). `scope.userMessage` is
|
|
89
|
+
// what the seed stage committed, so the match is against the run's own
|
|
90
|
+
// copy rather than a guess from position — see window/currentRequest.ts
|
|
91
|
+
// for what happens when the window was seeded from somewhere else.
|
|
92
|
+
const currentRequestIndex = currentRequestIndexOf(history, scope.userMessage);
|
|
87
93
|
const guards = {
|
|
88
94
|
answeredCallIds: answeredCallIds(history),
|
|
95
|
+
...(currentRequestIndex >= 0 && { currentRequestIndex }),
|
|
89
96
|
...(pausedToolCallId !== undefined && { pausedToolCallId }),
|
|
90
97
|
...(scope.pausedCheckIn === true && { pausedCheckIn: true }),
|
|
91
98
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"window.js","sourceRoot":"","sources":["../../../../../src/core/agent/stages/window.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAKH,OAAO,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAC;AACjE,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAA2B,MAAM,eAAe,CAAC;AACtE,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEpD,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,YAAY,EAAsB,MAAM,oBAAoB,CAAC;AA4BpG,8BAA8B;AAC9B,MAAM,UAAU,gBAAgB,CAC9B,IAAqB;IAErB,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;IACjC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,GAAW,EAAE,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC;IACnD,0EAA0E;IAC1E,sEAAsE;IACtE,IAAI,MAAM,GAAG,KAAK,CAAC;IACnB,2EAA2E;IAC3E,4EAA4E;IAC5E,4EAA4E;IAC5E,gBAAgB;IAChB,IAAI,eAAe,GAAG,KAAK,CAAC;IAE5B,OAAO,KAAK,EAAE,KAAK,EAAE,EAAE;QACrB,yEAAyE;QACzE,uEAAuE;QACvE,mEAAmE;QACnE,mEAAmE;QACnE,+BAA+B;QAC/B,MAAM,OAAO,GAAG,CAAE,KAAK,CAAC,OAA6C,IAAI,EAAE,CAAC,CAAC,KAAK,EAAE,CAAC;QACrF,MAAM,KAAK,GAAG,YAAY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AAE,CAAC;gBACnF,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC,KAAK;aAC1B,EACD,MAAM,CAAC,KAAK,CAAC,KAAK,CACnB,CAAC;QACJ,CAAC;QAED,IAAI,MAAM,CAAC,OAAO,KAAK,SAAS,IAAI,CAAC,MAAM,EAAE,CAAC;YAC5C,MAAM,GAAG,IAAI,CAAC;YACd,sCAAsC;YACtC,OAAO,CAAC,IAAI,CAAC,0BAA0B,QAAQ,CAAC,IAAI,KAAK,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;QAC7E,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* window/currentRequest — which message in the window is the thing the run
|
|
3
|
+
* was asked to do.
|
|
4
|
+
*
|
|
5
|
+
* Pattern: One pure function over the window (no scope, no I/O, no clock).
|
|
6
|
+
* Role: core/ layer. Feeds the refusal engine, which is what actually
|
|
7
|
+
* keeps this message in the window (see turns.ts, `'current-request'`).
|
|
8
|
+
* Kept in its own module because "what did the person ask for" is a
|
|
9
|
+
* different question from "where is a turn boundary", and only this
|
|
10
|
+
* one has to know which user-role messages the LIBRARY wrote.
|
|
11
|
+
* Emits: N/A.
|
|
12
|
+
*
|
|
13
|
+
* ## Why this exists
|
|
14
|
+
*
|
|
15
|
+
* Caught in a real recorded run (9.55.0). A ten-iteration tool loop under a
|
|
16
|
+
* small window dropped the window's HEAD at iteration 4 — and the head was
|
|
17
|
+
* the user's own request. The model went on working from tool traffic and a
|
|
18
|
+
* drop notice, with no statement of its objective anywhere in context. It
|
|
19
|
+
* finished that task by momentum; a longer one forgets what it was doing.
|
|
20
|
+
*
|
|
21
|
+
* Every other guard in this family protects the WIRE (do not split a
|
|
22
|
+
* `tool_use` from its `tool_result`) or the near past (`keepRecentTurns`).
|
|
23
|
+
* Nothing protected the one message the whole run is about, because it is the
|
|
24
|
+
* OLDEST message in the window and every strategy here removes the oldest
|
|
25
|
+
* thing first. So it is named, and it refuses.
|
|
26
|
+
*
|
|
27
|
+
* ## Which message, exactly
|
|
28
|
+
*
|
|
29
|
+
* The window is a flat message list. Its `Turn` segmentation is a WIRE
|
|
30
|
+
* boundary (a non-`tool` message plus the `tool` messages answering it), not
|
|
31
|
+
* a conversational one — there is no "turn 3 of this conversation" object in
|
|
32
|
+
* this folder to point at. What the run DOES know is the message it was
|
|
33
|
+
* started with, which the seed stage commits as `scope.userMessage`, and the
|
|
34
|
+
* stage passes it in as `said`.
|
|
35
|
+
*
|
|
36
|
+
* So the answer is, in order:
|
|
37
|
+
*
|
|
38
|
+
* 1. the LAST message the person said whose text is exactly `said` — the
|
|
39
|
+
* message this run is executing, matched by content rather than by
|
|
40
|
+
* position because a restored conversation puts earlier turns in front
|
|
41
|
+
* of it;
|
|
42
|
+
* 2. failing that, the LAST message the person said at all. That is the
|
|
43
|
+
* honest approximation for a window seeded from outside this run, and it
|
|
44
|
+
* is stated rather than hidden: earlier turns of a multi-turn
|
|
45
|
+
* conversation stay droppable exactly as they were.
|
|
46
|
+
*
|
|
47
|
+
* "The person said it" is deliberately narrow. Three kinds of `role: 'user'`
|
|
48
|
+
* message are written by this LIBRARY, not by anybody: a drop notice, a
|
|
49
|
+
* compaction frame, and a message an {@link Injection} delivered (which
|
|
50
|
+
* carries `injectedBy`). None of them may become the anchor — otherwise the
|
|
51
|
+
* window would protect its own bookkeeping and drop the request underneath
|
|
52
|
+
* it, and a tool able to influence an injection could pin its own text in
|
|
53
|
+
* context permanently.
|
|
54
|
+
*/
|
|
55
|
+
import type { LLMMessage } from '../../../adapters/types.js';
|
|
56
|
+
/**
|
|
57
|
+
* Index in `history` of the current request — the message no window strategy
|
|
58
|
+
* may drop — or `-1` when this window holds none.
|
|
59
|
+
*
|
|
60
|
+
* `-1` is a real answer, not a failure: a hand-built window of assistant
|
|
61
|
+
* turns, or one whose only user-role messages are this library's own frames,
|
|
62
|
+
* genuinely has no request to protect. Every caller treats it as "the rule
|
|
63
|
+
* does not apply here", which is how the pre-9.55.0 behaviour is still
|
|
64
|
+
* reachable byte for byte.
|
|
65
|
+
*
|
|
66
|
+
* @param history the window, in order
|
|
67
|
+
* @param said the text the run was started with (`scope.userMessage`),
|
|
68
|
+
* when the caller knows it
|
|
69
|
+
*/
|
|
70
|
+
export declare function currentRequestIndexOf(history: readonly LLMMessage[], said?: string): number;
|