feat: cap 503 overload key retries to 1 retry key and split Admin UI into subpages

This commit is contained in:
tyuXX 2026-11-05 19:44:07 +00:00
parent 343208216e
commit 9d44c92b01
15 changed files with 3372 additions and 2997 deletions

View file

@ -114,7 +114,7 @@ async function runTests() {
name: 'Emergency Provider Tier 0',
type: 'custom',
baseUrl: upstreamBaseUrl,
keys: ['key-t0-1', 'key-t0-2']
keys: ['key-t0-1', 'key-t0-2', 'key-t0-3', 'key-t0-4', 'key-t0-5']
});
const pT1 = configStore.saveProvider({
@ -146,8 +146,9 @@ async function runTests() {
modelCircuitBreaker.tripCooldown(pT1.id, 'mock-t1-model', 'Simulated 503 outage');
// Also mark keys rate-limited
configStore.updateKeyStats(pT0.id, 'key-t0-1', { rateLimitedUntil: Date.now() + 60000 });
configStore.updateKeyStats(pT0.id, 'key-t0-2', { rateLimitedUntil: Date.now() + 60000 });
for (const k of pT0.keys) {
configStore.updateKeyStats(pT0.id, k.key, { rateLimitedUntil: Date.now() + 60000 });
}
configStore.updateKeyStats(pT1.id, 'key-t1-1', { rateLimitedUntil: Date.now() + 60000 });
// Verify all key-model pairs are detected as on cooldown
@ -174,11 +175,11 @@ async function runTests() {
const data = (await response.json()) as any;
assert.strictEqual(data.choices[0].message.content, 'Emergency probe saved the request!');
// Verify candidates were attempted sequentially: Candidate 1 -> Candidate 2 -> Candidate 3
assert.strictEqual(candidateAttempts.length, 3);
// Verify candidates were attempted sequentially, skipping keys 3..5 after 2nd 503: Candidate 1 -> Candidate 2 -> Candidate 3 (Tier 1)
assert.strictEqual(candidateAttempts.length, 3, 'Should only try 2 keys on Tier 0 before skipping remaining 3 keys and failing over to Tier 1');
assert.strictEqual(candidateAttempts[0], 'mock-t0-model:key-t0-1', 'Candidate 1 must be attempted first with revoked cooldown');
assert.strictEqual(candidateAttempts[1], 'mock-t0-model:key-t0-2', 'Candidate 2 must be attempted next with revoked cooldown');
assert.strictEqual(candidateAttempts[2], 'mock-t1-model:key-t1-1', 'Candidate 3 must be attempted next and succeed');
assert.strictEqual(candidateAttempts[1], 'mock-t0-model:key-t0-2', 'Candidate 2 (1 retry key) must be attempted next with revoked cooldown');
assert.strictEqual(candidateAttempts[2], 'mock-t1-model:key-t1-1', 'Candidate 3 in Tier 1 must be attempted next (skipping keys 3..5 of Tier 0) and succeed');
// Verify Candidate 1 and Candidate 2 were put back on cooldown upon failure
assert.strictEqual(modelCircuitBreaker.isTargetInCooldown(pT0.id, 'mock-t0-model'), true, 'Tier 0 target must be back in cooldown after failing');