coder-agent 2.9.5 → 2.9.6
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/agent.js +26 -2
- package/package.json +1 -1
package/dist/agent.js
CHANGED
|
@@ -503,10 +503,34 @@ async function callGeminiAPIWithRotation(apiKey, params, maxRetries = 3, initial
|
|
|
503
503
|
const nextModel = rotationList[modelIndex];
|
|
504
504
|
if (!silent) {
|
|
505
505
|
stopSpinner();
|
|
506
|
-
|
|
507
|
-
|
|
506
|
+
let reason = "Rate limited";
|
|
507
|
+
if (isModelError)
|
|
508
|
+
reason = "Model unavailable";
|
|
509
|
+
else if (status >= 500)
|
|
510
|
+
reason = "Server error (5xx)";
|
|
511
|
+
console.log(chalk.hex('#ff9f0a')('⚠') + ' ' + chalk.gray(`${reason} on ${currentModel}. Rotating to ${nextModel}...`));
|
|
508
512
|
startSpinner("thinking...");
|
|
509
513
|
}
|
|
514
|
+
// Delay slightly on rate limits or server errors before sending next request
|
|
515
|
+
if (status === 429 || (status >= 500 && status < 600)) {
|
|
516
|
+
try {
|
|
517
|
+
await new Promise((resolve, reject) => {
|
|
518
|
+
const timer = setTimeout(resolve, 2000);
|
|
519
|
+
if (signal) {
|
|
520
|
+
signal.addEventListener("abort", () => {
|
|
521
|
+
clearTimeout(timer);
|
|
522
|
+
const abortErr = new Error("The user aborted a request.");
|
|
523
|
+
abortErr.name = "AbortError";
|
|
524
|
+
reject(abortErr);
|
|
525
|
+
});
|
|
526
|
+
}
|
|
527
|
+
});
|
|
528
|
+
}
|
|
529
|
+
catch (err) {
|
|
530
|
+
if (err.name === "AbortError" || signal?.aborted)
|
|
531
|
+
throw err;
|
|
532
|
+
}
|
|
533
|
+
}
|
|
510
534
|
currentModel = nextModel;
|
|
511
535
|
attempts = 0; // reset retry counter for the fresh model
|
|
512
536
|
continue;
|