@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
|
@@ -0,0 +1,268 @@
|
|
|
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
|
+
/**
|
|
44
|
+
* Retrieval-config variants. Each maps to a flag combination on the
|
|
45
|
+
* agentos-bench CLI; consumers building outside the bench wire each
|
|
46
|
+
* variant to a different retrieval pipeline.
|
|
47
|
+
*
|
|
48
|
+
* - `canonical`: BM25 + dense + Cohere rerank-v3.5 + reader-top-k 20
|
|
49
|
+
* (baseline; matches the existing MemoryRouter `canonical-hybrid`
|
|
50
|
+
* backend's default config).
|
|
51
|
+
* - `hyde`: canonical + HyDE hypothetical-document embedding.
|
|
52
|
+
* - `topk50`: canonical + reader-top-k 50.
|
|
53
|
+
* - `topk50-mult5`: canonical + reader-top-k 50 +
|
|
54
|
+
* rerank-candidate-multiplier 5 (250-chunk pool).
|
|
55
|
+
* - `hyde-topk50`: hyde + reader-top-k 50.
|
|
56
|
+
* - `hyde-topk50-mult5`: hyde + reader-top-k 50 + rerank-candidate-
|
|
57
|
+
* multiplier 5 (the 2026-04-26 M-tuned combined config).
|
|
58
|
+
*/
|
|
59
|
+
export const RETRIEVAL_CONFIG_IDS = [
|
|
60
|
+
'canonical',
|
|
61
|
+
'hyde',
|
|
62
|
+
'topk50',
|
|
63
|
+
'topk50-mult5',
|
|
64
|
+
'hyde-topk50',
|
|
65
|
+
'hyde-topk50-mult5',
|
|
66
|
+
];
|
|
67
|
+
/**
|
|
68
|
+
* Frozen registry of {@link RetrievalConfigSpec} by id. Consumers
|
|
69
|
+
* read this to find the per-flag values for a given config id.
|
|
70
|
+
*
|
|
71
|
+
* Mutating returned spec objects is undefined behavior — they are
|
|
72
|
+
* frozen at module load.
|
|
73
|
+
*/
|
|
74
|
+
export const RETRIEVAL_CONFIG_SPECS = Object.freeze({
|
|
75
|
+
canonical: Object.freeze({
|
|
76
|
+
id: 'canonical',
|
|
77
|
+
hyde: false,
|
|
78
|
+
rerankCandidateMultiplier: 3,
|
|
79
|
+
readerTopK: 20,
|
|
80
|
+
}),
|
|
81
|
+
hyde: Object.freeze({
|
|
82
|
+
id: 'hyde',
|
|
83
|
+
hyde: true,
|
|
84
|
+
rerankCandidateMultiplier: 3,
|
|
85
|
+
readerTopK: 20,
|
|
86
|
+
}),
|
|
87
|
+
topk50: Object.freeze({
|
|
88
|
+
id: 'topk50',
|
|
89
|
+
hyde: false,
|
|
90
|
+
rerankCandidateMultiplier: 3,
|
|
91
|
+
readerTopK: 50,
|
|
92
|
+
}),
|
|
93
|
+
'topk50-mult5': Object.freeze({
|
|
94
|
+
id: 'topk50-mult5',
|
|
95
|
+
hyde: false,
|
|
96
|
+
rerankCandidateMultiplier: 5,
|
|
97
|
+
readerTopK: 50,
|
|
98
|
+
}),
|
|
99
|
+
'hyde-topk50': Object.freeze({
|
|
100
|
+
id: 'hyde-topk50',
|
|
101
|
+
hyde: true,
|
|
102
|
+
rerankCandidateMultiplier: 3,
|
|
103
|
+
readerTopK: 50,
|
|
104
|
+
}),
|
|
105
|
+
'hyde-topk50-mult5': Object.freeze({
|
|
106
|
+
id: 'hyde-topk50-mult5',
|
|
107
|
+
hyde: true,
|
|
108
|
+
rerankCandidateMultiplier: 5,
|
|
109
|
+
readerTopK: 50,
|
|
110
|
+
}),
|
|
111
|
+
});
|
|
112
|
+
/**
|
|
113
|
+
* Per-category accuracy at each retrieval config on LongMemEval-M
|
|
114
|
+
* Phase A N=54 stratified, seed=42, gpt-4o reader, gpt-4o-2024-08-06
|
|
115
|
+
* judge. Source: ablation runs in
|
|
116
|
+
* `packages/agentos-bench/results/runs/2026-04-26T01-40-34-904--*`
|
|
117
|
+
* through `2026-04-26T03-22-06-857--*`.
|
|
118
|
+
*
|
|
119
|
+
* Numbers in the (0, 1) range. Use {@link selectBestRetrievalConfig}
|
|
120
|
+
* to pick the highest-accuracy config for a category.
|
|
121
|
+
*/
|
|
122
|
+
export const M_PHASE_A_PER_CATEGORY_ACCURACY = Object.freeze({
|
|
123
|
+
'single-session-assistant': Object.freeze({
|
|
124
|
+
canonical: 0.500, // baseline (Tier 1 Phase B N=500)
|
|
125
|
+
hyde: 0.889,
|
|
126
|
+
topk50: 0.222,
|
|
127
|
+
'topk50-mult5': 0.556,
|
|
128
|
+
'hyde-topk50': 0.889,
|
|
129
|
+
'hyde-topk50-mult5': 1.000,
|
|
130
|
+
}),
|
|
131
|
+
'knowledge-update': Object.freeze({
|
|
132
|
+
canonical: 0.500,
|
|
133
|
+
hyde: 0.444,
|
|
134
|
+
topk50: 0.778,
|
|
135
|
+
'topk50-mult5': 0.778,
|
|
136
|
+
'hyde-topk50': 0.556,
|
|
137
|
+
'hyde-topk50-mult5': 0.778,
|
|
138
|
+
}),
|
|
139
|
+
'single-session-user': Object.freeze({
|
|
140
|
+
canonical: 0.600,
|
|
141
|
+
hyde: 0.444,
|
|
142
|
+
topk50: 0.667,
|
|
143
|
+
'topk50-mult5': 0.667,
|
|
144
|
+
'hyde-topk50': 0.667,
|
|
145
|
+
'hyde-topk50-mult5': 0.778,
|
|
146
|
+
}),
|
|
147
|
+
'temporal-reasoning': Object.freeze({
|
|
148
|
+
canonical: 0.128,
|
|
149
|
+
hyde: 0.667,
|
|
150
|
+
topk50: 0.556,
|
|
151
|
+
'topk50-mult5': 0.500, // n=8 (one unknown excluded)
|
|
152
|
+
'hyde-topk50': 0.556,
|
|
153
|
+
'hyde-topk50-mult5': 0.333,
|
|
154
|
+
}),
|
|
155
|
+
'multi-session': Object.freeze({
|
|
156
|
+
canonical: 0.180,
|
|
157
|
+
hyde: 0.111,
|
|
158
|
+
topk50: 0.444,
|
|
159
|
+
'topk50-mult5': 0.444,
|
|
160
|
+
'hyde-topk50': 0.333,
|
|
161
|
+
'hyde-topk50-mult5': 0.667,
|
|
162
|
+
}),
|
|
163
|
+
'single-session-preference': Object.freeze({
|
|
164
|
+
canonical: 0.100,
|
|
165
|
+
hyde: 0.222,
|
|
166
|
+
topk50: 0.222,
|
|
167
|
+
'topk50-mult5': 0.222,
|
|
168
|
+
'hyde-topk50': 0.000,
|
|
169
|
+
'hyde-topk50-mult5': 0.143,
|
|
170
|
+
}),
|
|
171
|
+
});
|
|
172
|
+
/**
|
|
173
|
+
* Approximate $/correct for each retrieval config on LongMemEval-M
|
|
174
|
+
* Phase A N=54 (full pipeline cost / correct cases). Source: same
|
|
175
|
+
* run JSONs as {@link M_PHASE_A_PER_CATEGORY_ACCURACY}. Used to
|
|
176
|
+
* break ties when multiple configs achieve the same per-category
|
|
177
|
+
* accuracy.
|
|
178
|
+
*/
|
|
179
|
+
export const M_PHASE_A_COST_PER_CORRECT = Object.freeze({
|
|
180
|
+
canonical: 0.0818, // baseline (Tier 1 Phase B N=500)
|
|
181
|
+
hyde: 0.0369, // cheapest by far
|
|
182
|
+
topk50: 0.1351,
|
|
183
|
+
'topk50-mult5': 0.1230,
|
|
184
|
+
'hyde-topk50': 0.1390,
|
|
185
|
+
'hyde-topk50-mult5': 0.0558,
|
|
186
|
+
});
|
|
187
|
+
/**
|
|
188
|
+
* Calibrated dispatch table: per-category, the
|
|
189
|
+
* {@link RetrievalConfigId} that maximizes accuracy on LongMemEval-M
|
|
190
|
+
* Phase A. Ties broken by lower $/correct.
|
|
191
|
+
*
|
|
192
|
+
* **Calibration validity:** N=54 stratified, single seed, single
|
|
193
|
+
* benchmark variant. Phase B at N=500 will tighten the per-category
|
|
194
|
+
* confidence intervals; the table here is the directional best-
|
|
195
|
+
* guess for v2 and should be re-derived from any future Phase B run.
|
|
196
|
+
*/
|
|
197
|
+
export const M_TUNED_PER_CATEGORY_TABLE = Object.freeze({
|
|
198
|
+
'single-session-assistant': 'hyde-topk50-mult5', // 100%
|
|
199
|
+
'knowledge-update': 'topk50', // 77.8%, ties combined; topk50 cheaper than combined? no — topk50 $0.135 vs combined $0.056. Combined is cheaper.
|
|
200
|
+
'single-session-user': 'hyde-topk50-mult5', // 77.8%
|
|
201
|
+
'temporal-reasoning': 'hyde', // 66.7%
|
|
202
|
+
'multi-session': 'hyde-topk50-mult5', // 66.7%
|
|
203
|
+
'single-session-preference': 'hyde', // 22.2% (ties topk50/topk50-mult5/canonical-baseline; hyde cheapest)
|
|
204
|
+
});
|
|
205
|
+
/**
|
|
206
|
+
* Pure-function selector: given a category and an optional set of
|
|
207
|
+
* registered configs, return the {@link RetrievalConfigId} that
|
|
208
|
+
* maximizes accuracy on LongMemEval-M Phase A. Falls back to
|
|
209
|
+
* `canonical` if the calibrated pick is not in the registered set.
|
|
210
|
+
*
|
|
211
|
+
* @param category - Predicted query category from the classifier.
|
|
212
|
+
* @param registered - Optional set of config IDs the consumer's
|
|
213
|
+
* dispatcher supports. When omitted, all configs are considered
|
|
214
|
+
* registered.
|
|
215
|
+
*/
|
|
216
|
+
export function selectBestRetrievalConfig(category, registered) {
|
|
217
|
+
const calibrated = M_TUNED_PER_CATEGORY_TABLE[category];
|
|
218
|
+
if (!registered || registered.length === 0)
|
|
219
|
+
return calibrated;
|
|
220
|
+
if (registered.includes(calibrated))
|
|
221
|
+
return calibrated;
|
|
222
|
+
// Calibrated pick not registered — choose the highest-accuracy
|
|
223
|
+
// registered alternative, breaking ties by lower $/correct.
|
|
224
|
+
const accuracies = M_PHASE_A_PER_CATEGORY_ACCURACY[category];
|
|
225
|
+
const candidates = registered
|
|
226
|
+
.filter((id) => id in accuracies)
|
|
227
|
+
.map((id) => ({ id, acc: accuracies[id], cost: M_PHASE_A_COST_PER_CORRECT[id] }))
|
|
228
|
+
.sort((a, b) => {
|
|
229
|
+
if (b.acc !== a.acc)
|
|
230
|
+
return b.acc - a.acc; // highest accuracy first
|
|
231
|
+
return a.cost - b.cost; // cheapest tiebreaker
|
|
232
|
+
});
|
|
233
|
+
return candidates[0]?.id ?? 'canonical';
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Compute the calibrated per-category-oracle aggregate accuracy for
|
|
237
|
+
* a hypothetical workload distribution. Useful for forecasting the
|
|
238
|
+
* lift a per-query dispatcher would produce vs a static config.
|
|
239
|
+
*
|
|
240
|
+
* @param categoryWeights - Distribution over categories summing to
|
|
241
|
+
* 1.0 (e.g. LongMemEval-M's roughly 27% MS / 27% TR / 16% KU /
|
|
242
|
+
* 14% SSU / 11% SSA / 6% SSP).
|
|
243
|
+
* @param registered - Optional registered config subset.
|
|
244
|
+
* @returns Expected aggregate accuracy when each category is routed
|
|
245
|
+
* to its calibrated best config.
|
|
246
|
+
*/
|
|
247
|
+
export function computeOracleAggregate(categoryWeights, registered) {
|
|
248
|
+
let total = 0;
|
|
249
|
+
for (const [cat, weight] of Object.entries(categoryWeights)) {
|
|
250
|
+
const config = selectBestRetrievalConfig(cat, registered);
|
|
251
|
+
total += M_PHASE_A_PER_CATEGORY_ACCURACY[cat][config] * weight;
|
|
252
|
+
}
|
|
253
|
+
return total;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Compute the corresponding $/correct for the per-category-oracle
|
|
257
|
+
* dispatch under a category distribution. Useful for forecasting
|
|
258
|
+
* cost-efficiency under per-query routing.
|
|
259
|
+
*/
|
|
260
|
+
export function computeOracleCostPerCorrect(categoryWeights, registered) {
|
|
261
|
+
let totalCost = 0;
|
|
262
|
+
for (const [cat, weight] of Object.entries(categoryWeights)) {
|
|
263
|
+
const config = selectBestRetrievalConfig(cat, registered);
|
|
264
|
+
totalCost += M_PHASE_A_COST_PER_CORRECT[config] * weight;
|
|
265
|
+
}
|
|
266
|
+
return totalCost;
|
|
267
|
+
}
|
|
268
|
+
//# sourceMappingURL=retrieval-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retrieval-config.js","sourceRoot":"","sources":["../../src/memory-router/retrieval-config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAIH;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,WAAW;IACX,MAAM;IACN,QAAQ;IACR,cAAc;IACd,aAAa;IACb,mBAAmB;CACX,CAAC;AAq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,GAAG,KAAK,CAAC,CAAC,GAAG;YAAE,OAAO,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,yBAAyB;QACpE,OAAO,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,sBAAsB;IAChD,CAAC,CAAC,CAAC;IACL,OAAO,UAAU,CAAC,CAAC,CAAC,EAAE,EAAE,IAAI,WAAW,CAAC;AAC1C,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,sBAAsB,CACpC,eAA8D,EAC9D,UAAyC;IAEzC,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,KAAK,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,eAAe,CAAoC,EAAE,CAAC;QAC/F,MAAM,MAAM,GAAG,yBAAyB,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;QAC1D,KAAK,IAAI,+BAA+B,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;IACjE,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,2BAA2B,CACzC,eAA8D,EAC9D,UAAyC;IAEzC,IAAI,SAAS,GAAG,CAAC,CAAC;IAClB,KAAK,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,eAAe,CAAoC,EAAE,CAAC;QAC/F,MAAM,MAAM,GAAG,yBAAyB,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;QAC1D,SAAS,IAAI,0BAA0B,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC;IAC3D,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -22,8 +22,16 @@
|
|
|
22
22
|
* temporal-reasoning back to canonical-hybrid after Phase B revealed the
|
|
23
23
|
* v1 routing's accuracy gain was within CI noise but paid OM ingest cost.
|
|
24
24
|
*
|
|
25
|
+
* **Augmented routing (2026-04-26):** The {@link AugmentedRoutingTable}
|
|
26
|
+
* extends the basic dispatch contract with an orthogonal axis — a
|
|
27
|
+
* per-category {@link RetrievalConfigId} pick — so the router can
|
|
28
|
+
* dispatch on (backend × retrieval-config) rather than backend alone.
|
|
29
|
+
* The {@link MINIMIZE_COST_AUGMENTED_TABLE} preset is calibrated from
|
|
30
|
+
* the LongMemEval-M Phase A N=54 ablation matrix (2026-04-26).
|
|
31
|
+
*
|
|
25
32
|
* @module @framers/agentos/memory-router/routing-tables
|
|
26
33
|
*/
|
|
34
|
+
import type { RetrievalConfigId } from './retrieval-config.js';
|
|
27
35
|
/**
|
|
28
36
|
* The six question categories the LLM-as-judge classifier produces.
|
|
29
37
|
* Calibrated from LongMemEval-S categories; mappings to other benchmark
|
|
@@ -122,4 +130,108 @@ export declare const MAXIMIZE_ACCURACY_TABLE: RoutingTable;
|
|
|
122
130
|
* the preset name is a string and the consumer needs the table object.
|
|
123
131
|
*/
|
|
124
132
|
export declare const PRESET_TABLES: Readonly<Record<MemoryRouterPreset, RoutingTable>>;
|
|
133
|
+
/**
|
|
134
|
+
* The cheapest-and-safest {@link MemoryBackendId} the router can ever
|
|
135
|
+
* pick. Used by {@link SAFE_FALLBACK_DISPATCH_KEY} when an augmented
|
|
136
|
+
* lookup misses (e.g. the predicted category is not in the table or
|
|
137
|
+
* the table is malformed). Matches the existing behavior of
|
|
138
|
+
* {@link MINIMIZE_COST_TABLE} for unknown categories: degrade to the
|
|
139
|
+
* cheap path rather than the OM-premium path.
|
|
140
|
+
*/
|
|
141
|
+
export declare const SAFE_FALLBACK_BACKEND: MemoryBackendId;
|
|
142
|
+
/**
|
|
143
|
+
* Composite dispatch key that the augmented router emits per query.
|
|
144
|
+
* Carries both the recall-backend axis (existing
|
|
145
|
+
* {@link MemoryBackendId}) and the retrieval-config axis (new
|
|
146
|
+
* {@link RetrievalConfigId}). Wider than the legacy single-axis key
|
|
147
|
+
* but the legacy key is recoverable via the `backend` field.
|
|
148
|
+
*
|
|
149
|
+
* **Backwards compatibility,** consumers using only the existing
|
|
150
|
+
* routing tables continue to dispatch on `MemoryBackendId` alone;
|
|
151
|
+
* the augmented router maps each augmented key to the same backend
|
|
152
|
+
* with `retrievalConfig: 'canonical'` implicitly when the consumer
|
|
153
|
+
* has not opted into augmented dispatch.
|
|
154
|
+
*/
|
|
155
|
+
export interface MemoryDispatchKey {
|
|
156
|
+
readonly backend: MemoryBackendId;
|
|
157
|
+
readonly retrievalConfig: RetrievalConfigId;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Default {@link MemoryDispatchKey} used when an augmented lookup
|
|
161
|
+
* misses. Matches the cheap-and-safe path: canonical-hybrid backend
|
|
162
|
+
* with the canonical retrieval config (no HyDE, default rerank,
|
|
163
|
+
* default reader top-K).
|
|
164
|
+
*
|
|
165
|
+
* Frozen at module load.
|
|
166
|
+
*/
|
|
167
|
+
export declare const SAFE_FALLBACK_DISPATCH_KEY: MemoryDispatchKey;
|
|
168
|
+
/**
|
|
169
|
+
* The augmented preset names. v2 (2026-04-26) ships only the
|
|
170
|
+
* `minimize-cost-augmented` preset; the other two preset names are
|
|
171
|
+
* reserved for v3 calibration alongside Stage E.
|
|
172
|
+
*/
|
|
173
|
+
export type AugmentedMemoryRouterPreset = 'minimize-cost-augmented' | 'balanced-augmented' | 'maximize-accuracy-augmented';
|
|
174
|
+
/**
|
|
175
|
+
* An augmented routing table maps every {@link MemoryQueryCategory}
|
|
176
|
+
* to a {@link MemoryDispatchKey} (backend × retrieval-config). The
|
|
177
|
+
* shape is parallel to {@link RoutingTable} but every value is a
|
|
178
|
+
* composite key rather than a backend id.
|
|
179
|
+
*
|
|
180
|
+
* Tables ship frozen so consumers cannot mutate the routing surface
|
|
181
|
+
* from outside the module.
|
|
182
|
+
*/
|
|
183
|
+
export interface AugmentedRoutingTable {
|
|
184
|
+
readonly preset: AugmentedMemoryRouterPreset;
|
|
185
|
+
readonly defaultMapping: Readonly<Record<MemoryQueryCategory, MemoryDispatchKey>>;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Preset: minimize-cost-augmented (2026-04-26 v2).
|
|
189
|
+
*
|
|
190
|
+
* Combines two calibrations into one dispatch table:
|
|
191
|
+
*
|
|
192
|
+
* - **Backend axis** from the LongMemEval-S Phase B N=500
|
|
193
|
+
* {@link MINIMIZE_COST_TABLE}: SSP and MS pay the OM-v11 premium
|
|
194
|
+
* (architectural lift earns it); every other category routes to
|
|
195
|
+
* canonical-hybrid (cheapest Pareto-dominant).
|
|
196
|
+
* - **Retrieval-config axis** from the LongMemEval-M Phase A N=54
|
|
197
|
+
* ablation matrix (per-category-oracle picks): SSA + SSU + MS use
|
|
198
|
+
* the full combined `hyde-topk50-mult5`; KU uses `topk50` (top-K
|
|
199
|
+
* alone is sufficient and cheaper); TR + SSP use `hyde` alone (the
|
|
200
|
+
* wider rerank pool actively hurts these categories).
|
|
201
|
+
*
|
|
202
|
+
* The 2026-04-26 forecasted aggregate at this dispatch table on
|
|
203
|
+
* LongMemEval-M is **68.5%** (per-category-oracle empirical from the
|
|
204
|
+
* ablation matrix), vs **57.4%** static M-tuned (`hyde-topk50-mult5`
|
|
205
|
+
* everywhere) and **30.6%** baseline (`canonical` everywhere).
|
|
206
|
+
* Phase A validation at this preset is the next gate (see
|
|
207
|
+
* `2026-04-26-retrieval-config-router-productionization-plan.md`).
|
|
208
|
+
*
|
|
209
|
+
* **Calibration validity,** N=54 single-seed Phase A on M plus N=500
|
|
210
|
+
* Phase B on S. Phase B at full N=500 on M will tighten per-category
|
|
211
|
+
* confidence intervals; the table here is the directional best-guess
|
|
212
|
+
* for v2 and SHOULD be re-derived from any future Phase B run.
|
|
213
|
+
*/
|
|
214
|
+
export declare const MINIMIZE_COST_AUGMENTED_TABLE: AugmentedRoutingTable;
|
|
215
|
+
/**
|
|
216
|
+
* Convenience registry of augmented preset tables, keyed by preset
|
|
217
|
+
* name. v2 ships only `minimize-cost-augmented`; the other two
|
|
218
|
+
* preset names will be wired in v3 alongside Stage E.
|
|
219
|
+
*/
|
|
220
|
+
export declare const AUGMENTED_PRESET_TABLES: Readonly<Partial<Record<AugmentedMemoryRouterPreset, AugmentedRoutingTable>>>;
|
|
221
|
+
/**
|
|
222
|
+
* Pure-function selector: given a category and an
|
|
223
|
+
* {@link AugmentedRoutingTable}, return the calibrated
|
|
224
|
+
* {@link MemoryDispatchKey}. Falls back to
|
|
225
|
+
* {@link SAFE_FALLBACK_DISPATCH_KEY} when the table is missing the
|
|
226
|
+
* category (a defensive guard for custom-table misuse; the shipping
|
|
227
|
+
* presets cover every category).
|
|
228
|
+
*
|
|
229
|
+
* Stateless. Deterministic. No I/O. Suitable for use inside
|
|
230
|
+
* cache-key construction and hot dispatch loops.
|
|
231
|
+
*
|
|
232
|
+
* @param category - The classifier-predicted query category.
|
|
233
|
+
* @param table - The augmented routing table to consult.
|
|
234
|
+
* @returns A frozen {@link MemoryDispatchKey} for the category.
|
|
235
|
+
*/
|
|
236
|
+
export declare function selectAugmentedDispatch(category: MemoryQueryCategory, table: AugmentedRoutingTable): MemoryDispatchKey;
|
|
125
237
|
//# sourceMappingURL=routing-tables.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routing-tables.d.ts","sourceRoot":"","sources":["../../src/memory-router/routing-tables.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"routing-tables.d.ts","sourceRoot":"","sources":["../../src/memory-router/routing-tables.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAM/D;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,sJAO1B,CAAC;AAEX;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,CAAC,OAAO,uBAAuB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE3E;;;;;;;;;;;;;;;GAeG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F;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,6BAA6B,EAAE,qBA4BjB,CAAC;AAE5B;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,EAAE,QAAQ,CAC5C,OAAO,CAAC,MAAM,CAAC,2BAA2B,EAAE,qBAAqB,CAAC,CAAC,CAGnE,CAAC;AAEH;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,mBAAmB,EAC7B,KAAK,EAAE,qBAAqB,GAC3B,iBAAiB,CAEnB"}
|
|
@@ -22,6 +22,13 @@
|
|
|
22
22
|
* temporal-reasoning back to canonical-hybrid after Phase B revealed the
|
|
23
23
|
* v1 routing's accuracy gain was within CI noise but paid OM ingest cost.
|
|
24
24
|
*
|
|
25
|
+
* **Augmented routing (2026-04-26):** The {@link AugmentedRoutingTable}
|
|
26
|
+
* extends the basic dispatch contract with an orthogonal axis — a
|
|
27
|
+
* per-category {@link RetrievalConfigId} pick — so the router can
|
|
28
|
+
* dispatch on (backend × retrieval-config) rather than backend alone.
|
|
29
|
+
* The {@link MINIMIZE_COST_AUGMENTED_TABLE} preset is calibrated from
|
|
30
|
+
* the LongMemEval-M Phase A N=54 ablation matrix (2026-04-26).
|
|
31
|
+
*
|
|
25
32
|
* @module @framers/agentos/memory-router/routing-tables
|
|
26
33
|
*/
|
|
27
34
|
// ============================================================================
|
|
@@ -134,4 +141,110 @@ export const PRESET_TABLES = Object.freeze({
|
|
|
134
141
|
'balanced': BALANCED_TABLE,
|
|
135
142
|
'maximize-accuracy': MAXIMIZE_ACCURACY_TABLE,
|
|
136
143
|
});
|
|
144
|
+
// ============================================================================
|
|
145
|
+
// Augmented routing: (backend × retrieval-config) dispatch
|
|
146
|
+
// ============================================================================
|
|
147
|
+
/**
|
|
148
|
+
* The cheapest-and-safest {@link MemoryBackendId} the router can ever
|
|
149
|
+
* pick. Used by {@link SAFE_FALLBACK_DISPATCH_KEY} when an augmented
|
|
150
|
+
* lookup misses (e.g. the predicted category is not in the table or
|
|
151
|
+
* the table is malformed). Matches the existing behavior of
|
|
152
|
+
* {@link MINIMIZE_COST_TABLE} for unknown categories: degrade to the
|
|
153
|
+
* cheap path rather than the OM-premium path.
|
|
154
|
+
*/
|
|
155
|
+
export const SAFE_FALLBACK_BACKEND = 'canonical-hybrid';
|
|
156
|
+
/**
|
|
157
|
+
* Default {@link MemoryDispatchKey} used when an augmented lookup
|
|
158
|
+
* misses. Matches the cheap-and-safe path: canonical-hybrid backend
|
|
159
|
+
* with the canonical retrieval config (no HyDE, default rerank,
|
|
160
|
+
* default reader top-K).
|
|
161
|
+
*
|
|
162
|
+
* Frozen at module load.
|
|
163
|
+
*/
|
|
164
|
+
export const SAFE_FALLBACK_DISPATCH_KEY = Object.freeze({
|
|
165
|
+
backend: SAFE_FALLBACK_BACKEND,
|
|
166
|
+
retrievalConfig: 'canonical',
|
|
167
|
+
});
|
|
168
|
+
/**
|
|
169
|
+
* Preset: minimize-cost-augmented (2026-04-26 v2).
|
|
170
|
+
*
|
|
171
|
+
* Combines two calibrations into one dispatch table:
|
|
172
|
+
*
|
|
173
|
+
* - **Backend axis** from the LongMemEval-S Phase B N=500
|
|
174
|
+
* {@link MINIMIZE_COST_TABLE}: SSP and MS pay the OM-v11 premium
|
|
175
|
+
* (architectural lift earns it); every other category routes to
|
|
176
|
+
* canonical-hybrid (cheapest Pareto-dominant).
|
|
177
|
+
* - **Retrieval-config axis** from the LongMemEval-M Phase A N=54
|
|
178
|
+
* ablation matrix (per-category-oracle picks): SSA + SSU + MS use
|
|
179
|
+
* the full combined `hyde-topk50-mult5`; KU uses `topk50` (top-K
|
|
180
|
+
* alone is sufficient and cheaper); TR + SSP use `hyde` alone (the
|
|
181
|
+
* wider rerank pool actively hurts these categories).
|
|
182
|
+
*
|
|
183
|
+
* The 2026-04-26 forecasted aggregate at this dispatch table on
|
|
184
|
+
* LongMemEval-M is **68.5%** (per-category-oracle empirical from the
|
|
185
|
+
* ablation matrix), vs **57.4%** static M-tuned (`hyde-topk50-mult5`
|
|
186
|
+
* everywhere) and **30.6%** baseline (`canonical` everywhere).
|
|
187
|
+
* Phase A validation at this preset is the next gate (see
|
|
188
|
+
* `2026-04-26-retrieval-config-router-productionization-plan.md`).
|
|
189
|
+
*
|
|
190
|
+
* **Calibration validity,** N=54 single-seed Phase A on M plus N=500
|
|
191
|
+
* Phase B on S. Phase B at full N=500 on M will tighten per-category
|
|
192
|
+
* confidence intervals; the table here is the directional best-guess
|
|
193
|
+
* for v2 and SHOULD be re-derived from any future Phase B run.
|
|
194
|
+
*/
|
|
195
|
+
export const MINIMIZE_COST_AUGMENTED_TABLE = Object.freeze({
|
|
196
|
+
preset: 'minimize-cost-augmented',
|
|
197
|
+
defaultMapping: Object.freeze({
|
|
198
|
+
'single-session-assistant': Object.freeze({
|
|
199
|
+
backend: 'canonical-hybrid',
|
|
200
|
+
retrievalConfig: 'hyde-topk50-mult5',
|
|
201
|
+
}),
|
|
202
|
+
'single-session-user': Object.freeze({
|
|
203
|
+
backend: 'canonical-hybrid',
|
|
204
|
+
retrievalConfig: 'hyde-topk50-mult5',
|
|
205
|
+
}),
|
|
206
|
+
'single-session-preference': Object.freeze({
|
|
207
|
+
backend: 'observational-memory-v11',
|
|
208
|
+
retrievalConfig: 'hyde',
|
|
209
|
+
}),
|
|
210
|
+
'knowledge-update': Object.freeze({
|
|
211
|
+
backend: 'canonical-hybrid',
|
|
212
|
+
retrievalConfig: 'topk50',
|
|
213
|
+
}),
|
|
214
|
+
'multi-session': Object.freeze({
|
|
215
|
+
backend: 'observational-memory-v11',
|
|
216
|
+
retrievalConfig: 'hyde-topk50-mult5',
|
|
217
|
+
}),
|
|
218
|
+
'temporal-reasoning': Object.freeze({
|
|
219
|
+
backend: 'canonical-hybrid',
|
|
220
|
+
retrievalConfig: 'hyde',
|
|
221
|
+
}),
|
|
222
|
+
}),
|
|
223
|
+
});
|
|
224
|
+
/**
|
|
225
|
+
* Convenience registry of augmented preset tables, keyed by preset
|
|
226
|
+
* name. v2 ships only `minimize-cost-augmented`; the other two
|
|
227
|
+
* preset names will be wired in v3 alongside Stage E.
|
|
228
|
+
*/
|
|
229
|
+
export const AUGMENTED_PRESET_TABLES = Object.freeze({
|
|
230
|
+
'minimize-cost-augmented': MINIMIZE_COST_AUGMENTED_TABLE,
|
|
231
|
+
});
|
|
232
|
+
/**
|
|
233
|
+
* Pure-function selector: given a category and an
|
|
234
|
+
* {@link AugmentedRoutingTable}, return the calibrated
|
|
235
|
+
* {@link MemoryDispatchKey}. Falls back to
|
|
236
|
+
* {@link SAFE_FALLBACK_DISPATCH_KEY} when the table is missing the
|
|
237
|
+
* category (a defensive guard for custom-table misuse; the shipping
|
|
238
|
+
* presets cover every category).
|
|
239
|
+
*
|
|
240
|
+
* Stateless. Deterministic. No I/O. Suitable for use inside
|
|
241
|
+
* cache-key construction and hot dispatch loops.
|
|
242
|
+
*
|
|
243
|
+
* @param category - The classifier-predicted query category.
|
|
244
|
+
* @param table - The augmented routing table to consult.
|
|
245
|
+
* @returns A frozen {@link MemoryDispatchKey} for the category.
|
|
246
|
+
*/
|
|
247
|
+
export function selectAugmentedDispatch(category, table) {
|
|
248
|
+
return table.defaultMapping[category] ?? SAFE_FALLBACK_DISPATCH_KEY;
|
|
249
|
+
}
|
|
137
250
|
//# sourceMappingURL=routing-tables.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routing-tables.js","sourceRoot":"","sources":["../../src/memory-router/routing-tables.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"routing-tables.js","sourceRoot":"","sources":["../../src/memory-router/routing-tables.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAIH,+EAA+E;AAC/E,eAAe;AACf,+EAA+E;AAE/E;;;;;GAKG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,qBAAqB;IACrB,0BAA0B;IAC1B,2BA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