fix where models didnt wait if retrydelay is less than 2 mins for multi account scenario

This commit is contained in:
Badri Narayanan S
2025-12-21 19:57:50 +05:30
parent 8eead9660c
commit c703fb32fb

View File

@@ -256,19 +256,12 @@ export async function sendMessage(anthropicRequest, accountManager) {
);
}
if (accountManager.getAccountCount() === 1) {
// Single account mode: wait for reset
console.log(`[CloudCode] Single account rate-limited. Waiting ${formatDuration(waitMs)}...`);
// Wait for reset (applies to both single and multi-account modes)
const accountCount = accountManager.getAccountCount();
console.log(`[CloudCode] All ${accountCount} account(s) rate-limited. Waiting ${formatDuration(waitMs)}...`);
await sleep(waitMs);
accountManager.clearExpiredLimits();
account = accountManager.pickNext();
} else {
// Multi-account: all exhausted - throw proper error
throw new Error(
`RESOURCE_EXHAUSTED: All ${accountManager.getAccountCount()} accounts rate-limited. ` +
`quota will reset after ${formatDuration(waitMs)}. Next available: ${resetTime}`
);
}
}
if (!account) {
@@ -509,19 +502,12 @@ export async function* sendMessageStream(anthropicRequest, accountManager) {
);
}
if (accountManager.getAccountCount() === 1) {
// Single account mode: wait for reset
console.log(`[CloudCode] Single account rate-limited. Waiting ${formatDuration(waitMs)}...`);
// Wait for reset (applies to both single and multi-account modes)
const accountCount = accountManager.getAccountCount();
console.log(`[CloudCode] All ${accountCount} account(s) rate-limited. Waiting ${formatDuration(waitMs)}...`);
await sleep(waitMs);
accountManager.clearExpiredLimits();
account = accountManager.pickNext();
} else {
// Multi-account: all exhausted - throw proper error
throw new Error(
`RESOURCE_EXHAUSTED: All ${accountManager.getAccountCount()} accounts rate-limited. ` +
`quota will reset after ${formatDuration(waitMs)}. Next available: ${resetTime}`
);
}
}
if (!account) {