@framers/agentos 0.5.1 → 0.5.3
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/dist/memory/retrieval/typed-network/TypedNetworkObserver.d.ts +53 -7
- package/dist/memory/retrieval/typed-network/TypedNetworkObserver.d.ts.map +1 -1
- package/dist/memory/retrieval/typed-network/TypedNetworkObserver.js +143 -18
- package/dist/memory/retrieval/typed-network/TypedNetworkObserver.js.map +1 -1
- package/dist/memory/retrieval/typed-network/prompts/extraction-schema.d.ts +56 -23
- package/dist/memory/retrieval/typed-network/prompts/extraction-schema.d.ts.map +1 -1
- package/dist/memory/retrieval/typed-network/prompts/extraction-schema.js +50 -10
- package/dist/memory/retrieval/typed-network/prompts/extraction-schema.js.map +1 -1
- package/dist/memory-router/MemoryRouter.d.ts +85 -1
- package/dist/memory-router/MemoryRouter.d.ts.map +1 -1
- package/dist/memory-router/MemoryRouter.js +88 -1
- package/dist/memory-router/MemoryRouter.js.map +1 -1
- package/dist/memory-router/dispatcher.d.ts +39 -1
- package/dist/memory-router/dispatcher.d.ts.map +1 -1
- package/dist/memory-router/dispatcher.js +9 -1
- package/dist/memory-router/dispatcher.js.map +1 -1
- package/dist/memory-router/index.d.ts +7 -5
- package/dist/memory-router/index.d.ts.map +1 -1
- package/dist/memory-router/index.js +7 -2
- package/dist/memory-router/index.js.map +1 -1
- package/dist/memory-router/retrieval-config.d.ts +147 -0
- package/dist/memory-router/retrieval-config.d.ts.map +1 -0
- package/dist/memory-router/retrieval-config.js +268 -0
- package/dist/memory-router/retrieval-config.js.map +1 -0
- package/dist/memory-router/routing-tables.d.ts +112 -0
- package/dist/memory-router/routing-tables.d.ts.map +1 -1
- package/dist/memory-router/routing-tables.js +113 -0
- package/dist/memory-router/routing-tables.js.map +1 -1
- package/package.json +1 -1
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
*/
|
|
20
20
|
import type { IMemoryClassifier, MemoryClassifierResult } from './classifier.js';
|
|
21
21
|
import { type MemoryBackendCostPoint } from './backend-costs.js';
|
|
22
|
-
import { type MemoryBackendId, type MemoryQueryCategory, type MemoryRouterPreset, type RoutingTable } from './routing-tables.js';
|
|
22
|
+
import { type AugmentedRoutingTable, type MemoryBackendId, type MemoryDispatchKey, type MemoryQueryCategory, type MemoryRouterPreset, type RoutingTable } from './routing-tables.js';
|
|
23
23
|
import { type MemoryBudgetMode, type MemoryRoutingDecision } from './select-backend.js';
|
|
24
24
|
import type { IMemoryDispatcher } from './dispatcher.js';
|
|
25
25
|
/**
|
|
@@ -83,6 +83,17 @@ export interface MemoryRouterOptions {
|
|
|
83
83
|
* execute the chosen backend themselves.
|
|
84
84
|
*/
|
|
85
85
|
readonly dispatcher?: IMemoryDispatcher<unknown, unknown>;
|
|
86
|
+
/**
|
|
87
|
+
* Optional augmented routing table. When supplied,
|
|
88
|
+
* {@link MemoryRouter.decideAugmented} and
|
|
89
|
+
* {@link MemoryRouter.decideAndDispatchAugmented} resolve each query
|
|
90
|
+
* to a composite {@link MemoryDispatchKey} (backend × retrieval-config)
|
|
91
|
+
* instead of the legacy single-axis backend pick.
|
|
92
|
+
*
|
|
93
|
+
* Existing consumers see no behavioral change unless they call the
|
|
94
|
+
* new augmented methods.
|
|
95
|
+
*/
|
|
96
|
+
readonly augmentedTable?: AugmentedRoutingTable;
|
|
86
97
|
}
|
|
87
98
|
/**
|
|
88
99
|
* Per-call options for {@link MemoryRouter.decide}.
|
|
@@ -119,6 +130,24 @@ export interface MemoryRouterDispatchedDecision<TTrace> {
|
|
|
119
130
|
readonly traces: TTrace[];
|
|
120
131
|
readonly backend: MemoryBackendId;
|
|
121
132
|
}
|
|
133
|
+
/**
|
|
134
|
+
* Bundled result of a `decideAugmented()` call. Carries the classifier
|
|
135
|
+
* result and the composite {@link MemoryDispatchKey} (backend ×
|
|
136
|
+
* retrieval-config) the augmented router resolved.
|
|
137
|
+
*/
|
|
138
|
+
export interface MemoryRouterAugmentedDecision {
|
|
139
|
+
readonly classifier: MemoryClassifierResult;
|
|
140
|
+
readonly dispatch: MemoryDispatchKey;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Bundled result of a `decideAndDispatchAugmented()` call. Combines
|
|
144
|
+
* the augmented decision with the dispatched traces.
|
|
145
|
+
*/
|
|
146
|
+
export interface MemoryRouterAugmentedDispatchedDecision<TTrace> {
|
|
147
|
+
readonly decision: MemoryRouterAugmentedDecision;
|
|
148
|
+
readonly traces: TTrace[];
|
|
149
|
+
readonly dispatch: MemoryDispatchKey;
|
|
150
|
+
}
|
|
122
151
|
/**
|
|
123
152
|
* Thrown when `decideAndDispatch` is called on a router that was
|
|
124
153
|
* constructed without a dispatcher.
|
|
@@ -126,6 +155,14 @@ export interface MemoryRouterDispatchedDecision<TTrace> {
|
|
|
126
155
|
export declare class MemoryRouterDispatcherMissingError extends Error {
|
|
127
156
|
constructor();
|
|
128
157
|
}
|
|
158
|
+
/**
|
|
159
|
+
* Thrown when `decideAugmented` or `decideAndDispatchAugmented` is
|
|
160
|
+
* called on a router that was constructed without an
|
|
161
|
+
* {@link AugmentedRoutingTable}.
|
|
162
|
+
*/
|
|
163
|
+
export declare class MemoryRouterAugmentedTableMissingError extends Error {
|
|
164
|
+
constructor();
|
|
165
|
+
}
|
|
129
166
|
/**
|
|
130
167
|
* The public MemoryRouter primitive. One instance per memory-recall
|
|
131
168
|
* endpoint; construct once at app startup with the chosen preset and
|
|
@@ -159,6 +196,7 @@ export declare class MemoryRouter {
|
|
|
159
196
|
private readonly classifier;
|
|
160
197
|
private readonly preset;
|
|
161
198
|
private readonly routingTable;
|
|
199
|
+
private readonly augmentedTable;
|
|
162
200
|
private readonly budgetPerQuery;
|
|
163
201
|
private readonly budgetMode;
|
|
164
202
|
private readonly backendCosts;
|
|
@@ -191,5 +229,51 @@ export declare class MemoryRouter {
|
|
|
191
229
|
* was supplied at construction.
|
|
192
230
|
*/
|
|
193
231
|
decideAndDispatch<TTrace, TPayload = undefined>(query: string, dispatchPayload?: TPayload, options?: MemoryRouterDecideOptions): Promise<MemoryRouterDispatchedDecision<TTrace>>;
|
|
232
|
+
/**
|
|
233
|
+
* Decide-only routing using the augmented table. Classifies the
|
|
234
|
+
* query, resolves a composite {@link MemoryDispatchKey} (backend ×
|
|
235
|
+
* retrieval-config) from the configured
|
|
236
|
+
* {@link AugmentedRoutingTable}, and returns both pieces.
|
|
237
|
+
*
|
|
238
|
+
* Does NOT execute the recall — pair with {@link IMemoryDispatcher}
|
|
239
|
+
* for the end-to-end flow, or call
|
|
240
|
+
* {@link MemoryRouter.decideAndDispatchAugmented} when both an
|
|
241
|
+
* augmented table and a dispatcher are wired.
|
|
242
|
+
*
|
|
243
|
+
* @param query - The user's memory-recall query text.
|
|
244
|
+
* @param options - Per-call overrides (ground-truth telemetry,
|
|
245
|
+
* prompt variant). The `groundTruthCategory` field is unused on
|
|
246
|
+
* this path because augmented routing has no `selectBackend`-style
|
|
247
|
+
* telemetry surface; tests pass it through anyway for parity.
|
|
248
|
+
* @returns The classifier result + composite dispatch key.
|
|
249
|
+
*
|
|
250
|
+
* @throws {@link MemoryRouterAugmentedTableMissingError} when no
|
|
251
|
+
* augmented table was supplied at construction.
|
|
252
|
+
*/
|
|
253
|
+
decideAugmented(query: string, options?: MemoryRouterDecideOptions): Promise<MemoryRouterAugmentedDecision>;
|
|
254
|
+
/**
|
|
255
|
+
* Decide + dispatch in one call, using the augmented table.
|
|
256
|
+
* Requires the router to have been constructed with both an
|
|
257
|
+
* {@link AugmentedRoutingTable} and a {@link IMemoryDispatcher}.
|
|
258
|
+
*
|
|
259
|
+
* The selected {@link RetrievalConfigId} is forwarded to the
|
|
260
|
+
* dispatcher's `retrievalConfig` arg; consumer-defined executors
|
|
261
|
+
* read it via the third-arg
|
|
262
|
+
* {@link MemoryBackendExecutorContext} parameter.
|
|
263
|
+
*
|
|
264
|
+
* @typeParam TTrace - Caller's trace shape (passed through verbatim).
|
|
265
|
+
* @typeParam TPayload - Caller's payload shape for the dispatcher.
|
|
266
|
+
* @param query - User memory-recall query.
|
|
267
|
+
* @param dispatchPayload - Optional payload forwarded to the
|
|
268
|
+
* per-backend executor (e.g. topK, retrieval policy).
|
|
269
|
+
* @param options - Per-call overrides (ground-truth telemetry,
|
|
270
|
+
* prompt variant).
|
|
271
|
+
*
|
|
272
|
+
* @throws {@link MemoryRouterAugmentedTableMissingError} when no
|
|
273
|
+
* augmented table was supplied at construction.
|
|
274
|
+
* @throws {@link MemoryRouterDispatcherMissingError} when no
|
|
275
|
+
* dispatcher was supplied at construction.
|
|
276
|
+
*/
|
|
277
|
+
decideAndDispatchAugmented<TTrace, TPayload = undefined>(query: string, dispatchPayload?: TPayload, options?: MemoryRouterDecideOptions): Promise<MemoryRouterAugmentedDispatchedDecision<TTrace>>;
|
|
194
278
|
}
|
|
195
279
|
//# sourceMappingURL=MemoryRouter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MemoryRouter.d.ts","sourceRoot":"","sources":["../../src/memory-router/MemoryRouter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EACV,iBAAiB,EACjB,sBAAsB,EACvB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAEL,KAAK,sBAAsB,EAC5B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,
|
|
1
|
+
{"version":3,"file":"MemoryRouter.d.ts","sourceRoot":"","sources":["../../src/memory-router/MemoryRouter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EACV,iBAAiB,EACjB,sBAAsB,EACvB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAEL,KAAK,sBAAsB,EAC5B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAGL,KAAK,qBAAqB,EAC1B,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,EACvB,KAAK,YAAY,EAClB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F,OAAO,CAAC,QAAQ,CAAC,uBAAuB,CAAU;IAClD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAA6C;gBAE5D,OAAO,EAAE,mBAAmB;IAgCxC;;;;;;;;;OASG;IACG,MAAM,CACV,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,yBAAyB,GAClC,OAAO,CAAC,oBAAoB,CAAC;IAuBhC;;;;;;;;;;;;;OAaG;IACG,iBAAiB,CAAC,MAAM,EAAE,QAAQ,GAAG,SAAS,EAClD,KAAK,EAAE,MAAM,EACb,eAAe,CAAC,EAAE,QAAQ,EAC1B,OAAO,CAAC,EAAE,yBAAyB,GAClC,OAAO,CAAC,8BAA8B,CAAC,MAAM,CAAC,CAAC;IAmBlD;;;;;;;;;;;;;;;;;;;;OAoBG;IACG,eAAe,CACnB,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,yBAAyB,GAClC,OAAO,CAAC,6BAA6B,CAAC;IAmBzC;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACG,0BAA0B,CAAC,MAAM,EAAE,QAAQ,GAAG,SAAS,EAC3D,KAAK,EAAE,MAAM,EACb,eAAe,CAAC,EAAE,QAAQ,EAC1B,OAAO,CAAC,EAAE,yBAAyB,GAClC,OAAO,CAAC,uCAAuC,CAAC,MAAM,CAAC,CAAC;CAmB5D"}
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
* @module @framers/agentos/memory-router/MemoryRouter
|
|
19
19
|
*/
|
|
20
20
|
import { DEFAULT_MEMORY_BACKEND_COSTS, } from './backend-costs.js';
|
|
21
|
-
import { PRESET_TABLES, } from './routing-tables.js';
|
|
21
|
+
import { PRESET_TABLES, selectAugmentedDispatch, } from './routing-tables.js';
|
|
22
22
|
import { selectBackend, } from './select-backend.js';
|
|
23
23
|
/**
|
|
24
24
|
* Thrown when `decideAndDispatch` is called on a router that was
|
|
@@ -31,6 +31,19 @@ export class MemoryRouterDispatcherMissingError extends Error {
|
|
|
31
31
|
this.name = 'MemoryRouterDispatcherMissingError';
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Thrown when `decideAugmented` or `decideAndDispatchAugmented` is
|
|
36
|
+
* called on a router that was constructed without an
|
|
37
|
+
* {@link AugmentedRoutingTable}.
|
|
38
|
+
*/
|
|
39
|
+
export class MemoryRouterAugmentedTableMissingError extends Error {
|
|
40
|
+
constructor() {
|
|
41
|
+
super('MemoryRouter.decideAugmented requires an augmentedTable. ' +
|
|
42
|
+
'Pass one in MemoryRouterOptions (e.g. MINIMIZE_COST_AUGMENTED_TABLE), ' +
|
|
43
|
+
'or use the legacy `decide` / `decideAndDispatch` methods.');
|
|
44
|
+
this.name = 'MemoryRouterAugmentedTableMissingError';
|
|
45
|
+
}
|
|
46
|
+
}
|
|
34
47
|
// ============================================================================
|
|
35
48
|
// Class
|
|
36
49
|
// ============================================================================
|
|
@@ -68,6 +81,7 @@ export class MemoryRouter {
|
|
|
68
81
|
this.classifier = options.classifier;
|
|
69
82
|
this.preset = options.preset ?? 'minimize-cost';
|
|
70
83
|
this.dispatcher = options.dispatcher ?? null;
|
|
84
|
+
this.augmentedTable = options.augmentedTable ?? null;
|
|
71
85
|
// Resolve routing table: explicit > preset's default.
|
|
72
86
|
const baseTable = options.routingTable ?? PRESET_TABLES[this.preset];
|
|
73
87
|
// Apply optional per-category mapping override.
|
|
@@ -151,5 +165,78 @@ export class MemoryRouter {
|
|
|
151
165
|
backend: dispatched.backend,
|
|
152
166
|
};
|
|
153
167
|
}
|
|
168
|
+
/**
|
|
169
|
+
* Decide-only routing using the augmented table. Classifies the
|
|
170
|
+
* query, resolves a composite {@link MemoryDispatchKey} (backend ×
|
|
171
|
+
* retrieval-config) from the configured
|
|
172
|
+
* {@link AugmentedRoutingTable}, and returns both pieces.
|
|
173
|
+
*
|
|
174
|
+
* Does NOT execute the recall — pair with {@link IMemoryDispatcher}
|
|
175
|
+
* for the end-to-end flow, or call
|
|
176
|
+
* {@link MemoryRouter.decideAndDispatchAugmented} when both an
|
|
177
|
+
* augmented table and a dispatcher are wired.
|
|
178
|
+
*
|
|
179
|
+
* @param query - The user's memory-recall query text.
|
|
180
|
+
* @param options - Per-call overrides (ground-truth telemetry,
|
|
181
|
+
* prompt variant). The `groundTruthCategory` field is unused on
|
|
182
|
+
* this path because augmented routing has no `selectBackend`-style
|
|
183
|
+
* telemetry surface; tests pass it through anyway for parity.
|
|
184
|
+
* @returns The classifier result + composite dispatch key.
|
|
185
|
+
*
|
|
186
|
+
* @throws {@link MemoryRouterAugmentedTableMissingError} when no
|
|
187
|
+
* augmented table was supplied at construction.
|
|
188
|
+
*/
|
|
189
|
+
async decideAugmented(query, options) {
|
|
190
|
+
if (!this.augmentedTable) {
|
|
191
|
+
throw new MemoryRouterAugmentedTableMissingError();
|
|
192
|
+
}
|
|
193
|
+
const useFewShot = options?.useFewShotPrompt ?? this.defaultUseFewShotPrompt;
|
|
194
|
+
const classifierOptions = useFewShot
|
|
195
|
+
? { useFewShotPrompt: true }
|
|
196
|
+
: undefined;
|
|
197
|
+
const classifier = await this.classifier.classify(query, classifierOptions);
|
|
198
|
+
const dispatch = selectAugmentedDispatch(classifier.category, this.augmentedTable);
|
|
199
|
+
return { classifier, dispatch };
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Decide + dispatch in one call, using the augmented table.
|
|
203
|
+
* Requires the router to have been constructed with both an
|
|
204
|
+
* {@link AugmentedRoutingTable} and a {@link IMemoryDispatcher}.
|
|
205
|
+
*
|
|
206
|
+
* The selected {@link RetrievalConfigId} is forwarded to the
|
|
207
|
+
* dispatcher's `retrievalConfig` arg; consumer-defined executors
|
|
208
|
+
* read it via the third-arg
|
|
209
|
+
* {@link MemoryBackendExecutorContext} parameter.
|
|
210
|
+
*
|
|
211
|
+
* @typeParam TTrace - Caller's trace shape (passed through verbatim).
|
|
212
|
+
* @typeParam TPayload - Caller's payload shape for the dispatcher.
|
|
213
|
+
* @param query - User memory-recall query.
|
|
214
|
+
* @param dispatchPayload - Optional payload forwarded to the
|
|
215
|
+
* per-backend executor (e.g. topK, retrieval policy).
|
|
216
|
+
* @param options - Per-call overrides (ground-truth telemetry,
|
|
217
|
+
* prompt variant).
|
|
218
|
+
*
|
|
219
|
+
* @throws {@link MemoryRouterAugmentedTableMissingError} when no
|
|
220
|
+
* augmented table was supplied at construction.
|
|
221
|
+
* @throws {@link MemoryRouterDispatcherMissingError} when no
|
|
222
|
+
* dispatcher was supplied at construction.
|
|
223
|
+
*/
|
|
224
|
+
async decideAndDispatchAugmented(query, dispatchPayload, options) {
|
|
225
|
+
if (!this.dispatcher) {
|
|
226
|
+
throw new MemoryRouterDispatcherMissingError();
|
|
227
|
+
}
|
|
228
|
+
const decision = await this.decideAugmented(query, options);
|
|
229
|
+
const dispatched = (await this.dispatcher.dispatch({
|
|
230
|
+
backend: decision.dispatch.backend,
|
|
231
|
+
retrievalConfig: decision.dispatch.retrievalConfig,
|
|
232
|
+
query,
|
|
233
|
+
payload: dispatchPayload,
|
|
234
|
+
}));
|
|
235
|
+
return {
|
|
236
|
+
decision,
|
|
237
|
+
traces: dispatched.traces,
|
|
238
|
+
dispatch: decision.dispatch,
|
|
239
|
+
};
|
|
240
|
+
}
|
|
154
241
|
}
|
|
155
242
|
//# sourceMappingURL=MemoryRouter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MemoryRouter.js","sourceRoot":"","sources":["../../src/memory-router/MemoryRouter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAMH,OAAO,EACL,4BAA4B,GAE7B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,aAAa,
|
|
1
|
+
{"version":3,"file":"MemoryRouter.js","sourceRoot":"","sources":["../../src/memory-router/MemoryRouter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAMH,OAAO,EACL,4BAA4B,GAE7B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAC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tC,UAAU,CAAC,QAAQ,EACnB,IAAI,CAAC,cAAc,CACpB,CAAC;QAEF,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC;IAClC,CAAC;IAED;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,KAAK,CAAC,0BAA0B,CAC9B,KAAa,EACb,eAA0B,EAC1B,OAAmC;QAEnC,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAC;YACrB,MAAM,IAAI,kCAAkC,EAAE,CAAC;QACjD,CAAC;QACD,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;QAE5D,MAAM,UAAU,GAAG,CAAC,MAAM,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC;YACjD,OAAO,EAAE,QAAQ,CAAC,QAAQ,CAAC,OAAO;YAClC,eAAe,EAAE,QAAQ,CAAC,QAAQ,CAAC,eAAe;YAClD,KAAK;YACL,OAAO,EAAE,eAA0B;SACpC,CAAC,CAAiC,CAAC;QAEpC,OAAO;YACL,QAAQ;YACR,MAAM,EAAE,UAAU,CAAC,MAAM;YACzB,QAAQ,EAAE,QAAQ,CAAC,QAAQ;SAC5B,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -29,17 +29,47 @@
|
|
|
29
29
|
* @module @framers/agentos/memory-router/dispatcher
|
|
30
30
|
*/
|
|
31
31
|
import type { MemoryBackendId } from './routing-tables.js';
|
|
32
|
+
import type { RetrievalConfigId } from './retrieval-config.js';
|
|
33
|
+
/**
|
|
34
|
+
* Optional execution context passed as the third argument to a
|
|
35
|
+
* {@link MemoryBackendExecutor}. Carries cross-cutting per-call hints
|
|
36
|
+
* the dispatcher knows about but the user-defined payload should not
|
|
37
|
+
* have to encode (e.g. the {@link RetrievalConfigId} chosen by the
|
|
38
|
+
* augmented router).
|
|
39
|
+
*
|
|
40
|
+
* Existing executors with the older two-argument signature
|
|
41
|
+
* `(query, payload) => traces` remain assignable to
|
|
42
|
+
* {@link MemoryBackendExecutor} because the context arg is optional —
|
|
43
|
+
* functions are contravariant in their parameters and JavaScript
|
|
44
|
+
* silently ignores unused trailing arguments.
|
|
45
|
+
*/
|
|
46
|
+
export interface MemoryBackendExecutorContext {
|
|
47
|
+
/**
|
|
48
|
+
* Augmented router's per-query retrieval-config pick. When set, the
|
|
49
|
+
* executor SHOULD apply the corresponding flags
|
|
50
|
+
* (see `RETRIEVAL_CONFIG_SPECS`) to its retrieval pipeline.
|
|
51
|
+
* Undefined when the dispatcher was called via the legacy backend-
|
|
52
|
+
* only path.
|
|
53
|
+
*/
|
|
54
|
+
readonly retrievalConfig?: RetrievalConfigId;
|
|
55
|
+
}
|
|
32
56
|
/**
|
|
33
57
|
* Per-backend execution function. Takes the query string + an optional
|
|
34
58
|
* caller-defined payload (e.g. topK, retrieval policy, session filter),
|
|
35
59
|
* returns the trace array.
|
|
36
60
|
*
|
|
61
|
+
* The optional third arg, {@link MemoryBackendExecutorContext}, carries
|
|
62
|
+
* cross-cutting hints the dispatcher routes through — currently the
|
|
63
|
+
* augmented router's per-query {@link RetrievalConfigId}. Executors
|
|
64
|
+
* written before augmented routing existed remain assignable because
|
|
65
|
+
* the third arg is optional.
|
|
66
|
+
*
|
|
37
67
|
* @typeParam TTrace - Shape of the trace the caller's memory layer emits.
|
|
38
68
|
* Defaults to the {@link ScoredTrace} shape from `@framers/agentos/memory`
|
|
39
69
|
* but any shape is accepted since the dispatcher is a pass-through.
|
|
40
70
|
* @typeParam TPayload - Shape of the optional payload argument.
|
|
41
71
|
*/
|
|
42
|
-
export type MemoryBackendExecutor<TTrace, TPayload = undefined> = (query: string, payload: TPayload) => Promise<TTrace[]>;
|
|
72
|
+
export type MemoryBackendExecutor<TTrace, TPayload = undefined> = (query: string, payload: TPayload, context?: MemoryBackendExecutorContext) => Promise<TTrace[]>;
|
|
43
73
|
/**
|
|
44
74
|
* Args passed to {@link IMemoryDispatcher.dispatch}.
|
|
45
75
|
*/
|
|
@@ -48,6 +78,14 @@ export interface MemoryDispatchArgs<TPayload = undefined> {
|
|
|
48
78
|
readonly query: string;
|
|
49
79
|
/** Optional payload forwarded to the per-backend executor verbatim. */
|
|
50
80
|
readonly payload?: TPayload;
|
|
81
|
+
/**
|
|
82
|
+
* Optional augmented-router pick. When supplied, the dispatcher
|
|
83
|
+
* forwards it as the third executor arg
|
|
84
|
+
* ({@link MemoryBackendExecutorContext.retrievalConfig}). Existing
|
|
85
|
+
* legacy callers omit this field; existing executors ignore the
|
|
86
|
+
* third arg unless they opt in.
|
|
87
|
+
*/
|
|
88
|
+
readonly retrievalConfig?: RetrievalConfigId;
|
|
51
89
|
}
|
|
52
90
|
/**
|
|
53
91
|
* Result of a dispatch call. Carries the traces plus the backend that
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dispatcher.d.ts","sourceRoot":"","sources":["../../src/memory-router/dispatcher.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"dispatcher.d.ts","sourceRoot":"","sources":["../../src/memory-router/dispatcher.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAM/D;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,4BAA4B;IAC3C;;;;;;OAMG;IACH,QAAQ,CAAC,eAAe,CAAC,EAAE,iBAAiB,CAAC;CAC9C;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,MAAM,qBAAqB,CAAC,MAAM,EAAE,QAAQ,GAAG,SAAS,IAAI,CAChE,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,QAAQ,EACjB,OAAO,CAAC,EAAE,4BAA4B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C;IAIvD,QAAQ,CACZ,IAAI,EAAE,kBAAkB,CAAC,QAAQ,CAAC,GACjC,OAAO,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC;CAiBzC"}
|
|
@@ -77,7 +77,15 @@ export class FunctionMemoryDispatcher {
|
|
|
77
77
|
if (!executor) {
|
|
78
78
|
throw new UnsupportedMemoryBackendError(args.backend);
|
|
79
79
|
}
|
|
80
|
-
|
|
80
|
+
// Preserve the legacy two-argument call shape on legacy dispatch
|
|
81
|
+
// calls (no retrievalConfig). Only pass the context arg when the
|
|
82
|
+
// augmented router has supplied a retrievalConfig — keeps existing
|
|
83
|
+
// mocks asserting `executor(query, payload)` working unchanged.
|
|
84
|
+
const traces = args.retrievalConfig !== undefined
|
|
85
|
+
? await executor(args.query, args.payload, {
|
|
86
|
+
retrievalConfig: args.retrievalConfig,
|
|
87
|
+
})
|
|
88
|
+
: await executor(args.query, args.payload);
|
|
81
89
|
return { traces, backend: args.backend };
|
|
82
90
|
}
|
|
83
91
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dispatcher.js","sourceRoot":"","sources":["../../src/memory-router/dispatcher.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;
|
|
1
|
+
{"version":3,"file":"dispatcher.js","sourceRoot":"","sources":["../../src/memory-router/dispatcher.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AA6FH;;;;GAIG;AACH,MAAM,OAAO,6BAA8B,SAAQ,KAAK;IACtD,YAA4B,OAAwB;QAClD,KAAK,CACH,8BAA8B,OAAO,uBAAuB;YAC1D,2DAA2D,CAC9D,CAAC;QAJwB,YAAO,GAAP,OAAO,CAAiB;QAKlD,IAAI,CAAC,IAAI,GAAG,+BAA+B,CAAC;IAC9C,CAAC;CACF;AAeD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,OAAO,wBAAwB;IAKnC,YAAY,QAAiD;QAC3D,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAED,KAAK,CAAC,QAAQ,CACZ,IAAkC;QAElC,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC7C,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,IAAI,6BAA6B,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACxD,CAAC;QACD,iEAAiE;QACjE,iEAAiE;QACjE,mEAAmE;QACnE,gEAAgE;QAChE,MAAM,MAAM,GACV,IAAI,CAAC,eAAe,KAAK,SAAS;YAChC,CAAC,CAAC,MAAM,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,OAAmB,EAAE;gBACnD,eAAe,EAAE,IAAI,CAAC,eAAe;aACtC,CAAC;YACJ,CAAC,CAAC,MAAM,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,OAAmB,CAAC,CAAC;QAC3D,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC;IAC3C,CAAC;CACF"}
|
|
@@ -108,21 +108,23 @@
|
|
|
108
108
|
* );
|
|
109
109
|
* ```
|
|
110
110
|
*/
|
|
111
|
-
export type { MemoryQueryCategory, MemoryBackendId, MemoryRouterPreset, RoutingTable, } from './routing-tables.js';
|
|
111
|
+
export type { MemoryQueryCategory, MemoryBackendId, MemoryRouterPreset, RoutingTable, AugmentedMemoryRouterPreset, AugmentedRoutingTable, MemoryDispatchKey, } from './routing-tables.js';
|
|
112
112
|
export { MEMORY_QUERY_CATEGORIES } from './routing-tables.js';
|
|
113
113
|
export type { MemoryBackendCostPoint } from './backend-costs.js';
|
|
114
114
|
export type { MemoryBudgetMode, MemoryRouterConfig, MemoryRoutingDecision, } from './select-backend.js';
|
|
115
115
|
export type { IMemoryClassifier, IMemoryClassifierLLM, MemoryClassifierLLMRequest, MemoryClassifierLLMResponse, MemoryClassifierClassifyOptions, MemoryClassifierResult, LLMMemoryClassifierOptions, } from './classifier.js';
|
|
116
|
-
export type { IMemoryDispatcher, MemoryDispatchArgs, MemoryDispatchResult, MemoryBackendExecutor, MemoryBackendRegistry, } from './dispatcher.js';
|
|
117
|
-
export type { MemoryBudgetPolicy, MemoryRouterOptions, MemoryRouterDecideOptions, MemoryRouterDecision, MemoryRouterDispatchedDecision, } from './MemoryRouter.js';
|
|
118
|
-
export { MINIMIZE_COST_TABLE, BALANCED_TABLE, MAXIMIZE_ACCURACY_TABLE, PRESET_TABLES, } from './routing-tables.js';
|
|
116
|
+
export type { IMemoryDispatcher, MemoryDispatchArgs, MemoryDispatchResult, MemoryBackendExecutor, MemoryBackendExecutorContext, MemoryBackendRegistry, } from './dispatcher.js';
|
|
117
|
+
export type { MemoryBudgetPolicy, MemoryRouterOptions, MemoryRouterDecideOptions, MemoryRouterDecision, MemoryRouterDispatchedDecision, MemoryRouterAugmentedDecision, MemoryRouterAugmentedDispatchedDecision, } from './MemoryRouter.js';
|
|
118
|
+
export { MINIMIZE_COST_TABLE, BALANCED_TABLE, MAXIMIZE_ACCURACY_TABLE, PRESET_TABLES, MINIMIZE_COST_AUGMENTED_TABLE, AUGMENTED_PRESET_TABLES, SAFE_FALLBACK_BACKEND, SAFE_FALLBACK_DISPATCH_KEY, selectAugmentedDispatch, } from './routing-tables.js';
|
|
119
119
|
export { TIER_1_CANONICAL_COSTS, TIER_2A_V10_COSTS, TIER_2B_V11_COSTS, DEFAULT_MEMORY_BACKEND_COSTS, } from './backend-costs.js';
|
|
120
120
|
export { selectBackend, MemoryRouterUnknownCategoryError, MemoryRouterBudgetExceededError, } from './select-backend.js';
|
|
121
121
|
export { CLASSIFIER_SYSTEM_PROMPT, CLASSIFIER_SYSTEM_PROMPT_FEWSHOT, SAFE_FALLBACK_CATEGORY, LLMMemoryClassifier, normalizeClassifierOutput, parseClassifierOutput, } from './classifier.js';
|
|
122
122
|
export { FunctionMemoryDispatcher, UnsupportedMemoryBackendError, } from './dispatcher.js';
|
|
123
|
-
export { MemoryRouter, MemoryRouterDispatcherMissingError, } from './MemoryRouter.js';
|
|
123
|
+
export { MemoryRouter, MemoryRouterDispatcherMissingError, MemoryRouterAugmentedTableMissingError, } from './MemoryRouter.js';
|
|
124
124
|
export type { CalibrationSample, CalibrationCell, AggregatedCalibration, AdaptivePresetRule, SelectByPresetArgs, BuildAdaptiveRoutingTableArgs, AdaptiveMemoryRouterOptions, } from './adaptive.js';
|
|
125
125
|
export { aggregateCalibration, selectByPreset, buildAdaptiveRoutingTable, AdaptiveMemoryRouter, } from './adaptive.js';
|
|
126
126
|
export { EntityRetrievalRanker, createEntityRetrievalRanker, } from './backends/index.js';
|
|
127
127
|
export type { RankedCandidate, RankedCandidateWithBoost, EntityRetrievalRankerOptions, } from './backends/index.js';
|
|
128
|
+
export { RETRIEVAL_CONFIG_IDS, RETRIEVAL_CONFIG_SPECS, M_PHASE_A_PER_CATEGORY_ACCURACY, M_PHASE_A_COST_PER_CORRECT, M_TUNED_PER_CATEGORY_TABLE, selectBestRetrievalConfig, computeOracleAggregate, computeOracleCostPerCorrect, } from './retrieval-config.js';
|
|
129
|
+
export type { RetrievalConfigId, RetrievalConfigSpec, } from './retrieval-config.js';
|
|
128
130
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/memory-router/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6GG;AAMH,YAAY,EACV,mBAAmB,EACnB,eAAe,EACf,kBAAkB,EAClB,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/memory-router/index.ts"],"names":[],"mappings":"AAAA;;;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AwB,EACxB,gCAAgC,EAChC,sBAAsB,EACtB,mBAAmB,EACnB,yBAAyB,EACzB,qBAAqB,GACtB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,wBAAwB,EACxB,6BAA6B,GAC9B,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,YAAY,EACZ,kCAAkC,EAClC,sCAAsC,GACvC,MAAM,mBAAmB,CAAC;AAM3B,YAAY,EACV,iBAAiB,EACjB,eAAe,EACf,qBAAqB,EACrB,kBAAkB,EAClB,kBAAkB,EAClB,6BAA6B,EAC7B,2BAA2B,GAC5B,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,oBAAoB,EACpB,cAAc,EACd,yBAAyB,EACzB,oBAAoB,GACrB,MAAM,eAAe,CAAC;AAMvB,OAAO,EACL,qBAAqB,EACrB,2BAA2B,GAC5B,MAAM,qBAAqB,CAAC;AAC7B,YAAY,EACV,eAAe,EACf,wBAAwB,EACxB,4BAA4B,GAC7B,MAAM,qBAAqB,CAAC;AAO7B,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,+BAA+B,EAC/B,0BAA0B,EAC1B,0BAA0B,EAC1B,yBAAyB,EACzB,sBAAsB,EACtB,2BAA2B,GAC5B,MAAM,uBAAuB,CAAC;AAE/B,YAAY,EACV,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,uBAAuB,CAAC"}
|
|
@@ -112,15 +112,20 @@ export { MEMORY_QUERY_CATEGORIES } from './routing-tables.js';
|
|
|
112
112
|
// ============================================================================
|
|
113
113
|
// Values
|
|
114
114
|
// ============================================================================
|
|
115
|
-
export { MINIMIZE_COST_TABLE, BALANCED_TABLE, MAXIMIZE_ACCURACY_TABLE, PRESET_TABLES, } from './routing-tables.js';
|
|
115
|
+
export { MINIMIZE_COST_TABLE, BALANCED_TABLE, MAXIMIZE_ACCURACY_TABLE, PRESET_TABLES, MINIMIZE_COST_AUGMENTED_TABLE, AUGMENTED_PRESET_TABLES, SAFE_FALLBACK_BACKEND, SAFE_FALLBACK_DISPATCH_KEY, selectAugmentedDispatch, } from './routing-tables.js';
|
|
116
116
|
export { TIER_1_CANONICAL_COSTS, TIER_2A_V10_COSTS, TIER_2B_V11_COSTS, DEFAULT_MEMORY_BACKEND_COSTS, } from './backend-costs.js';
|
|
117
117
|
export { selectBackend, MemoryRouterUnknownCategoryError, MemoryRouterBudgetExceededError, } from './select-backend.js';
|
|
118
118
|
export { CLASSIFIER_SYSTEM_PROMPT, CLASSIFIER_SYSTEM_PROMPT_FEWSHOT, SAFE_FALLBACK_CATEGORY, LLMMemoryClassifier, normalizeClassifierOutput, parseClassifierOutput, } from './classifier.js';
|
|
119
119
|
export { FunctionMemoryDispatcher, UnsupportedMemoryBackendError, } from './dispatcher.js';
|
|
120
|
-
export { MemoryRouter, MemoryRouterDispatcherMissingError, } from './MemoryRouter.js';
|
|
120
|
+
export { MemoryRouter, MemoryRouterDispatcherMissingError, MemoryRouterAugmentedTableMissingError, } from './MemoryRouter.js';
|
|
121
121
|
export { aggregateCalibration, selectByPreset, buildAdaptiveRoutingTable, AdaptiveMemoryRouter, } from './adaptive.js';
|
|
122
122
|
// ============================================================================
|
|
123
123
|
// Reference recall-stage backends (Stage I: Mem0-v3-style entity-linking)
|
|
124
124
|
// ============================================================================
|
|
125
125
|
export { EntityRetrievalRanker, createEntityRetrievalRanker, } from './backends/index.js';
|
|
126
|
+
// ============================================================================
|
|
127
|
+
// RetrievalConfigRouter (per-query retrieval-config dispatch, calibrated
|
|
128
|
+
// from 2026-04-26 LongMemEval-M Phase A N=54 ablation matrix)
|
|
129
|
+
// ============================================================================
|
|
130
|
+
export { RETRIEVAL_CONFIG_IDS, RETRIEVAL_CONFIG_SPECS, M_PHASE_A_PER_CATEGORY_ACCURACY, M_PHASE_A_COST_PER_CORRECT, M_TUNED_PER_CATEGORY_TABLE, selectBestRetrievalConfig, computeOracleAggregate, computeOracleCostPerCorrect, } from './retrieval-config.js';
|
|
126
131
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/memory-router/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6GG;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/memory-router/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6GG;AAeH,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC;AAuC9D,+EAA+E;AAC/E,SAAS;AACT,+EAA+E;AAE/E,OAAO,EACL,mBAAmB,EACnB,cAAc,EACd,uBAAuB,EACvB,aAAa,EACb,6BAA6B,EAC7B,uBAAuB,EACvB,qBAAqB,EACrB,0BAA0B,EAC1B,uBAAuB,GACxB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,sBAAsB,EACtB,iBAAiB,EACjB,iBAAiB,EACjB,4BAA4B,GAC7B,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,aAAa,EACb,gCAAgC,EAChC,+BAA+B,GAChC,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,wBAAwB,EACxB,gCAAgC,EAChC,sBAAsB,EACtB,mBAAmB,EACnB,yBAAyB,EACzB,qBAAqB,GACtB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,wBAAwB,EACxB,6BAA6B,GAC9B,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,YAAY,EACZ,kCAAkC,EAClC,sCAAsC,GACvC,MAAM,mBAAmB,CAAC;AAgB3B,OAAO,EACL,oBAAoB,EACpB,cAAc,EACd,yBAAyB,EACzB,oBAAoB,GACrB,MAAM,eAAe,CAAC;AAEvB,+EAA+E;AAC/E,0EAA0E;AAC1E,+EAA+E;AAE/E,OAAO,EACL,qBAAqB,EACrB,2BAA2B,GAC5B,MAAM,qBAAqB,CAAC;AAO7B,+EAA+E;AAC/E,yEAAyE;AACzE,8DAA8D;AAC9D,+EAA+E;AAE/E,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACtB,+BAA+B,EAC/B,0BAA0B,EAC1B,0BAA0B,EAC1B,yBAAyB,EACzB,sBAAsB,EACtB,2BAA2B,GAC5B,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file retrieval-config.ts
|
|
3
|
+
* @description RetrievalConfigRouter primitive — extends the
|
|
4
|
+
* MemoryRouter pattern with per-query retrieval-config dispatch.
|
|
5
|
+
*
|
|
6
|
+
* **What this primitive does:**
|
|
7
|
+
*
|
|
8
|
+
* The shipping {@link MemoryRouter} dispatches among recall BACKENDS
|
|
9
|
+
* (canonical-hybrid, OM-v10, OM-v11) per query. This module adds an
|
|
10
|
+
* orthogonal axis: per-query retrieval-CONFIG dispatch — picking
|
|
11
|
+
* among `(canonical, hyde, topk50, topk50-mult5, hyde-topk50, hyde-
|
|
12
|
+
* topk50-mult5)` based on the LLM classifier's predicted query
|
|
13
|
+
* category. Each variant configures different retrieval-precision
|
|
14
|
+
* knobs that lift different categories at different cost points.
|
|
15
|
+
*
|
|
16
|
+
* **Why this exists:**
|
|
17
|
+
*
|
|
18
|
+
* The 2026-04-26 ablation matrix on LongMemEval-M (Phase A N=54)
|
|
19
|
+
* showed dramatic per-category variance across retrieval-config
|
|
20
|
+
* combinations. Some categories (multi-session) only lift with the
|
|
21
|
+
* full combined config; others (temporal-reasoning) are best served
|
|
22
|
+
* by HyDE alone; cost-per-correct varies 4x across configs. A static
|
|
23
|
+
* always-on combined config leaves ~9 pp of accuracy on the table
|
|
24
|
+
* vs per-category-oracle dispatch.
|
|
25
|
+
*
|
|
26
|
+
* **Calibration source:**
|
|
27
|
+
*
|
|
28
|
+
* `M_TUNED_PER_CATEGORY_TABLE` is calibrated from the LongMemEval-M
|
|
29
|
+
* Phase A N=54 ablation runs documented in
|
|
30
|
+
* `apps/agentos-live-docs/blog/2026-04-26-longmemeval-m-30-to-57.md`
|
|
31
|
+
* §"Ablation matrix". Each category's pick is the ablation config
|
|
32
|
+
* that maximized accuracy for that category on M; ties broken by
|
|
33
|
+
* lower $/correct.
|
|
34
|
+
*
|
|
35
|
+
* **Opt-in by registration:**
|
|
36
|
+
*
|
|
37
|
+
* Consumers register only the {@link RetrievalConfigId} values they
|
|
38
|
+
* support in their dispatcher. The selector falls back to `canonical`
|
|
39
|
+
* if a registered config is not in the consumer's executor map.
|
|
40
|
+
*
|
|
41
|
+
* @module @framers/agentos/memory-router/retrieval-config
|
|
42
|
+
*/
|
|
43
|
+
import type { MemoryQueryCategory } from './routing-tables.js';
|
|
44
|
+
/**
|
|
45
|
+
* Retrieval-config variants. Each maps to a flag combination on the
|
|
46
|
+
* agentos-bench CLI; consumers building outside the bench wire each
|
|
47
|
+
* variant to a different retrieval pipeline.
|
|
48
|
+
*
|
|
49
|
+
* - `canonical`: BM25 + dense + Cohere rerank-v3.5 + reader-top-k 20
|
|
50
|
+
* (baseline; matches the existing MemoryRouter `canonical-hybrid`
|
|
51
|
+
* backend's default config).
|
|
52
|
+
* - `hyde`: canonical + HyDE hypothetical-document embedding.
|
|
53
|
+
* - `topk50`: canonical + reader-top-k 50.
|
|
54
|
+
* - `topk50-mult5`: canonical + reader-top-k 50 +
|
|
55
|
+
* rerank-candidate-multiplier 5 (250-chunk pool).
|
|
56
|
+
* - `hyde-topk50`: hyde + reader-top-k 50.
|
|
57
|
+
* - `hyde-topk50-mult5`: hyde + reader-top-k 50 + rerank-candidate-
|
|
58
|
+
* multiplier 5 (the 2026-04-26 M-tuned combined config).
|
|
59
|
+
*/
|
|
60
|
+
export declare const RETRIEVAL_CONFIG_IDS: readonly ["canonical", "hyde", "topk50", "topk50-mult5", "hyde-topk50", "hyde-topk50-mult5"];
|
|
61
|
+
/** {@link RETRIEVAL_CONFIG_IDS} as a TypeScript literal type. */
|
|
62
|
+
export type RetrievalConfigId = (typeof RETRIEVAL_CONFIG_IDS)[number];
|
|
63
|
+
/**
|
|
64
|
+
* Per-flag breakdown of a {@link RetrievalConfigId}. The fields
|
|
65
|
+
* correspond directly to the agentos-bench CLI flags so consumers
|
|
66
|
+
* can apply the config to their own retrieval pipeline.
|
|
67
|
+
*/
|
|
68
|
+
export interface RetrievalConfigSpec {
|
|
69
|
+
/** Stable identifier. */
|
|
70
|
+
id: RetrievalConfigId;
|
|
71
|
+
/** Enable HyDE (hypothetical-document embedding). Default false. */
|
|
72
|
+
hyde: boolean;
|
|
73
|
+
/** Cohere rerank candidate multiplier. Default 3 (matches `--rerank-candidate-multiplier 3`). */
|
|
74
|
+
rerankCandidateMultiplier: number;
|
|
75
|
+
/** Reader-side top-K cutoff after rerank. Default 20 (matches `--reader-top-k 20`). */
|
|
76
|
+
readerTopK: number;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Frozen registry of {@link RetrievalConfigSpec} by id. Consumers
|
|
80
|
+
* read this to find the per-flag values for a given config id.
|
|
81
|
+
*
|
|
82
|
+
* Mutating returned spec objects is undefined behavior — they are
|
|
83
|
+
* frozen at module load.
|
|
84
|
+
*/
|
|
85
|
+
export declare const RETRIEVAL_CONFIG_SPECS: Readonly<Record<RetrievalConfigId, Readonly<RetrievalConfigSpec>>>;
|
|
86
|
+
/**
|
|
87
|
+
* Per-category accuracy at each retrieval config on LongMemEval-M
|
|
88
|
+
* Phase A N=54 stratified, seed=42, gpt-4o reader, gpt-4o-2024-08-06
|
|
89
|
+
* judge. Source: ablation runs in
|
|
90
|
+
* `packages/agentos-bench/results/runs/2026-04-26T01-40-34-904--*`
|
|
91
|
+
* through `2026-04-26T03-22-06-857--*`.
|
|
92
|
+
*
|
|
93
|
+
* Numbers in the (0, 1) range. Use {@link selectBestRetrievalConfig}
|
|
94
|
+
* to pick the highest-accuracy config for a category.
|
|
95
|
+
*/
|
|
96
|
+
export declare const M_PHASE_A_PER_CATEGORY_ACCURACY: Readonly<Record<MemoryQueryCategory, Readonly<Record<RetrievalConfigId, number>>>>;
|
|
97
|
+
/**
|
|
98
|
+
* Approximate $/correct for each retrieval config on LongMemEval-M
|
|
99
|
+
* Phase A N=54 (full pipeline cost / correct cases). Source: same
|
|
100
|
+
* run JSONs as {@link M_PHASE_A_PER_CATEGORY_ACCURACY}. Used to
|
|
101
|
+
* break ties when multiple configs achieve the same per-category
|
|
102
|
+
* accuracy.
|
|
103
|
+
*/
|
|
104
|
+
export declare const M_PHASE_A_COST_PER_CORRECT: Readonly<Record<RetrievalConfigId, number>>;
|
|
105
|
+
/**
|
|
106
|
+
* Calibrated dispatch table: per-category, the
|
|
107
|
+
* {@link RetrievalConfigId} that maximizes accuracy on LongMemEval-M
|
|
108
|
+
* Phase A. Ties broken by lower $/correct.
|
|
109
|
+
*
|
|
110
|
+
* **Calibration validity:** N=54 stratified, single seed, single
|
|
111
|
+
* benchmark variant. Phase B at N=500 will tighten the per-category
|
|
112
|
+
* confidence intervals; the table here is the directional best-
|
|
113
|
+
* guess for v2 and should be re-derived from any future Phase B run.
|
|
114
|
+
*/
|
|
115
|
+
export declare const M_TUNED_PER_CATEGORY_TABLE: Readonly<Record<MemoryQueryCategory, RetrievalConfigId>>;
|
|
116
|
+
/**
|
|
117
|
+
* Pure-function selector: given a category and an optional set of
|
|
118
|
+
* registered configs, return the {@link RetrievalConfigId} that
|
|
119
|
+
* maximizes accuracy on LongMemEval-M Phase A. Falls back to
|
|
120
|
+
* `canonical` if the calibrated pick is not in the registered set.
|
|
121
|
+
*
|
|
122
|
+
* @param category - Predicted query category from the classifier.
|
|
123
|
+
* @param registered - Optional set of config IDs the consumer's
|
|
124
|
+
* dispatcher supports. When omitted, all configs are considered
|
|
125
|
+
* registered.
|
|
126
|
+
*/
|
|
127
|
+
export declare function selectBestRetrievalConfig(category: MemoryQueryCategory, registered?: readonly RetrievalConfigId[]): RetrievalConfigId;
|
|
128
|
+
/**
|
|
129
|
+
* Compute the calibrated per-category-oracle aggregate accuracy for
|
|
130
|
+
* a hypothetical workload distribution. Useful for forecasting the
|
|
131
|
+
* lift a per-query dispatcher would produce vs a static config.
|
|
132
|
+
*
|
|
133
|
+
* @param categoryWeights - Distribution over categories summing to
|
|
134
|
+
* 1.0 (e.g. LongMemEval-M's roughly 27% MS / 27% TR / 16% KU /
|
|
135
|
+
* 14% SSU / 11% SSA / 6% SSP).
|
|
136
|
+
* @param registered - Optional registered config subset.
|
|
137
|
+
* @returns Expected aggregate accuracy when each category is routed
|
|
138
|
+
* to its calibrated best config.
|
|
139
|
+
*/
|
|
140
|
+
export declare function computeOracleAggregate(categoryWeights: Readonly<Record<MemoryQueryCategory, number>>, registered?: readonly RetrievalConfigId[]): number;
|
|
141
|
+
/**
|
|
142
|
+
* Compute the corresponding $/correct for the per-category-oracle
|
|
143
|
+
* dispatch under a category distribution. Useful for forecasting
|
|
144
|
+
* cost-efficiency under per-query routing.
|
|
145
|
+
*/
|
|
146
|
+
export declare function computeOracleCostPerCorrect(categoryWeights: Readonly<Record<MemoryQueryCategory, number>>, registered?: readonly RetrievalConfigId[]): number;
|
|
147
|
+
//# sourceMappingURL=retrieval-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retrieval-config.d.ts","sourceRoot":"","sources":["../../src/memory-router/retrieval-config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE/D;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,oBAAoB,8FAOvB,CAAC;AAEX,iEAAiE;AACjE,MAAM,MAAM,iBAAiB,GAAG,CAAC,OAAO,oBAAoB,CAAC,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