Spaces:
Running
Running
Heaven K Claude Opus 4.6 commited on
Commit ·
001455d
1
Parent(s): 4244d9b
fix: add 30s cooldown on 400 errors to prevent retry loop
Browse filesSince findAvailableSlot always starts from slot 0, a 400 error
without cooldown would keep hitting the same Mistral slot forever.
Now it gets a 30s cooldown so the pool moves to the next Mistral
model, then Groq if all Mistral models are on cooldown.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
packages/server/src/providers/pool.ts
CHANGED
|
@@ -100,14 +100,16 @@ export class AIProviderPool {
|
|
| 100 |
}
|
| 101 |
|
| 102 |
if (error.status === 400) {
|
| 103 |
-
// 400 errors: invalid model, json_validate_failed, bad request
|
| 104 |
const bodyStr = error.body ?? error.message ?? '';
|
| 105 |
const isInvalidModel = bodyStr.includes('invalid_model') || bodyStr.includes('Invalid model');
|
| 106 |
if (isInvalidModel) {
|
| 107 |
slot.disabled = true;
|
| 108 |
logger.warn(`Invalid model on ${slot.provider.name}, permanently disabled`);
|
| 109 |
} else {
|
| 110 |
-
|
|
|
|
|
|
|
| 111 |
}
|
| 112 |
this.currentIndex = (this.currentIndex + 1) % this.slots.length;
|
| 113 |
continue;
|
|
|
|
| 100 |
}
|
| 101 |
|
| 102 |
if (error.status === 400) {
|
| 103 |
+
// 400 errors: invalid model, json_validate_failed, bad request
|
| 104 |
const bodyStr = error.body ?? error.message ?? '';
|
| 105 |
const isInvalidModel = bodyStr.includes('invalid_model') || bodyStr.includes('Invalid model');
|
| 106 |
if (isInvalidModel) {
|
| 107 |
slot.disabled = true;
|
| 108 |
logger.warn(`Invalid model on ${slot.provider.name}, permanently disabled`);
|
| 109 |
} else {
|
| 110 |
+
// Cooldown to prevent retry loop (findAvailableSlot starts from 0)
|
| 111 |
+
slot.cooldownUntil = Date.now() + 30_000;
|
| 112 |
+
logger.warn(`400 error on ${slot.provider.name}, 30s cooldown. Trying next...`);
|
| 113 |
}
|
| 114 |
this.currentIndex = (this.currentIndex + 1) % this.slots.length;
|
| 115 |
continue;
|