Spaces:
Running
Running
Heaven K Claude Opus 4.6 commited on
Commit ·
5252a42
1
Parent(s): 3ed3f80
fix: handle 403 and unexpected errors in AI pool instead of crashing
Browse files403 (forbidden/blocked model) now permanently disables the slot and
tries the next provider. Any other unexpected errors (JSON parse,
network, etc.) get a 10s cooldown instead of aborting the entire pool.
This prevents "Max retries exceeded" when some models are blocked.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
packages/server/src/providers/pool.ts
CHANGED
|
@@ -112,6 +112,14 @@ export class AIProviderPool {
|
|
| 112 |
continue;
|
| 113 |
}
|
| 114 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
if (error.status === 404) {
|
| 116 |
// 404: model does not exist on this provider — permanently disable the slot
|
| 117 |
slot.disabled = true;
|
|
@@ -128,7 +136,11 @@ export class AIProviderPool {
|
|
| 128 |
continue;
|
| 129 |
}
|
| 130 |
|
| 131 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 132 |
}
|
| 133 |
}
|
| 134 |
|
|
|
|
| 112 |
continue;
|
| 113 |
}
|
| 114 |
|
| 115 |
+
if (error.status === 403) {
|
| 116 |
+
// 403: model blocked at org level or forbidden — permanently disable
|
| 117 |
+
slot.disabled = true;
|
| 118 |
+
logger.warn(`Forbidden (403) on ${slot.provider.name}, permanently disabled. Trying next...`);
|
| 119 |
+
this.currentIndex = (this.currentIndex + 1) % this.slots.length;
|
| 120 |
+
continue;
|
| 121 |
+
}
|
| 122 |
+
|
| 123 |
if (error.status === 404) {
|
| 124 |
// 404: model does not exist on this provider — permanently disable the slot
|
| 125 |
slot.disabled = true;
|
|
|
|
| 136 |
continue;
|
| 137 |
}
|
| 138 |
|
| 139 |
+
// Any other error (JSON parse, network, etc.) — cooldown and try next
|
| 140 |
+
slot.cooldownUntil = Date.now() + 10_000;
|
| 141 |
+
logger.warn(`Unexpected error on ${slot.provider.name}: ${error.message || error.status}. Trying next...`);
|
| 142 |
+
this.currentIndex = (this.currentIndex + 1) % this.slots.length;
|
| 143 |
+
continue;
|
| 144 |
}
|
| 145 |
}
|
| 146 |
|