agent-nuvira 3.5.0 → 3.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -13
- package/dist/agent-sdk/src/scaffold.d.ts +1 -1
- package/dist/agent-sdk/src/scaffold.js +1 -1
- package/dist/cli/chat.d.ts +117 -6
- package/dist/cli/chat.d.ts.map +1 -1
- package/dist/cli/chat.js +344 -20
- package/dist/cli/chat.js.map +1 -1
- package/dist/cli/duties.d.ts +11 -0
- package/dist/cli/duties.d.ts.map +1 -1
- package/dist/cli/duties.js +31 -0
- package/dist/cli/duties.js.map +1 -1
- package/dist/cli/models.d.ts.map +1 -1
- package/dist/cli/models.js +55 -0
- package/dist/cli/models.js.map +1 -1
- package/dist/learning/auto-router.d.ts +28 -0
- package/dist/learning/auto-router.d.ts.map +1 -1
- package/dist/learning/auto-router.js +84 -5
- package/dist/learning/auto-router.js.map +1 -1
- package/dist/learning/duty-lease.d.ts +163 -0
- package/dist/learning/duty-lease.d.ts.map +1 -0
- package/dist/learning/duty-lease.js +301 -0
- package/dist/learning/duty-lease.js.map +1 -0
- package/dist/learning/model-first-router.d.ts +14 -0
- package/dist/learning/model-first-router.d.ts.map +1 -1
- package/dist/learning/model-first-router.js +54 -17
- package/dist/learning/model-first-router.js.map +1 -1
- package/dist/learning/model-warmup.d.ts +92 -0
- package/dist/learning/model-warmup.d.ts.map +1 -1
- package/dist/learning/model-warmup.js +137 -2
- package/dist/learning/model-warmup.js.map +1 -1
- package/dist/learning/retry-patience.d.ts +139 -0
- package/dist/learning/retry-patience.d.ts.map +1 -0
- package/dist/learning/retry-patience.js +169 -0
- package/dist/learning/retry-patience.js.map +1 -0
- package/dist/tools/tool-loop.d.ts +41 -3
- package/dist/tools/tool-loop.d.ts.map +1 -1
- package/dist/tools/tool-loop.js +260 -4
- package/dist/tools/tool-loop.js.map +1 -1
- package/package.json +4 -1
- package/src/web-dashboard/public/assets/{index-yky0dw5e.js → index-Bik91KJh.js} +2 -2
- package/src/web-dashboard/public/assets/{index-yky0dw5e.js.map → index-Bik91KJh.js.map} +1 -1
- package/src/web-dashboard/public/index.html +1 -1
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
* stopWarmupDaemon();
|
|
26
26
|
*/
|
|
27
27
|
import { getModelRegistry } from './model-registry.js';
|
|
28
|
+
import { type DutyLeaseInfo } from './duty-lease.js';
|
|
28
29
|
import type { ConfigManager } from '../config/manager.js';
|
|
29
30
|
/**
|
|
30
31
|
* Every bound this module spends against a free tier, in one place and
|
|
@@ -52,6 +53,33 @@ export interface WarmupConfig {
|
|
|
52
53
|
hotWindowMs: number;
|
|
53
54
|
/** Models used within this window are "warm" (ms). */
|
|
54
55
|
warmWindowMs: number;
|
|
56
|
+
/**
|
|
57
|
+
* Max VERIFIED, in-pool models re-spot-checked per cycle to keep the pool
|
|
58
|
+
* FRESH. Separate from `hotPerCycle` because the two halves spend on
|
|
59
|
+
* different things: `hotPerCycle` keeps in-use models warm, this one stops
|
|
60
|
+
* the routable pool from ageing out.
|
|
61
|
+
*/
|
|
62
|
+
poolRefreshPerCycle: number;
|
|
63
|
+
/**
|
|
64
|
+
* How long a VERIFIED model may go without re-verification (ms).
|
|
65
|
+
*
|
|
66
|
+
* WHY HOURS, NOT THE 7-DAY RULE. The registry retires a model nothing
|
|
67
|
+
* re-verifies, and NOTHING was re-verifying a verified one: the exploration
|
|
68
|
+
* half selects `status === 'unverified'` rows only, so a model that had been
|
|
69
|
+
* verified once could only age — the measured pool showed verified entries at
|
|
70
|
+
* 142.8h and shrinking, while routing kept serving from a pool that was
|
|
71
|
+
* quietly expiring. Freshness IS a routing input (health ranking reads
|
|
72
|
+
* `lastVerifiedAt`, latency and errorRate), so a stale pool is a routing
|
|
73
|
+
* signal that stops describing reality.
|
|
74
|
+
*
|
|
75
|
+
* WHY THIS STAYS BOUNDED. Only VERIFIED rows are eligible (the pool the
|
|
76
|
+
* router would actually serve — never the hundreds of catalog entries), only
|
|
77
|
+
* `poolRefreshPerCycle` of them per cycle, parked rows are skipped (a park is
|
|
78
|
+
* a rest, not staleness), and a 1-token spot-check per model every 12h is a
|
|
79
|
+
* few hundred tokens a day for a pool of ~12 — not a catalog-wide sweep,
|
|
80
|
+
* which on free tiers is where RPM/TPM limits would turn warmup into 429s.
|
|
81
|
+
*/
|
|
82
|
+
poolStalenessMs: number;
|
|
55
83
|
}
|
|
56
84
|
/**
|
|
57
85
|
* Resolve the sweep's bounds (env overrides → defaults).
|
|
@@ -86,6 +114,8 @@ export interface WarmupCycleResult {
|
|
|
86
114
|
warmed: number;
|
|
87
115
|
/** NEVER-VERIFIED models spot-checked to grow the routing pool. */
|
|
88
116
|
explored: number;
|
|
117
|
+
/** STALE, verified in-pool models re-spot-checked to keep the pool fresh. */
|
|
118
|
+
poolRefreshed: number;
|
|
89
119
|
/** Spot-checks of either kind that came back `verified`. */
|
|
90
120
|
verified: number;
|
|
91
121
|
/** Hot candidates the per-cycle cap left for the next cycle. */
|
|
@@ -96,6 +126,18 @@ export interface WarmupCycleResult {
|
|
|
96
126
|
* did noticeably more network work than its neighbours.
|
|
97
127
|
*/
|
|
98
128
|
catalogRefreshed: boolean;
|
|
129
|
+
/**
|
|
130
|
+
* False when a cycle was REFUSED because another process holds the warmup
|
|
131
|
+
* duty lease (see `duty-lease.ts`) — every other counter is zero then.
|
|
132
|
+
*
|
|
133
|
+
* Reported rather than silent because it is the one outcome that looks
|
|
134
|
+
* identical to "there was nothing to do", and the two call for opposite
|
|
135
|
+
* responses: one is good news, the other means this process will never do the
|
|
136
|
+
* sweep on its own.
|
|
137
|
+
*/
|
|
138
|
+
ran: boolean;
|
|
139
|
+
/** Who held the lease, when `ran` is false. Diagnostics only. */
|
|
140
|
+
leaseHeldBy?: DutyLeaseInfo;
|
|
99
141
|
}
|
|
100
142
|
/** Injectable seams for tests — the real spot-check talks to a provider. */
|
|
101
143
|
export interface WarmupDeps {
|
|
@@ -123,6 +165,29 @@ export interface WarmupDeps {
|
|
|
123
165
|
* spend its whole budget on something that cannot answer.
|
|
124
166
|
*/
|
|
125
167
|
export declare function selectExplorationCandidates(registry: ReturnType<typeof getModelRegistry>, configManager: ConfigManager, now: number, limit: number): WarmupCandidate[];
|
|
168
|
+
/**
|
|
169
|
+
* Pick VERIFIED, in-pool models that have gone STALE, oldest verification
|
|
170
|
+
* first.
|
|
171
|
+
*
|
|
172
|
+
* This is the half the module was missing: exploration (`status ===
|
|
173
|
+
* 'unverified'`) grows the pool, hot records keep THIS process's models warm,
|
|
174
|
+
* and nothing refreshed a verified model that stopped being used — so a pool
|
|
175
|
+
* model aged toward the registry's 7-day retirement and, because the health
|
|
176
|
+
* ranking reads `lastVerifiedAt`, routing kept ranking it on evidence that was
|
|
177
|
+
* no longer true.
|
|
178
|
+
*
|
|
179
|
+
* Deliberately narrow:
|
|
180
|
+
* - VERIFIED rows only. An `unverified` row belongs to exploration, and an
|
|
181
|
+
* `unavailable` one is not stale — it is broken, and re-probing it is
|
|
182
|
+
* exploration's job once it is re-listed.
|
|
183
|
+
* - Unservable providers are excluded, so a cycle never spends its budget on
|
|
184
|
+
* a provider with no credentials.
|
|
185
|
+
* - Quota-parked rows are skipped: a park is a rest with a known end, and
|
|
186
|
+
* re-probing it would be exactly the extra traffic the park prevents.
|
|
187
|
+
* - The exploration throttle still applies per model, so this can never
|
|
188
|
+
* re-probe the same model twice in one `exploreThrottleMs` window.
|
|
189
|
+
*/
|
|
190
|
+
export declare function selectPoolRefreshCandidates(registry: ReturnType<typeof getModelRegistry>, configManager: ConfigManager, now: number, limit: number): WarmupCandidate[];
|
|
126
191
|
/**
|
|
127
192
|
* Run one warmup cycle: keep hot models warm, and grow the verified pool.
|
|
128
193
|
*
|
|
@@ -132,6 +197,33 @@ export declare function selectExplorationCandidates(registry: ReturnType<typeof
|
|
|
132
197
|
* a fresh process (the old `if (records.length === 0) return;` made the first
|
|
133
198
|
* cycle of every short-lived CLI run a no-op).
|
|
134
199
|
*/
|
|
200
|
+
/** The duty name every warmup caller contends on — one lease per machine. */
|
|
201
|
+
export declare const WARMUP_DUTY_LEASE = "model-warmup";
|
|
202
|
+
/**
|
|
203
|
+
* How long an un-renewed warmup lease may live before another process may steal
|
|
204
|
+
* it (ms).
|
|
205
|
+
*
|
|
206
|
+
* A live cycle re-news at half this window (see the loop below), so this is
|
|
207
|
+
* purely the CRASH-RECOVERY delay: how long a dead holder can keep the sweep
|
|
208
|
+
* switched off. It is also the floor under the interval — a lease that expired
|
|
209
|
+
* inside one cycle would let two processes sweep at once.
|
|
210
|
+
*/
|
|
211
|
+
export declare function warmupLeaseStaleMs(env?: NodeJS.ProcessEnv): number;
|
|
212
|
+
/**
|
|
213
|
+
* Run one warmup cycle UNDER the warmup duty lease, or refuse and say who holds
|
|
214
|
+
* it.
|
|
215
|
+
*
|
|
216
|
+
* WHY THE LEASE LIVES HERE AND NOT IN THE CALLERS. Every caller wants the same
|
|
217
|
+
* thing — "one sweep at a time" — and there are four of them (the daemon timer,
|
|
218
|
+
* the first-cycle kick at startup, `nuvira models warm`, and any future
|
|
219
|
+
* dashboard trigger). Putting the guard in each one means the fifth caller, or a
|
|
220
|
+
* refactor, silently re-introduces the waste. Putting it here means the sweep
|
|
221
|
+
* cannot be started un-leased at all.
|
|
222
|
+
*
|
|
223
|
+
* The work a cycle does is a real generation per candidate, on the user's free
|
|
224
|
+
* tier — which is why two processes sweeping the same candidate list is not
|
|
225
|
+
* merely redundant, it is the exact traffic that turns warmup into 429s.
|
|
226
|
+
*/
|
|
135
227
|
export declare function runWarmupCycle(configManager: ConfigManager, deps?: WarmupDeps): Promise<WarmupCycleResult>;
|
|
136
228
|
/**
|
|
137
229
|
* Get warmup statistics (for dashboard display).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-warmup.d.ts","sourceRoot":"","sources":["../../src/learning/model-warmup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,gBAAgB,EAA2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,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,GACZ,eAAe,EAAE,CA2BnB;AAED;;;;;;;;GAQG;AACH,6EAA6E;AAC7E,eAAO,MAAM,iBAAiB,iBAAiB,CAAC;AAEhD;;;;;;;;GAQG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,MAAM,CAE/E;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,cAAc,CAClC,aAAa,EAAE,aAAa,EAC5B,IAAI,GAAE,UAAe,GACpB,OAAO,CAAC,iBAAiB,CAAC,CAyB5B;AAuHD;;GAEG;AACH,wBAAgB,cAAc,IAAI;IAChC,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;CACrB,CAoBA;AAED;;GAEG;AACH,wBAAgB,gBAAgB,IAAI,KAAK,CAAC;IACxC,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,MAAM,CAAC;CACjC,CAAC,CAiBD"}
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
import { getModelRegistry } from './model-registry.js';
|
|
28
28
|
import { spotCheckModel, refreshModelRegistry } from '../inference/model-probe.js';
|
|
29
29
|
import { detectCredentialChange } from './credential-fingerprint.js';
|
|
30
|
+
import { acquireDutyLease, releaseDutyLease, renewDutyLease, dutyLeaseStaleMs, } from './duty-lease.js';
|
|
30
31
|
import { ProviderFactory } from '../inference/factory.js';
|
|
31
32
|
import { logger } from '../utils/logger.js';
|
|
32
33
|
/** Parse a positive-integer env override; anything else falls back. */
|
|
@@ -51,6 +52,11 @@ export function warmupConfig(env = process.env) {
|
|
|
51
52
|
exploreThrottleMs: positiveInt(env.NUVIRA_WARMUP_EXPLORE_THROTTLE_MS, 600_000),
|
|
52
53
|
hotWindowMs: positiveInt(env.NUVIRA_WARMUP_HOT_WINDOW_MS, 30_600_000),
|
|
53
54
|
warmWindowMs: positiveInt(env.NUVIRA_WARMUP_WARM_WINDOW_MS, 86_400_000),
|
|
55
|
+
poolRefreshPerCycle: positiveInt(env.NUVIRA_WARMUP_POOL_PER_CYCLE, 4),
|
|
56
|
+
// 12 hours: a verified model is re-probed twice a day, so a provider that
|
|
57
|
+
// silently stopped serving one is noticed within a working session rather
|
|
58
|
+
// than at the 7-day retirement.
|
|
59
|
+
poolStalenessMs: positiveInt(env.NUVIRA_WARMUP_POOL_STALENESS_MS, 43_200_000),
|
|
54
60
|
};
|
|
55
61
|
}
|
|
56
62
|
/** In-memory usage tracker (persisted to registry via telemetry). */
|
|
@@ -204,6 +210,58 @@ export function selectExplorationCandidates(registry, configManager, now, limit)
|
|
|
204
210
|
a.model.localeCompare(b.model));
|
|
205
211
|
return rows.slice(0, limit).map(({ provider, model, priority }) => ({ provider, model, priority }));
|
|
206
212
|
}
|
|
213
|
+
/**
|
|
214
|
+
* Pick VERIFIED, in-pool models that have gone STALE, oldest verification
|
|
215
|
+
* first.
|
|
216
|
+
*
|
|
217
|
+
* This is the half the module was missing: exploration (`status ===
|
|
218
|
+
* 'unverified'`) grows the pool, hot records keep THIS process's models warm,
|
|
219
|
+
* and nothing refreshed a verified model that stopped being used — so a pool
|
|
220
|
+
* model aged toward the registry's 7-day retirement and, because the health
|
|
221
|
+
* ranking reads `lastVerifiedAt`, routing kept ranking it on evidence that was
|
|
222
|
+
* no longer true.
|
|
223
|
+
*
|
|
224
|
+
* Deliberately narrow:
|
|
225
|
+
* - VERIFIED rows only. An `unverified` row belongs to exploration, and an
|
|
226
|
+
* `unavailable` one is not stale — it is broken, and re-probing it is
|
|
227
|
+
* exploration's job once it is re-listed.
|
|
228
|
+
* - Unservable providers are excluded, so a cycle never spends its budget on
|
|
229
|
+
* a provider with no credentials.
|
|
230
|
+
* - Quota-parked rows are skipped: a park is a rest with a known end, and
|
|
231
|
+
* re-probing it would be exactly the extra traffic the park prevents.
|
|
232
|
+
* - The exploration throttle still applies per model, so this can never
|
|
233
|
+
* re-probe the same model twice in one `exploreThrottleMs` window.
|
|
234
|
+
*/
|
|
235
|
+
export function selectPoolRefreshCandidates(registry, configManager, now, limit) {
|
|
236
|
+
if (limit <= 0)
|
|
237
|
+
return [];
|
|
238
|
+
const cfg = warmupConfig();
|
|
239
|
+
const rows = [];
|
|
240
|
+
for (const provider of registry.getTrackedProviders()) {
|
|
241
|
+
if (!isServable(provider, configManager))
|
|
242
|
+
continue;
|
|
243
|
+
for (const entry of registry.getAllModelsForProvider(provider)) {
|
|
244
|
+
if (entry.status !== 'verified')
|
|
245
|
+
continue;
|
|
246
|
+
if (!entry.model || entry.model === 'default')
|
|
247
|
+
continue;
|
|
248
|
+
if (entry.quotaParkedUntil > now)
|
|
249
|
+
continue;
|
|
250
|
+
if (now - (entry.lastProbedAt ?? 0) < cfg.exploreThrottleMs)
|
|
251
|
+
continue;
|
|
252
|
+
const lastVerifiedAt = entry.lastVerifiedAt ?? 0;
|
|
253
|
+
if (now - lastVerifiedAt < cfg.poolStalenessMs)
|
|
254
|
+
continue;
|
|
255
|
+
rows.push({ provider, model: entry.model, priority: 0, lastVerifiedAt });
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
// Oldest verification first: the most-stale model is the one whose routing
|
|
259
|
+
// evidence is furthest from reality.
|
|
260
|
+
rows.sort((a, b) => a.lastVerifiedAt - b.lastVerifiedAt ||
|
|
261
|
+
a.provider.localeCompare(b.provider) ||
|
|
262
|
+
a.model.localeCompare(b.model));
|
|
263
|
+
return rows.slice(0, limit).map(({ provider, model, priority }) => ({ provider, model, priority }));
|
|
264
|
+
}
|
|
207
265
|
/**
|
|
208
266
|
* Run one warmup cycle: keep hot models warm, and grow the verified pool.
|
|
209
267
|
*
|
|
@@ -213,7 +271,62 @@ export function selectExplorationCandidates(registry, configManager, now, limit)
|
|
|
213
271
|
* a fresh process (the old `if (records.length === 0) return;` made the first
|
|
214
272
|
* cycle of every short-lived CLI run a no-op).
|
|
215
273
|
*/
|
|
274
|
+
/** The duty name every warmup caller contends on — one lease per machine. */
|
|
275
|
+
export const WARMUP_DUTY_LEASE = 'model-warmup';
|
|
276
|
+
/**
|
|
277
|
+
* How long an un-renewed warmup lease may live before another process may steal
|
|
278
|
+
* it (ms).
|
|
279
|
+
*
|
|
280
|
+
* A live cycle re-news at half this window (see the loop below), so this is
|
|
281
|
+
* purely the CRASH-RECOVERY delay: how long a dead holder can keep the sweep
|
|
282
|
+
* switched off. It is also the floor under the interval — a lease that expired
|
|
283
|
+
* inside one cycle would let two processes sweep at once.
|
|
284
|
+
*/
|
|
285
|
+
export function warmupLeaseStaleMs(env = process.env) {
|
|
286
|
+
return Math.max(dutyLeaseStaleMs(env), warmupConfig(env).intervalMs * 2);
|
|
287
|
+
}
|
|
288
|
+
/**
|
|
289
|
+
* Run one warmup cycle UNDER the warmup duty lease, or refuse and say who holds
|
|
290
|
+
* it.
|
|
291
|
+
*
|
|
292
|
+
* WHY THE LEASE LIVES HERE AND NOT IN THE CALLERS. Every caller wants the same
|
|
293
|
+
* thing — "one sweep at a time" — and there are four of them (the daemon timer,
|
|
294
|
+
* the first-cycle kick at startup, `nuvira models warm`, and any future
|
|
295
|
+
* dashboard trigger). Putting the guard in each one means the fifth caller, or a
|
|
296
|
+
* refactor, silently re-introduces the waste. Putting it here means the sweep
|
|
297
|
+
* cannot be started un-leased at all.
|
|
298
|
+
*
|
|
299
|
+
* The work a cycle does is a real generation per candidate, on the user's free
|
|
300
|
+
* tier — which is why two processes sweeping the same candidate list is not
|
|
301
|
+
* merely redundant, it is the exact traffic that turns warmup into 429s.
|
|
302
|
+
*/
|
|
216
303
|
export async function runWarmupCycle(configManager, deps = {}) {
|
|
304
|
+
const staleMs = warmupLeaseStaleMs();
|
|
305
|
+
const taken = acquireDutyLease(WARMUP_DUTY_LEASE, { staleMs, purpose: 'model warmup sweep' });
|
|
306
|
+
if (!taken.owned) {
|
|
307
|
+
logger.debug(`[warmup] ${WARMUP_DUTY_LEASE} lease held by pid ${taken.holder?.pid ?? '?'} on ${taken.holder?.host ?? '?'} — skipping this cycle`);
|
|
308
|
+
return {
|
|
309
|
+
warmed: 0,
|
|
310
|
+
explored: 0,
|
|
311
|
+
poolRefreshed: 0,
|
|
312
|
+
verified: 0,
|
|
313
|
+
skipped: 0,
|
|
314
|
+
catalogRefreshed: false,
|
|
315
|
+
ran: false,
|
|
316
|
+
...(taken.holder ? { leaseHeldBy: taken.holder } : {}),
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
try {
|
|
320
|
+
return await runWarmupCycleBody(configManager, deps, { name: WARMUP_DUTY_LEASE, staleMs });
|
|
321
|
+
}
|
|
322
|
+
finally {
|
|
323
|
+
// Released even on a throw: a failing cycle must not switch the sweep off
|
|
324
|
+
// until the lease expires.
|
|
325
|
+
releaseDutyLease(WARMUP_DUTY_LEASE);
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
/** The cycle itself. Call it through {@link runWarmupCycle}, which leases it. */
|
|
329
|
+
async function runWarmupCycleBody(configManager, deps, lease) {
|
|
217
330
|
const registry = getModelRegistry();
|
|
218
331
|
const now = Date.now();
|
|
219
332
|
const cfg = warmupConfig();
|
|
@@ -221,9 +334,11 @@ export async function runWarmupCycle(configManager, deps = {}) {
|
|
|
221
334
|
const result = {
|
|
222
335
|
warmed: 0,
|
|
223
336
|
explored: 0,
|
|
337
|
+
poolRefreshed: 0,
|
|
224
338
|
verified: 0,
|
|
225
339
|
skipped: 0,
|
|
226
340
|
catalogRefreshed: false,
|
|
341
|
+
ran: true,
|
|
227
342
|
};
|
|
228
343
|
// ── Half 0: did the KEY SET change since the last run? ──────────────────
|
|
229
344
|
// The pool can only hold models a probe has verified, and there is no
|
|
@@ -263,12 +378,30 @@ export async function runWarmupCycle(configManager, deps = {}) {
|
|
|
263
378
|
result.skipped = hot.length - toWarm.length;
|
|
264
379
|
// ── Half 2: never-verified models (the pool the router cannot see) ──────
|
|
265
380
|
const exploration = selectExplorationCandidates(registry, configManager, now, cfg.explorePerCycle);
|
|
381
|
+
// ── Half 3: verified pool models that have gone STALE ──────────────────
|
|
382
|
+
// WITHOUT this half a verified model could only age: exploration looks at
|
|
383
|
+
// `unverified` rows, the hot half only knows THIS process's usage, and the
|
|
384
|
+
// registry retires what nothing re-verifies (7 days). Measured pool: verified
|
|
385
|
+
// entries at 142.8h and shrinking.
|
|
386
|
+
const stalePool = selectPoolRefreshCandidates(registry, configManager, now, cfg.poolRefreshPerCycle);
|
|
266
387
|
const exploreKeys = new Set(exploration.map((c) => usageKey(c.provider, c.model)));
|
|
267
|
-
const
|
|
388
|
+
const poolKeys = new Set(stalePool.map((c) => usageKey(c.provider, c.model)));
|
|
389
|
+
const cycle = [...toWarm, ...exploration, ...stalePool];
|
|
268
390
|
if (cycle.length === 0)
|
|
269
391
|
return result;
|
|
270
|
-
logger.debug(`[warmup] ${toWarm.length} hot · ${exploration.length} unverified candidates`);
|
|
392
|
+
logger.debug(`[warmup] ${toWarm.length} hot · ${exploration.length} unverified · ${stalePool.length} stale pool candidates`);
|
|
393
|
+
// Keep the lease alive across a long cycle. A cycle is up to
|
|
394
|
+
// `hotPerCycle + explorePerCycle + poolRefreshPerCycle` real generations, each
|
|
395
|
+
// bounded by the probe timeout, so it can outlive the stale window — and a
|
|
396
|
+
// lease that expired MID-cycle would invite a second process to start
|
|
397
|
+
// sweeping the same models, which is the waste the lease exists to stop.
|
|
398
|
+
const renewEveryMs = Math.max(1_000, Math.floor(lease.staleMs / 2));
|
|
399
|
+
let lastRenewAt = Date.now();
|
|
271
400
|
for (const candidate of cycle) {
|
|
401
|
+
if (Date.now() - lastRenewAt >= renewEveryMs) {
|
|
402
|
+
renewDutyLease(lease.name);
|
|
403
|
+
lastRenewAt = Date.now();
|
|
404
|
+
}
|
|
272
405
|
const key = usageKey(candidate.provider, candidate.model);
|
|
273
406
|
try {
|
|
274
407
|
const outcome = await spotCheck(candidate.provider, candidate.model, configManager);
|
|
@@ -276,6 +409,8 @@ export async function runWarmupCycle(configManager, deps = {}) {
|
|
|
276
409
|
result.verified += 1;
|
|
277
410
|
if (exploreKeys.has(key))
|
|
278
411
|
result.explored += 1;
|
|
412
|
+
else if (poolKeys.has(key))
|
|
413
|
+
result.poolRefreshed += 1;
|
|
279
414
|
else
|
|
280
415
|
result.warmed += 1;
|
|
281
416
|
if (outcome === 'verified') {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-warmup.js","sourceRoot":"","sources":["../../src/learning/model-warmup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,gBAAgB,EAA2B,MAAM,qBAAqB,CAAC;AAChF,OAAO,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AACnF,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAE1D,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAgC5C,uEAAuE;AACvE,SAAS,WAAW,CAAC,GAAuB,EAAE,QAAgB;IAC5D,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE;QAAE,OAAO,QAAQ,CAAC;IAC5D,MAAM,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IACtB,OAAO,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;AAChE,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,MAAyB,OAAO,CAAC,GAAG;IAC/D,OAAO;QACL,UAAU,EA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,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE;QAChD,MAAM,YAAY,GAAG,GAAG,GAAG,MAAM,CAAC,UAAU,CAAC;QAC7C,IAAI,MAAM,GAA4B,MAAM,CAAC;QAC7C,IAAI,YAAY,GAAG,GAAG,CAAC,WAAW;YAAE,MAAM,GAAG,KAAK,CAAC;aAC9C,IAAI,YAAY,GAAG,GAAG,CAAC,YAAY;YAAE,MAAM,GAAG,MAAM,CAAC;QAE1D,OAAO;YACL,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,UAAU,EAAE,MAAM,CAAC,UAAU;YAC7B,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,MAAM;SACP,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Blip patience — how long to STAY on the pair that just failed, and whether
|
|
3
|
+
* walking away is even a remedy.
|
|
4
|
+
*
|
|
5
|
+
* THE OBSERVED PROBLEM THIS ENCODES. A cloud provider does not go down for a
|
|
6
|
+
* turn: it returns 200, then a few empty/5xx responses for a handful of seconds,
|
|
7
|
+
* then serves normally again (measured repeatedly on `deepseek`). Two opposite
|
|
8
|
+
* mistakes are available, and the codebase has made both:
|
|
9
|
+
*
|
|
10
|
+
* - FAIL FAST: give up after seconds and fold onto the next candidate — which
|
|
11
|
+
* for that blip means silently dropping from a strong model to a weak one.
|
|
12
|
+
* The result is answered, badly, by a model the user did not choose.
|
|
13
|
+
* - WAIT BLINDLY: sit out a long fixed backoff on a pair that is actually
|
|
14
|
+
* dead, and make every user of a broken provider pay for it.
|
|
15
|
+
*
|
|
16
|
+
* A timeout cannot tell those apart, so a fixed schedule is the wrong shape
|
|
17
|
+
* either way. What CAN tell them apart is the evidence already in hand:
|
|
18
|
+
*
|
|
19
|
+
* 1. THE ALTERNATIVES. Walking away is only a remedy when it does not cost
|
|
20
|
+
* quality. If every alternative sits in a LOWER capability band, then
|
|
21
|
+
* "fail over" means "de-escalate", and for a blip that is the worse trade —
|
|
22
|
+
* so we wait instead. If a same-or-better band is reachable, failing over is
|
|
23
|
+
* free and waiting is pure waste.
|
|
24
|
+
* 2. THE PAIR'S TRACK RECORD. A pair that has served real traffic with a low
|
|
25
|
+
* error rate earns patience; a never-proven id does not.
|
|
26
|
+
* 3. THE SHAPE OF THE FAILURE. One failing step is a blip. The SAME pair
|
|
27
|
+
* failing two steps in a row is not — patience collapses there, whatever
|
|
28
|
+
* the alternatives look like.
|
|
29
|
+
*
|
|
30
|
+
* And the schedule's SHAPE matters as much as its total: a 2-second blink is
|
|
31
|
+
* caught by a retry at t≈1s, not at t=5s, so the early delays are dense and the
|
|
32
|
+
* late ones sparse ({@link TRANSIENT_BLIP_DELAYS_MS} → attempts at ≈1, 3, 7, 15,
|
|
33
|
+
* 30, 60s). That rides out both a blink and a real minute-long spike.
|
|
34
|
+
*
|
|
35
|
+
* PURE AND DETERMINISTIC. This module reads no clock, no registry and no config:
|
|
36
|
+
* the caller gathers the evidence (it has the registry and the ranked pool) and
|
|
37
|
+
* gets back a plan it can log. That is what makes the policy reviewable and
|
|
38
|
+
* testable one row at a time — see the table in the tests.
|
|
39
|
+
*/
|
|
40
|
+
import { type CapabilityBand } from './model-capability.js';
|
|
41
|
+
/**
|
|
42
|
+
* Transient (server/network/timeout) backoff, dense early and sparse late:
|
|
43
|
+
* attempts at ≈1s, 3s, 7s, 15s, 30s, 60s. Used exactly when WAITING beats
|
|
44
|
+
* walking away — no alternative, or only degrading ones.
|
|
45
|
+
*/
|
|
46
|
+
export declare const TRANSIENT_BLIP_DELAYS_MS: readonly [1000, 2000, 4000, 8000, 15000, 30000];
|
|
47
|
+
/**
|
|
48
|
+
* Transient backoff when a same-or-better-band candidate IS reachable: a short
|
|
49
|
+
* courtesy retry (two blinks' worth, <2s) and then the walk. Spending longer is
|
|
50
|
+
* waste — the replacement costs nothing in quality.
|
|
51
|
+
*/
|
|
52
|
+
export declare const TRANSIENT_FREE_ALTERNATIVE_DELAYS_MS: readonly [500, 1500];
|
|
53
|
+
/**
|
|
54
|
+
* Transient backoff for a pair we have no reason to trust and no alternative to:
|
|
55
|
+
* a token wait (≈5s), then the honest failure.
|
|
56
|
+
*/
|
|
57
|
+
export declare const TRANSIENT_LAST_RESORT_DELAYS_MS: readonly [1000, 4000];
|
|
58
|
+
/** Empty-response patience for a proven pair — the "final verse" case. */
|
|
59
|
+
export declare const EMPTY_PATIENCE_MS: readonly [2000, 5000];
|
|
60
|
+
/**
|
|
61
|
+
* Empty-response patience when EVERY alternative would de-escalate. Longer, and
|
|
62
|
+
* deliberately so: this is the one situation where the choice is literally
|
|
63
|
+
* "wait a few more seconds" vs "answer with a weaker model".
|
|
64
|
+
*/
|
|
65
|
+
export declare const EMPTY_PATIENCE_WAIT_BEATS_FOLDING_MS: readonly [2000, 5000, 10000];
|
|
66
|
+
/**
|
|
67
|
+
* Error rate at or below which a verified pair counts as a proven track record.
|
|
68
|
+
* Above it the pair has failed roughly 1 call in 5, which is not something a
|
|
69
|
+
* blip explains away.
|
|
70
|
+
*/
|
|
71
|
+
export declare const PROVEN_ERROR_RATE_MAX = 0.2;
|
|
72
|
+
/** Registry evidence for the failing pair, as the caller reads it. */
|
|
73
|
+
export interface PatienceEvidence {
|
|
74
|
+
/** `status === 'verified'` in the Model Availability Registry. */
|
|
75
|
+
verified: boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Where that verification came from. Real traffic (`telemetry`) is strong
|
|
78
|
+
* evidence; a bare catalog `probe` is not (it proves the id exists, nothing
|
|
79
|
+
* about answers), so it cannot on its own earn the long patience.
|
|
80
|
+
*/
|
|
81
|
+
source?: 'telemetry' | 'spot-check' | 'probe';
|
|
82
|
+
/** Rolling error rate 0–1, when recorded. */
|
|
83
|
+
errorRate?: number;
|
|
84
|
+
}
|
|
85
|
+
export interface PatienceInput {
|
|
86
|
+
/** The pair that just failed. */
|
|
87
|
+
current: {
|
|
88
|
+
provider: string;
|
|
89
|
+
model: string;
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* The pairs this surface could switch to, best first (provider + the model it
|
|
93
|
+
* would actually serve). Empty = this surface has nowhere else to go — a
|
|
94
|
+
* pinned turn, a single configured provider, the last candidate.
|
|
95
|
+
*/
|
|
96
|
+
alternatives: ReadonlyArray<{
|
|
97
|
+
provider: string;
|
|
98
|
+
model: string;
|
|
99
|
+
}>;
|
|
100
|
+
/** Registry evidence for {@link current}; omit when nothing is recorded. */
|
|
101
|
+
evidence?: PatienceEvidence;
|
|
102
|
+
/** Did this pair already fail an EARLIER step of this same turn? */
|
|
103
|
+
failedEarlierStep?: boolean;
|
|
104
|
+
/** Has this turn already produced completed tool work? */
|
|
105
|
+
deliveredWorkThisTurn?: boolean;
|
|
106
|
+
}
|
|
107
|
+
export interface PatiencePlan {
|
|
108
|
+
/** Schedule for server/network/timeout failures (`[]` = do not retry). */
|
|
109
|
+
transientDelaysMs: readonly number[];
|
|
110
|
+
/** Schedule for an `empty-response` (`[]` = do not retry). */
|
|
111
|
+
emptyResponseDelaysMs: readonly number[];
|
|
112
|
+
/** The strongest band reachable elsewhere, when an alternative exists. */
|
|
113
|
+
bestAlternativeBand?: CapabilityBand;
|
|
114
|
+
/**
|
|
115
|
+
* True when we are deliberately WAITING rather than folding down a band —
|
|
116
|
+
* the situation the log line exists to make visible.
|
|
117
|
+
*/
|
|
118
|
+
foldingWouldDegrade: boolean;
|
|
119
|
+
/** Why this plan — printed once, so a slow turn is explainable after the fact. */
|
|
120
|
+
reason: string;
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Decide how patient to be with the pair that just failed, and say why.
|
|
124
|
+
*
|
|
125
|
+
* The whole policy, in order (see the tests for each row):
|
|
126
|
+
*
|
|
127
|
+
* 1. The pair already failed an earlier step of this turn → NOT a blip. One
|
|
128
|
+
* token wait, no empty patience.
|
|
129
|
+
* 2. Nothing to gain by patience: a same-or-better band is reachable → short
|
|
130
|
+
* transient retry; empty patched only for a proven pair (a good pair's
|
|
131
|
+
* first blink is still worth two short waits).
|
|
132
|
+
* 3. A PROVEN pair facing only degrading alternatives (or none) → long, dense
|
|
133
|
+
* transient patience, and extended empty patience. This is the row that
|
|
134
|
+
* stops a blinking strong model from being replaced by a weak one.
|
|
135
|
+
* 4. An UNPROVEN pair with nowhere better to go → a token wait; the walk (or
|
|
136
|
+
* the honest failure) is the remedy, not optimism about a stranger.
|
|
137
|
+
*/
|
|
138
|
+
export declare function planBlipPatience(input: PatienceInput): PatiencePlan;
|
|
139
|
+
//# sourceMappingURL=retry-patience.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"retry-patience.d.ts","sourceRoot":"","sources":["../../src/learning/retry-patience.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AAEH,OAAO,EAA+B,KAAK,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEzF;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,iDAAwD,CAAC;AAE9F;;;;GAIG;AACH,eAAO,MAAM,oCAAoC,sBAAwB,CAAC;AAE1E;;;GAGG;AACH,eAAO,MAAM,+BAA+B,uBAA0B,CAAC;AAEvE,0EAA0E;AAC1E,eAAO,MAAM,iBAAiB,uBAA0B,CAAC;AAEzD;;;;GAIG;AACH,eAAO,MAAM,oCAAoC,8BAAkC,CAAC;AAEpF;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,MAAM,CAAC;AAEzC,sEAAsE;AACtE,MAAM,WAAW,gBAAgB;IAC/B,kEAAkE;IAClE,QAAQ,EAAE,OAAO,CAAC;IAClB;;;;OAIG;IACH,MAAM,CAAC,EAAE,WAAW,GAAG,YAAY,GAAG,OAAO,CAAC;IAC9C,6CAA6C;IAC7C,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAA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