agentfootprint 9.56.0 → 9.57.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 +5 -0
- package/dist/cache/CacheDecisionSubflow.js +2 -1
- package/dist/cache/CacheDecisionSubflow.js.map +1 -1
- package/dist/core/Agent.js +18 -0
- package/dist/core/Agent.js.map +1 -1
- package/dist/core/agent/buildAgentChart.js +4 -0
- package/dist/core/agent/buildAgentChart.js.map +1 -1
- package/dist/core/agent/buildDynamicAgentChart.js +3 -0
- package/dist/core/agent/buildDynamicAgentChart.js.map +1 -1
- package/dist/core/agent/stages/callLLM.js +2 -1
- package/dist/core/agent/stages/callLLM.js.map +1 -1
- package/dist/core/agent/stages/window.js +75 -3
- package/dist/core/agent/stages/window.js.map +1 -1
- package/dist/core/agent/window/index.js.map +1 -1
- package/dist/core/agent/window/lastToolResult.js +123 -0
- package/dist/core/agent/window/lastToolResult.js.map +1 -0
- package/dist/core/agent/window/notice.js +58 -6
- package/dist/core/agent/window/notice.js.map +1 -1
- package/dist/core/agent/window/options.js +31 -1
- package/dist/core/agent/window/options.js.map +1 -1
- package/dist/core/agent/window/strategies/drop.js +73 -17
- package/dist/core/agent/window/strategies/drop.js.map +1 -1
- package/dist/core/agent/window/toolNames.js +81 -0
- package/dist/core/agent/window/toolNames.js.map +1 -0
- package/dist/core/agent/window/turns.js +50 -2
- package/dist/core/agent/window/turns.js.map +1 -1
- package/dist/esm/cache/CacheDecisionSubflow.js +2 -1
- package/dist/esm/cache/CacheDecisionSubflow.js.map +1 -1
- package/dist/esm/core/Agent.d.ts +3 -0
- package/dist/esm/core/Agent.js +18 -0
- package/dist/esm/core/Agent.js.map +1 -1
- package/dist/esm/core/agent/buildAgentChart.js +4 -0
- package/dist/esm/core/agent/buildAgentChart.js.map +1 -1
- package/dist/esm/core/agent/buildDynamicAgentChart.js +3 -0
- package/dist/esm/core/agent/buildDynamicAgentChart.js.map +1 -1
- package/dist/esm/core/agent/stages/callLLM.js +2 -1
- package/dist/esm/core/agent/stages/callLLM.js.map +1 -1
- package/dist/esm/core/agent/stages/window.d.ts +10 -0
- package/dist/esm/core/agent/stages/window.js +75 -3
- package/dist/esm/core/agent/stages/window.js.map +1 -1
- package/dist/esm/core/agent/types.d.ts +35 -0
- package/dist/esm/core/agent/window/index.d.ts +1 -1
- package/dist/esm/core/agent/window/index.js.map +1 -1
- package/dist/esm/core/agent/window/lastToolResult.d.ts +96 -0
- package/dist/esm/core/agent/window/lastToolResult.js +119 -0
- package/dist/esm/core/agent/window/lastToolResult.js.map +1 -0
- package/dist/esm/core/agent/window/notice.d.ts +14 -4
- package/dist/esm/core/agent/window/notice.js +58 -6
- package/dist/esm/core/agent/window/notice.js.map +1 -1
- package/dist/esm/core/agent/window/options.d.ts +21 -0
- package/dist/esm/core/agent/window/options.js +29 -0
- package/dist/esm/core/agent/window/options.js.map +1 -1
- package/dist/esm/core/agent/window/strategies/drop.d.ts +20 -0
- package/dist/esm/core/agent/window/strategies/drop.js +73 -17
- package/dist/esm/core/agent/window/strategies/drop.js.map +1 -1
- package/dist/esm/core/agent/window/toolNames.d.ts +53 -0
- package/dist/esm/core/agent/window/toolNames.js +76 -0
- package/dist/esm/core/agent/window/toolNames.js.map +1 -0
- package/dist/esm/core/agent/window/turns.d.ts +23 -1
- package/dist/esm/core/agent/window/turns.js +50 -2
- package/dist/esm/core/agent/window/turns.js.map +1 -1
- package/dist/esm/core/agent/window/types.d.ts +84 -0
- package/dist/esm/events/payloads.d.ts +3 -1
- package/dist/esm/index.d.ts +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/lib/injection-engine/buildInjectionEngineSubflow.js +12 -1
- package/dist/esm/lib/injection-engine/buildInjectionEngineSubflow.js.map +1 -1
- package/dist/esm/lib/injection-engine/evaluator.js +31 -6
- package/dist/esm/lib/injection-engine/evaluator.js.map +1 -1
- package/dist/esm/lib/injection-engine/factories/defineInstruction.d.ts +45 -3
- package/dist/esm/lib/injection-engine/factories/defineInstruction.js +38 -4
- package/dist/esm/lib/injection-engine/factories/defineInstruction.js.map +1 -1
- package/dist/esm/lib/injection-engine/promptTemplate.d.ts +76 -0
- package/dist/esm/lib/injection-engine/promptTemplate.js +124 -0
- package/dist/esm/lib/injection-engine/promptTemplate.js.map +1 -0
- package/dist/esm/lib/injection-engine/types.d.ts +60 -3
- package/dist/esm/lib/injection-engine/types.js +25 -3
- package/dist/esm/lib/injection-engine/types.js.map +1 -1
- package/dist/esm/lib/iterationBudget.d.ts +28 -0
- package/dist/esm/lib/iterationBudget.js +31 -0
- package/dist/esm/lib/iterationBudget.js.map +1 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/injection-engine/buildInjectionEngineSubflow.js +12 -1
- package/dist/lib/injection-engine/buildInjectionEngineSubflow.js.map +1 -1
- package/dist/lib/injection-engine/evaluator.js +31 -6
- package/dist/lib/injection-engine/evaluator.js.map +1 -1
- package/dist/lib/injection-engine/factories/defineInstruction.js +38 -4
- package/dist/lib/injection-engine/factories/defineInstruction.js.map +1 -1
- package/dist/lib/injection-engine/promptTemplate.js +132 -0
- package/dist/lib/injection-engine/promptTemplate.js.map +1 -0
- package/dist/lib/injection-engine/types.js +25 -3
- package/dist/lib/injection-engine/types.js.map +1 -1
- package/dist/lib/iterationBudget.js +35 -0
- package/dist/lib/iterationBudget.js.map +1 -0
- package/dist/types/cache/CacheDecisionSubflow.d.ts.map +1 -1
- package/dist/types/core/Agent.d.ts +3 -0
- package/dist/types/core/Agent.d.ts.map +1 -1
- package/dist/types/core/agent/buildAgentChart.d.ts.map +1 -1
- package/dist/types/core/agent/buildDynamicAgentChart.d.ts.map +1 -1
- package/dist/types/core/agent/stages/callLLM.d.ts.map +1 -1
- package/dist/types/core/agent/stages/window.d.ts +10 -0
- package/dist/types/core/agent/stages/window.d.ts.map +1 -1
- package/dist/types/core/agent/types.d.ts +35 -0
- package/dist/types/core/agent/types.d.ts.map +1 -1
- package/dist/types/core/agent/window/index.d.ts +1 -1
- package/dist/types/core/agent/window/index.d.ts.map +1 -1
- package/dist/types/core/agent/window/lastToolResult.d.ts +97 -0
- package/dist/types/core/agent/window/lastToolResult.d.ts.map +1 -0
- package/dist/types/core/agent/window/notice.d.ts +14 -4
- package/dist/types/core/agent/window/notice.d.ts.map +1 -1
- package/dist/types/core/agent/window/options.d.ts +21 -0
- package/dist/types/core/agent/window/options.d.ts.map +1 -1
- package/dist/types/core/agent/window/strategies/drop.d.ts +20 -0
- package/dist/types/core/agent/window/strategies/drop.d.ts.map +1 -1
- package/dist/types/core/agent/window/toolNames.d.ts +54 -0
- package/dist/types/core/agent/window/toolNames.d.ts.map +1 -0
- package/dist/types/core/agent/window/turns.d.ts +23 -1
- package/dist/types/core/agent/window/turns.d.ts.map +1 -1
- package/dist/types/core/agent/window/types.d.ts +84 -0
- package/dist/types/core/agent/window/types.d.ts.map +1 -1
- package/dist/types/events/payloads.d.ts +3 -1
- package/dist/types/events/payloads.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/buildInjectionEngineSubflow.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/evaluator.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/factories/defineInstruction.d.ts +45 -3
- package/dist/types/lib/injection-engine/factories/defineInstruction.d.ts.map +1 -1
- package/dist/types/lib/injection-engine/promptTemplate.d.ts +77 -0
- package/dist/types/lib/injection-engine/promptTemplate.d.ts.map +1 -0
- package/dist/types/lib/injection-engine/types.d.ts +60 -3
- package/dist/types/lib/injection-engine/types.d.ts.map +1 -1
- package/dist/types/lib/iterationBudget.d.ts +29 -0
- package/dist/types/lib/iterationBudget.d.ts.map +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"callLLM.js","sourceRoot":"","sources":["../../../../src/core/agent/stages/callLLM.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;GAmBG;;;
|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QAC1C,KAAK,CAAC,kBAAkB,GAAG,QAAQ,CAAC,SAAS,CAAC;QAC9C,0DAA0D;QAC1D,+DAA+D;QAC/D,4DAA4D;QAC5D,+DAA+D;QAC/D,IAAI,QAAQ,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;YACtC,KAA2D,CAAC,WAAW;gBACtE,QAAQ,CAAC,WAAW,CAAC;QACzB,CAAC;QAED,IAAA,wBAAS,EAAC,KAAK,EAAE,+BAA+B,EAAE;YAChD,SAAS;YACT,OAAO,EAAE,QAAQ,CAAC,OAAO;YACzB,aAAa,EAAE,QAAQ,CAAC,SAAS,CAAC,MAAM;YACxC,KAAK,EAAE,QAAQ,CAAC,KAAK;YACrB,UAAU,EAAE,QAAQ,CAAC,UAAU;YAC/B,UAAU;SACX,CAAC,CAAC;QAEH,2EAA2E;QAC3E,iEAAiE;QACjE,IAAA,sBAAY,EACV,KAAK,EACL,IAAI,CAAC,YAAY,EACjB,IAAI,CAAC,UAAU,EACf,EAAE,QAAQ,EAAE,QAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,EAClC,QAAQ,CAAC,KAAK,CACf,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC;AA9VD,8CA8VC"}
|
|
@@ -51,8 +51,33 @@ 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
53
|
const currentRequest_js_1 = require("../window/currentRequest.js");
|
|
54
|
+
const lastToolResult_js_1 = require("../window/lastToolResult.js");
|
|
55
|
+
const options_js_1 = require("../window/options.js");
|
|
54
56
|
const removal_js_1 = require("../window/removal.js");
|
|
55
57
|
const turns_js_1 = require("../window/turns.js");
|
|
58
|
+
const toolNames_js_1 = require("../window/toolNames.js");
|
|
59
|
+
/**
|
|
60
|
+
* True when the pin is PROVABLY what is stopping the window from shrinking:
|
|
61
|
+
* the two most recent visits both removed nothing AND both named
|
|
62
|
+
* `'last-tool-result'`.
|
|
63
|
+
*
|
|
64
|
+
* Two, not one: a single blocked boundary is ordinary (the next tool result
|
|
65
|
+
* arrives and the pin moves). Two in a row with the pin named in both is
|
|
66
|
+
* non-progress, and the pin releases for one visit rather than let a window
|
|
67
|
+
* grow without bound — which is reachable under `summarizeOldest`, where a
|
|
68
|
+
* lone existing summary sitting in front of a pinned turn short-circuits the
|
|
69
|
+
* whole plan to "remove nothing" for ever.
|
|
70
|
+
*
|
|
71
|
+
* Deliberately a release-under-PROVEN-NON-PROGRESS rule and not a
|
|
72
|
+
* release-under-budget-pressure one: budget pressure peaks exactly when the
|
|
73
|
+
* model is most likely to fabricate, which is the worst moment to throw its
|
|
74
|
+
* evidence away.
|
|
75
|
+
*/
|
|
76
|
+
function pinIsBlocking(records) {
|
|
77
|
+
const recent = records.slice(-2);
|
|
78
|
+
return (recent.length === 2 &&
|
|
79
|
+
recent.every((r) => r.removedMessageCount === 0 && r.refusals.some((f) => f.reason === 'last-tool-result')));
|
|
80
|
+
}
|
|
56
81
|
/** Build the window stage. */
|
|
57
82
|
function buildWindowStage(deps) {
|
|
58
83
|
const { strategy, meter } = deps;
|
|
@@ -87,18 +112,38 @@ function buildWindowStage(deps) {
|
|
|
87
112
|
`being managed. Use a provider that reports usage, or remove the window strategy.`);
|
|
88
113
|
}
|
|
89
114
|
const origins = meter.origins();
|
|
115
|
+
// Read once, used twice: the append below, and the pin's stand-down check
|
|
116
|
+
// (9.57.0). One tracked read of the same key either way.
|
|
117
|
+
const priorRecords = scope.compactions ?? [];
|
|
90
118
|
const pausedToolCallId = scope.pausedToolCallId;
|
|
91
119
|
// The one message this run is executing (9.55.0). `scope.userMessage` is
|
|
92
120
|
// what the seed stage committed, so the match is against the run's own
|
|
93
121
|
// copy rather than a guess from position — see window/currentRequest.ts
|
|
94
122
|
// for what happens when the window was seeded from somewhere else.
|
|
95
123
|
const currentRequestIndex = (0, currentRequest_js_1.currentRequestIndexOf)(history, scope.userMessage);
|
|
124
|
+
// The last-tool-result pin (9.57.0). Candidates are resolved here, in the
|
|
125
|
+
// stage, for the same reason the anchor is: this is the one place holding
|
|
126
|
+
// the window, the anchor and the run's own state together. The CEILING is
|
|
127
|
+
// spent inside `planRemoval`, where the keep window is known — a pin that
|
|
128
|
+
// is already safe must not spend a slot.
|
|
129
|
+
const limit = deps.keepLastToolResults === false
|
|
130
|
+
? 0
|
|
131
|
+
: deps.keepLastToolResults ?? options_js_1.DEFAULT_KEEP_LAST_TOOL_RESULTS;
|
|
132
|
+
const standDown = limit > 0 && pinIsBlocking(priorRecords);
|
|
133
|
+
const pins = limit > 0 && !standDown ? (0, lastToolResult_js_1.toolResultPinsOf)(turns, history, currentRequestIndex) : [];
|
|
96
134
|
const guards = {
|
|
97
135
|
answeredCallIds: (0, turns_js_1.answeredCallIds)(history),
|
|
98
136
|
...(currentRequestIndex >= 0 && { currentRequestIndex }),
|
|
99
137
|
...(pausedToolCallId !== undefined && { pausedToolCallId }),
|
|
100
138
|
...(scope.pausedCheckIn === true && { pausedCheckIn: true }),
|
|
139
|
+
// Value-conditional: with no pinnable result the guards are the exact
|
|
140
|
+
// object this stage has always built.
|
|
141
|
+
...(pins.length > 0 && { toolResultPins: pins, keepLastToolResults: limit }),
|
|
101
142
|
};
|
|
143
|
+
// What the pin actually did, captured off the plan the strategy asked
|
|
144
|
+
// for. A strategy may ask more than once; the last answer is the one that
|
|
145
|
+
// decided the window.
|
|
146
|
+
let observed;
|
|
102
147
|
const result = await strategy.plan({
|
|
103
148
|
history,
|
|
104
149
|
turns,
|
|
@@ -113,7 +158,12 @@ function buildWindowStage(deps) {
|
|
|
113
158
|
now,
|
|
114
159
|
// The refusal engine, bound. A strategy cannot skip it: it never
|
|
115
160
|
// receives the guards, only the answer.
|
|
116
|
-
planRemoval: (keepRecentTurns, isExistingSummary) =>
|
|
161
|
+
planRemoval: (keepRecentTurns, isExistingSummary) => {
|
|
162
|
+
const plan = (0, turns_js_1.planRemoval)(turns, keepRecentTurns, guards, isExistingSummary);
|
|
163
|
+
if (plan.observations !== undefined)
|
|
164
|
+
observed = plan.observations;
|
|
165
|
+
return plan;
|
|
166
|
+
},
|
|
117
167
|
removalFacts: (indices, atMs) => (0, removal_js_1.removalFacts)(origins, indices, atMs),
|
|
118
168
|
});
|
|
119
169
|
// `undefined` = this strategy did not engage this iteration. Nothing to
|
|
@@ -127,8 +177,30 @@ function buildWindowStage(deps) {
|
|
|
127
177
|
meter.rebaseForWindowChange(result.rebase.headCount, result.rebase.keptTailCount, result.rebase.insertedAtMs);
|
|
128
178
|
scope.history = result.window;
|
|
129
179
|
}
|
|
130
|
-
|
|
131
|
-
|
|
180
|
+
// The record's honesty pass (9.57.0). The strategy files WHAT it did; the
|
|
181
|
+
// stage — which is the one place that holds the pre-change window and the
|
|
182
|
+
// eviction indices together — files WHOSE EVIDENCE left. It is stamped
|
|
183
|
+
// here rather than inside a strategy so a strategy a consumer wrote gets
|
|
184
|
+
// it too, and so it is filed on the removals that authored no notice at
|
|
185
|
+
// all: a drop further into the window tells the model nothing, and then
|
|
186
|
+
// the record is the only place the fact exists.
|
|
187
|
+
const evicted = result.evictions
|
|
188
|
+
.map((e) => history[e.index])
|
|
189
|
+
.filter((m) => m !== undefined);
|
|
190
|
+
const droppedObservations = (0, toolNames_js_1.droppedToolNames)(evicted, history);
|
|
191
|
+
// A stand-down is a decision, so it is filed even though it kept nothing.
|
|
192
|
+
const observations = standDown
|
|
193
|
+
? { pinned: [], yielded: 0, limit, standDown: true }
|
|
194
|
+
: observed;
|
|
195
|
+
const record = droppedObservations.length > 0 || observations !== undefined
|
|
196
|
+
? {
|
|
197
|
+
...result.record,
|
|
198
|
+
...(droppedObservations.length > 0 && { droppedObservations }),
|
|
199
|
+
...(observations !== undefined && { observations }),
|
|
200
|
+
}
|
|
201
|
+
: result.record;
|
|
202
|
+
const prior = priorRecords;
|
|
203
|
+
scope.compactions = [...prior, record];
|
|
132
204
|
// The durable half, written in the SAME commit as the window change and
|
|
133
205
|
// the record above. That co-location is the guarantee: there is no state,
|
|
134
206
|
// and no failure, in which messages left the window and the record of what
|
|
@@ -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,mEAAoE;AACpE,qDAAoD;AAEpD,iDAAoG;
|
|
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,mEAAoE;AACpE,mEAA+D;AAC/D,qDAAsE;AACtE,qDAAoD;AAEpD,iDAAoG;AACpG,yDAA0D;AAsC1D;;;;;;;;;;;;;;;;GAgBG;AACH,SAAS,aAAa,CAAC,OAAgC;IACrD,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACjC,OAAO,CACL,MAAM,CAAC,MAAM,KAAK,CAAC;QACnB,MAAM,CAAC,KAAK,CACV,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,mBAAmB,KAAK,CAAC,IAAI,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,KAAK,kBAAkB,CAAC,CAC9F,CACF,CAAC;AACJ,CAAC;AAED,8BAA8B;AAC9B,SAAgB,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,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C3B,CAAC,CAAC;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;AA/ND,4CA+NC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/core/agent/window/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;;AAEH,yCAA0D;AAAjD,wHAAA,2BAA2B,OAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/core/agent/window/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;;AAEH,yCAA0D;AAAjD,wHAAA,2BAA2B,OAAA;AAgBpC,yCAAqF;AAA5E,2GAAA,cAAc,OAAA;AAAE,0GAAA,aAAa,OAAA;AAStC,+CAA4E;AAAnE,sHAAA,sBAAsB,OAAA;AAAE,kHAAA,kBAAkB,OAAA;AACnD,yCAA+D;AAAtD,+GAAA,kBAAkB,OAAA;AAAE,yGAAA,YAAY,OAAA;AACzC,sEAAkE;AAAzD,qHAAA,eAAe,OAAA;AACxB,kEAA8D;AAArD,iHAAA,aAAa,OAAA;AACtB,8DAA0D;AAAjD,6GAAA,WAAW,OAAA"}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* window/lastToolResult — the last thing each tool said, and why the window
|
|
4
|
+
* keeps it.
|
|
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 these turns in the window (see turns.ts,
|
|
9
|
+
* `'last-tool-result'`). Sibling of currentRequest.ts, and kept
|
|
10
|
+
* apart from it for the same reason: "what did the person ask for"
|
|
11
|
+
* and "what has the agent just seen" are different questions.
|
|
12
|
+
* Emits: N/A.
|
|
13
|
+
*
|
|
14
|
+
* ## Why this exists
|
|
15
|
+
*
|
|
16
|
+
* Measured, in a context-gap audit over real recorded runs. An agent drove a
|
|
17
|
+
* screen through tools. A `whats_here` result — about 5,800 characters —
|
|
18
|
+
* carried the list of valid ids it had to act on. Under
|
|
19
|
+
* `slidingWindow({ keepRecentTurns: 2 })` that result survived roughly two
|
|
20
|
+
* iterations, because segmentation makes each assistant/tool_result PAIR one
|
|
21
|
+
* turn. The 9.55.0 anchor kept the REQUEST undroppable, so the model still
|
|
22
|
+
* knew what it had been asked to do — and no longer had the evidence to do
|
|
23
|
+
* it. It assembled a plausible id out of an entity name it remembered plus
|
|
24
|
+
* the shape of an id it had used earlier, and was refused. In one archived
|
|
25
|
+
* run the final answer to the person named a host that appears in no tool
|
|
26
|
+
* result at all.
|
|
27
|
+
*
|
|
28
|
+
* The framework evicted the evidence and kept the task. This is the other
|
|
29
|
+
* half of 9.55.0: **for each tool the agent is using, keep that tool's most
|
|
30
|
+
* recent result** — until the agent calls that tool again, or the person asks
|
|
31
|
+
* something new.
|
|
32
|
+
*
|
|
33
|
+
* ## What is pinned, exactly, and why it cannot grow
|
|
34
|
+
*
|
|
35
|
+
* One pin per tool NAME, always the LATEST result, superseded the moment that
|
|
36
|
+
* tool answers again. So the candidate space is the TOOL ROSTER, not the
|
|
37
|
+
* transcript: a loop that calls three tools forty times has three candidates,
|
|
38
|
+
* not forty. Three further bounds compose on top:
|
|
39
|
+
*
|
|
40
|
+
* • **deduped by turn** — a parallel batch answered in one assistant turn is
|
|
41
|
+
* ONE turn, so it costs one slot however many tools were in it;
|
|
42
|
+
* • **capped** — `keepLastToolResults` (default 2) is the ceiling, applied
|
|
43
|
+
* in `planRemoval` where the keep window is known, so a pin that is
|
|
44
|
+
* already inside `keepRecentTurns` costs nothing at all;
|
|
45
|
+
* • **anchored** — nothing at or before the CURRENT REQUEST is pinnable, so
|
|
46
|
+
* a new user turn releases the whole previous loop for free.
|
|
47
|
+
*
|
|
48
|
+
* Incompressible floor: 1 request + N pins + `keepRecentTurns` turns,
|
|
49
|
+
* independent of tool count, iteration count and run length.
|
|
50
|
+
*
|
|
51
|
+
* ## What it deliberately gets wrong
|
|
52
|
+
*
|
|
53
|
+
* The pin is CONTENT-BLIND. It keeps a tool's LAST result, which may be a
|
|
54
|
+
* one-word acknowledgement while the load-bearing screen dump was the call
|
|
55
|
+
* before. Two slots absorb the common case; nothing eliminates it. That is
|
|
56
|
+
* the honest price of a bound that is a fact about the tool roster rather
|
|
57
|
+
* than a guess about content — and a guess about content is what this library
|
|
58
|
+
* refuses to make everywhere else.
|
|
59
|
+
*
|
|
60
|
+
* Nor does the framework truly know "the tool the model is driving". This
|
|
61
|
+
* approximates it with "every tool that has spoken since the request, latest
|
|
62
|
+
* result each, newest first under a cap". A heuristic that PINS bills its
|
|
63
|
+
* error every iteration, which is why the cap is small and the record names
|
|
64
|
+
* what it kept.
|
|
65
|
+
*/
|
|
66
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
67
|
+
exports.toolResultPinsOf = void 0;
|
|
68
|
+
const toolNames_js_1 = require("./toolNames.js");
|
|
69
|
+
/** Content characters of one turn. Exact; not tokens. */
|
|
70
|
+
function turnChars(turn) {
|
|
71
|
+
let total = 0;
|
|
72
|
+
for (const msg of turn.messages)
|
|
73
|
+
total += msg.content.length;
|
|
74
|
+
return total;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* The turns holding each tool's most recent result, NEWEST FIRST.
|
|
78
|
+
*
|
|
79
|
+
* Newest first because that is the order the ceiling is spent in: when more
|
|
80
|
+
* tools have spoken than there are slots, the ones the agent used most
|
|
81
|
+
* recently keep theirs.
|
|
82
|
+
*
|
|
83
|
+
* @param turns the window's turn segmentation
|
|
84
|
+
* @param history the window itself, for recovering a name from the assistant
|
|
85
|
+
* call when a result does not carry one
|
|
86
|
+
* @param after index of the CURRENT REQUEST, or `-1` when the window holds
|
|
87
|
+
* none. Nothing at or before it is pinnable: results gathered for an
|
|
88
|
+
* earlier request are ordinary history, and this is what makes a new user
|
|
89
|
+
* turn release the whole previous loop without a line of code
|
|
90
|
+
*/
|
|
91
|
+
function toolResultPinsOf(turns, history, after = -1) {
|
|
92
|
+
const pins = [];
|
|
93
|
+
const namedTools = new Set();
|
|
94
|
+
const pinnedTurns = new Set();
|
|
95
|
+
for (let t = turns.length - 1; t >= 0; t--) {
|
|
96
|
+
const turn = turns[t];
|
|
97
|
+
for (let m = turn.messages.length - 1; m >= 0; m--) {
|
|
98
|
+
const index = turn.start + m;
|
|
99
|
+
if (index <= after)
|
|
100
|
+
continue;
|
|
101
|
+
const name = (0, toolNames_js_1.toolNameOfMessage)(turn.messages[m], history);
|
|
102
|
+
// A result that cannot be named is not pinned. Pinning it under a made-
|
|
103
|
+
// up name would keep a turn nothing can ever supersede.
|
|
104
|
+
if (name === undefined || namedTools.has(name))
|
|
105
|
+
continue;
|
|
106
|
+
namedTools.add(name);
|
|
107
|
+
// One pin per TURN: a parallel batch is one turn, and pinning it three
|
|
108
|
+
// times would spend three slots to keep one thing.
|
|
109
|
+
if (pinnedTurns.has(t))
|
|
110
|
+
continue;
|
|
111
|
+
pinnedTurns.add(t);
|
|
112
|
+
pins.push({
|
|
113
|
+
toolName: name,
|
|
114
|
+
turnIndex: t,
|
|
115
|
+
messageIndex: turn.start,
|
|
116
|
+
chars: turnChars(turn),
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return pins;
|
|
121
|
+
}
|
|
122
|
+
exports.toolResultPinsOf = toolResultPinsOf;
|
|
123
|
+
//# sourceMappingURL=lastToolResult.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lastToolResult.js","sourceRoot":"","sources":["../../../../src/core/agent/window/lastToolResult.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+DG;;;AAGH,iDAAmD;AAkBnD,yDAAyD;AACzD,SAAS,SAAS,CAAC,IAAU;IAC3B,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,QAAQ;QAAE,KAAK,IAAI,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC;IAC7D,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,SAAgB,gBAAgB,CAC9B,KAAsB,EACtB,OAA8B,EAC9B,KAAK,GAAG,CAAC,CAAC;IAEV,MAAM,IAAI,GAAoB,EAAE,CAAC;IACjC,MAAM,UAAU,GAAG,IAAI,GAAG,EAAU,CAAC;IACrC,MAAM,WAAW,GAAG,IAAI,GAAG,EAAU,CAAC;IAEtC,KAAK,IAAI,CAAC,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC3C,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAE,CAAC;QACvB,KAAK,IAAI,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;YACnD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;YAC7B,IAAI,KAAK,IAAI,KAAK;gBAAE,SAAS;YAC7B,MAAM,IAAI,GAAG,IAAA,gCAAiB,EAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAE,EAAE,OAAO,CAAC,CAAC;YAC3D,wEAAwE;YACxE,wDAAwD;YACxD,IAAI,IAAI,KAAK,SAAS,IAAI,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC;gBAAE,SAAS;YACzD,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YACrB,uEAAuE;YACvE,mDAAmD;YACnD,IAAI,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC;gBAAE,SAAS;YACjC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;YACnB,IAAI,CAAC,IAAI,CAAC;gBACR,QAAQ,EAAE,IAAI;gBACd,SAAS,EAAE,CAAC;gBACZ,YAAY,EAAE,IAAI,CAAC,KAAK;gBACxB,KAAK,EAAE,SAAS,CAAC,IAAI,CAAC;aACvB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAhCD,4CAgCC"}
|
|
@@ -16,10 +16,19 @@
|
|
|
16
16
|
*
|
|
17
17
|
* Given that we have to author a message there anyway, it should say what
|
|
18
18
|
* happened rather than be filler. So it does: how many messages left, at
|
|
19
|
-
* which iteration, by which strategy,
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
19
|
+
* which iteration, by which strategy, where they still are — and, since
|
|
20
|
+
* 9.57.0, WHICH TOOLS' RESULTS were among them. Unlike the compaction frame
|
|
21
|
+
* there is no model output involved at ALL — every character below is written
|
|
22
|
+
* by this library, and the only caller data that reaches it is a tool NAME,
|
|
23
|
+
* shape-filtered to a plain identifier and dropped outright when it is not
|
|
24
|
+
* one. So a drop still has no prompt-injection surface to speak of.
|
|
25
|
+
*
|
|
26
|
+
* That last sentence is the one this file exists for now. A drop the model is
|
|
27
|
+
* not told about is how a model came to invent an id: its `whats_here` result
|
|
28
|
+
* left the window, nothing said so, and it assembled a plausible-looking id
|
|
29
|
+
* out of an entity name it remembered. "Tool results are among them
|
|
30
|
+
* (whats_here) — call the tool again" is the difference between a re-fetch
|
|
31
|
+
* and a fabrication.
|
|
23
32
|
*
|
|
24
33
|
* It appears ONLY when the removal reaches the front of what may leave. That
|
|
25
34
|
* is the window's head in the ordinary case; since 9.55.0 it is the position
|
|
@@ -37,6 +46,39 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
37
46
|
exports.isDropNotice = exports.buildDropNotice = exports.DROP_NOTICE_PREFIX = void 0;
|
|
38
47
|
/** Opening of the authored notice. Stable — tests and readers match on it. */
|
|
39
48
|
exports.DROP_NOTICE_PREFIX = '[dropped history';
|
|
49
|
+
/**
|
|
50
|
+
* How many tool names the notice will print before it stops and says `…`.
|
|
51
|
+
*
|
|
52
|
+
* Four is enough to name what a turn was actually driving and small enough
|
|
53
|
+
* that the notice stays a sentence rather than a list. The record is not
|
|
54
|
+
* capped — see `WindowRecord.droppedObservations`.
|
|
55
|
+
*/
|
|
56
|
+
const MAX_NAMED_TOOLS = 4;
|
|
57
|
+
/**
|
|
58
|
+
* The only shape a tool name may take to reach the wire.
|
|
59
|
+
*
|
|
60
|
+
* A tool name is CALLER DATA — it comes from a `defineTool`, an MCP server, or
|
|
61
|
+
* a restored conversation somebody else wrote — and this notice is the one
|
|
62
|
+
* message in the drop path with no untrusted payload in it. A name that is not
|
|
63
|
+
* a plain identifier is DROPPED rather than truncated: truncating turns
|
|
64
|
+
* `ignore previous instructions and…` into `ignore previous instruction`,
|
|
65
|
+
* which is still an instruction. The record keeps the real name; the wire
|
|
66
|
+
* simply says less.
|
|
67
|
+
*/
|
|
68
|
+
const SAFE_TOOL_NAME = /^[A-Za-z0-9_.:-]{1,48}$/;
|
|
69
|
+
/**
|
|
70
|
+
* The tool names as the notice may print them: shape-filtered, deduplicated
|
|
71
|
+
* by the caller, capped, and `…` when the cap bit. Empty when nothing
|
|
72
|
+
* survived — and then the sentence is omitted entirely rather than printed
|
|
73
|
+
* with an empty list.
|
|
74
|
+
*/
|
|
75
|
+
function namesForWire(toolNames) {
|
|
76
|
+
const safe = toolNames.filter((n) => SAFE_TOOL_NAME.test(n));
|
|
77
|
+
if (safe.length === 0)
|
|
78
|
+
return '';
|
|
79
|
+
const shown = safe.slice(0, MAX_NAMED_TOOLS);
|
|
80
|
+
return safe.length > shown.length ? `${shown.join(', ')}, …` : shown.join(', ');
|
|
81
|
+
}
|
|
40
82
|
/**
|
|
41
83
|
* Build the message that takes the head position after a drop.
|
|
42
84
|
*
|
|
@@ -58,12 +100,22 @@ function buildDropNotice(facts) {
|
|
|
58
100
|
? `Your current request is kept — it is still in this window, above this line, and no ` +
|
|
59
101
|
`window strategy may drop it. `
|
|
60
102
|
: '';
|
|
103
|
+
// 9.57.0. The measured failure: a model whose tool result had been dropped
|
|
104
|
+
// assembled a plausible id out of an entity name it remembered and a shape
|
|
105
|
+
// it had seen, got refused, and in one archived run named a host that
|
|
106
|
+
// appears in no tool result at all. It was never told the evidence had
|
|
107
|
+
// gone. Now it is, by name, with the one instruction that recovers it.
|
|
108
|
+
const wireNames = facts.toolNames === undefined ? '' : namesForWire(facts.toolNames);
|
|
109
|
+
const observations = wireNames.length > 0
|
|
110
|
+
? `Tool results are among them (${wireNames}) — call the tool again if you need its ` +
|
|
111
|
+
`output; do not reconstruct ids or values from memory. `
|
|
112
|
+
: '';
|
|
61
113
|
return {
|
|
62
114
|
role: 'user',
|
|
63
115
|
content: `${exports.DROP_NOTICE_PREFIX} — ${facts.droppedMessageCount} earlier message(s) were dropped ` +
|
|
64
116
|
`from this window at iteration ${facts.iteration} by the '${facts.strategy}' window ` +
|
|
65
|
-
`strategy. ${kept}Nothing was summarized: those turns are simply not
|
|
66
|
-
`They are retained verbatim in this run's commit log.]`,
|
|
117
|
+
`strategy. ${kept}${observations}Nothing was summarized: those turns are simply not ` +
|
|
118
|
+
`being re-sent. They are retained verbatim in this run's commit log.]`,
|
|
67
119
|
};
|
|
68
120
|
}
|
|
69
121
|
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0CG;;;AAIH,8EAA8E;AACjE,QAAA,kBAAkB,GAAG,kBAAkB,CAAC;AAErD;;;;;;GAMG;AACH,MAAM,eAAe,GAAG,CAAC,CAAC;AAE1B;;;;;;;;;;GAUG;AACH,MAAM,cAAc,GAAG,yBAAyB,CAAC;AAEjD;;;;;GAKG;AACH,SAAS,YAAY,CAAC,SAA4B;IAChD,MAAM,IAAI,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7D,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IACjC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,eAAe,CAAC,CAAC;IAC7C,OAAO,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAClF,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,eAAe,CAAC,KAM/B;IACC,MAAM,IAAI,GACR,KAAK,CAAC,kBAAkB,KAAK,IAAI;QAC/B,CAAC,CAAC,qFAAqF;YACrF,+BAA+B;QACjC,CAAC,CAAC,EAAE,CAAC;IACT,2EAA2E;IAC3E,2EAA2E;IAC3E,sEAAsE;IACtE,uEAAuE;IACvE,uEAAuE;IACvE,MAAM,SAAS,GAAG,KAAK,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;IACrF,MAAM,YAAY,GAChB,SAAS,CAAC,MAAM,GAAG,CAAC;QAClB,CAAC,CAAC,gCAAgC,SAAS,0CAA0C;YACnF,wDAAwD;QAC1D,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,GAAG,YAAY,qDAAqD;YACrF,sEAAsE;KACzE,CAAC;AACJ,CAAC;AA/BD,0CA+BC;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"}
|
|
@@ -15,9 +15,39 @@
|
|
|
15
15
|
* money to discover.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.resolveTokenBudgetOptions = exports.resolveSlidingWindowOptions = exports.resolveCompactionOptions = exports.DEFAULT_RETENTION = exports.DEFAULT_KEEP_RECENT_TURNS = void 0;
|
|
18
|
+
exports.resolveTokenBudgetOptions = exports.resolveSlidingWindowOptions = exports.resolveCompactionOptions = exports.DEFAULT_RETENTION = exports.requireKeepLastToolResults = exports.DEFAULT_KEEP_LAST_TOOL_RESULTS = exports.DEFAULT_KEEP_RECENT_TURNS = void 0;
|
|
19
19
|
/** Default depth of the "never touch this" recent window. */
|
|
20
20
|
exports.DEFAULT_KEEP_RECENT_TURNS = 6;
|
|
21
|
+
/**
|
|
22
|
+
* How many tools' most recent results the window holds beyond
|
|
23
|
+
* `keepRecentTurns` when nobody said (9.57.0). ON by default, at 2.
|
|
24
|
+
*
|
|
25
|
+
* On by default for the same reason 9.55.0's anchor is: the counterfactual to
|
|
26
|
+
* a pinned 5,800-character tool result is not 5,800 bytes saved, it is a
|
|
27
|
+
* fabricated id, a refusal, a wasted action out of a small budget, and the
|
|
28
|
+
* same 5,800 bytes fetched again. That is a correctness failure the framework
|
|
29
|
+
* caused, and those are fixed on by default.
|
|
30
|
+
*
|
|
31
|
+
* TWO rather than one because the ceiling is spent newest-first among STALE
|
|
32
|
+
* candidates: a one-word acknowledgement from an actuator the model has
|
|
33
|
+
* stopped using can occupy a slot ahead of an older load-bearing observation.
|
|
34
|
+
* Two slots absorb that. `false` or `0` switches the pin off entirely.
|
|
35
|
+
*/
|
|
36
|
+
exports.DEFAULT_KEEP_LAST_TOOL_RESULTS = 2;
|
|
37
|
+
/**
|
|
38
|
+
* Validate the `keepLastToolResults` dial. Refused at construction, never
|
|
39
|
+
* mid-run — the house rule for every window option.
|
|
40
|
+
*/
|
|
41
|
+
function requireKeepLastToolResults(value, label) {
|
|
42
|
+
if (value === false)
|
|
43
|
+
return;
|
|
44
|
+
if (!Number.isInteger(value) || value < 0) {
|
|
45
|
+
throw new Error(`${label}: keepLastToolResults must be a whole number >= 0, or false, got ` +
|
|
46
|
+
`${String(value)}. It is how many tools' most recent results stay in the window ` +
|
|
47
|
+
`beyond keepRecentTurns; 0 and false both switch the pin off.`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.requireKeepLastToolResults = requireKeepLastToolResults;
|
|
21
51
|
/**
|
|
22
52
|
* What happens to folded messages when nobody said. The originals ride with
|
|
23
53
|
* the conversation: losing them has to be a choice somebody typed, not a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../../../src/core/agent/window/options.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAUH,6DAA6D;AAChD,QAAA,yBAAyB,GAAG,CAAC,CAAC;AAE3C;;;;GAIG;AACU,QAAA,iBAAiB,GAAwB,cAAc,CAAC;AAErE,MAAM,UAAU,GAAmC,CAAC,cAAc,EAAE,SAAS,CAAC,CAAC;AAE/E,SAAS,aAAa,CAAC,OAAgB,EAAE,KAAa,EAAE,KAAa;IACnE,IAAI,OAAO,KAAK,IAAI,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE,CAAC;QACpD,MAAM,IAAI,KAAK,CAAC,GAAG,KAAK,iCAAiC,KAAK,UAAU,OAAO,OAAO,GAAG,CAAC,CAAC;IAC7F,CAAC;AACH,CAAC;AAED,SAAS,gBAAgB,CAAC,eAAwB,EAAE,KAAa;IAC/D,IACE,OAAO,eAAe,KAAK,QAAQ;QACnC,CAAC,MAAM,CAAC,QAAQ,CAAC,eAAe,CAAC;QACjC,eAAe,IAAI,CAAC,EACpB,CAAC;QACD,MAAM,IAAI,KAAK,CACb,GAAG,KAAK,6DAA6D;YACnE,GAAG,MAAM,CAAC,eAAe,CAAC,0DAA0D;YACpF,sFAAsF;YACtF,eAAe,CAClB,CAAC;IACJ,CAAC;AACH,CAAC;AAED,SAAS,sBAAsB,CAAC,eAAwB,EAAE,KAAa;IACrE,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,eAAe,CAAC,IAAK,eAA0B,GAAG,CAAC,EAAE,CAAC;QAC1E,MAAM,IAAI,KAAK,CACb,GAAG,KAAK,kDAAkD,MAAM,C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;QAAE,sBAAsB,CAAC,eAAe,EAAE,KAAK,CAAC,CAAC;IAClF,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,eAAe,IAAI,iCAAyB,EAAE,CAAC;AAC5F,CAAC;AATD,8DASC"}
|
|
@@ -22,12 +22,55 @@
|
|
|
22
22
|
* slot just after the kept request when the request was the head;
|
|
23
23
|
* • when it does not, nothing is inserted: the original opening turn is
|
|
24
24
|
* still there, so there is no wire problem to solve.
|
|
25
|
+
*
|
|
26
|
+
* ## The notice is owed to the WIRE, not to politeness (9.57.0)
|
|
27
|
+
*
|
|
28
|
+
* That distinction used to be missing here, and it produced a livelock. The
|
|
29
|
+
* notice was authored whenever the removal reached the front of what may
|
|
30
|
+
* leave, and the whole removal was abandoned when the notice was not smaller
|
|
31
|
+
* than the span — but the obligation being guarded is narrower: **the window
|
|
32
|
+
* must open on a user turn.** When the message that would BECOME the head is
|
|
33
|
+
* already a user turn (the kept request, or an older user turn from a restored
|
|
34
|
+
* conversation), no notice is owed at all, and its 245–358 characters had no
|
|
35
|
+
* business vetoing a legitimate drop.
|
|
36
|
+
*
|
|
37
|
+
* Because the span is the longest CONTIGUOUS removable run, a blocker one turn
|
|
38
|
+
* along caps it at the same small span at every boundary — so the same verdict
|
|
39
|
+
* came back for ever and the window grew without bound. Two locally-correct
|
|
40
|
+
* rules composing into non-progress.
|
|
41
|
+
*
|
|
42
|
+
* So the decision is a LADDER: the rich notice, else the plain one, else no
|
|
43
|
+
* notice at all — and `'replacement-not-smaller'` only when the wire genuinely
|
|
44
|
+
* needs a message in that position and none of them is smaller than the span.
|
|
25
45
|
*/
|
|
26
46
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
47
|
exports.dropOldestSpan = void 0;
|
|
28
48
|
const notice_js_1 = require("../notice.js");
|
|
49
|
+
const toolNames_js_1 = require("../toolNames.js");
|
|
29
50
|
const removal_js_1 = require("../removal.js");
|
|
30
51
|
const turns_js_1 = require("../turns.js");
|
|
52
|
+
/**
|
|
53
|
+
* The first rung of the ladder that is SMALLER than the span it would replace,
|
|
54
|
+
* or `undefined` when none is.
|
|
55
|
+
*
|
|
56
|
+
* "Smaller", not "no larger": a notice exactly the size of the span buys
|
|
57
|
+
* nothing and costs the turns it replaced.
|
|
58
|
+
*/
|
|
59
|
+
function fittingNotice(spanChars, facts, keptRequestAtHead, toolNames) {
|
|
60
|
+
// The kept-request sentence is not a courtesy and is never traded away for
|
|
61
|
+
// size: a model that reads "3 earlier messages were dropped" and then finds
|
|
62
|
+
// a request above it has to be told which of the two facts to trust. The
|
|
63
|
+
// TOOL NAMES are the rung that can be traded — losing them costs the model
|
|
64
|
+
// a hint, while losing the drop costs it the whole window.
|
|
65
|
+
const base = { ...facts, ...(keptRequestAtHead && { currentRequestKept: true }) };
|
|
66
|
+
if (toolNames.length > 0) {
|
|
67
|
+
const rich = (0, notice_js_1.buildDropNotice)({ ...base, toolNames });
|
|
68
|
+
if (rich.content.length < spanChars)
|
|
69
|
+
return rich;
|
|
70
|
+
}
|
|
71
|
+
const plain = (0, notice_js_1.buildDropNotice)(base);
|
|
72
|
+
return plain.content.length < spanChars ? plain : undefined;
|
|
73
|
+
}
|
|
31
74
|
/**
|
|
32
75
|
* Drop the oldest contiguous removable span, if there is one.
|
|
33
76
|
*
|
|
@@ -74,18 +117,31 @@ function dropOldestSpan(input, keepRecentTurns, strategyName) {
|
|
|
74
117
|
const keptRequestAtHead = plan.from === 1 &&
|
|
75
118
|
plan.refusals.some((r) => r.reason === 'current-request' && r.turnIndex === 0);
|
|
76
119
|
if (spanStart === 0 || keptRequestAtHead) {
|
|
77
|
-
// The front of the droppable window is leaving
|
|
78
|
-
//
|
|
79
|
-
//
|
|
80
|
-
//
|
|
81
|
-
//
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
120
|
+
// The front of the droppable window is leaving. Ask the two questions
|
|
121
|
+
// separately, because they have different answers:
|
|
122
|
+
//
|
|
123
|
+
// 1. does the WIRE need a message in the head position? Only when the
|
|
124
|
+
// message that would become the head is not a user turn already.
|
|
125
|
+
// `head[0]` is the kept request on the 9.55.0 path (a user turn by
|
|
126
|
+
// definition); on the ordinary path `head` is empty and the new head
|
|
127
|
+
// is the first survivor. An empty result (reachable only from a
|
|
128
|
+
// strategy that keeps zero recent turns) counts as needing one.
|
|
129
|
+
// 2. does a notice FIT — is it smaller than what it replaces? Dropping
|
|
130
|
+
// two tiny turns to insert a longer notice is pure loss.
|
|
131
|
+
const newHead = head[0] ?? tail[0];
|
|
132
|
+
const wireNeedsNotice = newHead === undefined || newHead.role !== 'user';
|
|
133
|
+
const spanChars = (0, turns_js_1.windowChars)(span);
|
|
134
|
+
// The ladder. The rich notice is the one that names the tools whose
|
|
135
|
+
// results left; the plain one drops that sentence and keeps the rest.
|
|
136
|
+
const notice = fittingNotice(spanChars, { droppedMessageCount: span.length, iteration, strategy: strategyName }, keptRequestAtHead, (0, toolNames_js_1.droppedToolNames)(span, history));
|
|
137
|
+
if (notice !== undefined) {
|
|
138
|
+
// `head` is empty on the ordinary path, so this is byte-for-byte the
|
|
139
|
+
// `[notice, ...tail]` this function has always produced; when the
|
|
140
|
+
// request was kept it is `[request, notice, ...tail]`.
|
|
141
|
+
window = [...head, notice, ...tail];
|
|
142
|
+
insertedAtMs = droppedAtMs;
|
|
143
|
+
}
|
|
144
|
+
else if (wireNeedsNotice) {
|
|
89
145
|
// `'replacement-not-smaller'` since 8.14.0. A drop writes no summary —
|
|
90
146
|
// it never calls a summarizer at all — and the reason's old spelling
|
|
91
147
|
// (`'summary-not-smaller'`) named one that does not exist on this path.
|
|
@@ -94,11 +150,11 @@ function dropOldestSpan(input, keepRecentTurns, strategyName) {
|
|
|
94
150
|
...plan.refusals,
|
|
95
151
|
]);
|
|
96
152
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
153
|
+
else {
|
|
154
|
+
// Nothing is owed and nothing fits: drop silently. The record still
|
|
155
|
+
// names what left, which is where a reader looks anyway.
|
|
156
|
+
window = [...head, ...tail];
|
|
157
|
+
}
|
|
102
158
|
}
|
|
103
159
|
else {
|
|
104
160
|
window = [...head, ...tail];
|
|
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;;;AAGH,4CAA+C;AAC/C,kDAAmD;AACnD,8CAA2C;AAE3C,0CAAwD;AAwBxD;;;;;;GAMG;AACH,SAAS,aAAa,CACpB,SAAiB,EACjB,KAIC,EACD,iBAA0B,EAC1B,SAA4B;IAE5B,2EAA2E;IAC3E,4EAA4E;IAC5E,yEAAyE;IACzE,2EAA2E;IAC3E,2DAA2D;IAC3D,MAAM,IAAI,GAAG,EAAE,GAAG,KAAK,EAAE,GAAG,CAAC,iBAAiB,IAAI,EAAE,kBAAkB,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC;IAClF,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,GAAG,IAAA,2BAAe,EAAC,EAAE,GAAG,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC;QACrD,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,GAAG,SAAS;YAAE,OAAO,IAAI,CAAC;IACnD,CAAC;IACD,MAAM,KAAK,GAAG,IAAA,2BAAe,EAAC,IAAI,CAAC,CAAC;IACpC,OAAO,KAAK,CAAC,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AAC9D,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,cAAc,CAC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