fix: use ignoreRateLimits in retryClaudeWithRotation loops
Without this, token rotation was blocked by stale cooldowns even when the target token had available usage.
This commit is contained in:
@@ -351,7 +351,7 @@ export async function runAgentForGroup(
|
|||||||
while (
|
while (
|
||||||
shouldRotateClaudeToken(trigger.reason) &&
|
shouldRotateClaudeToken(trigger.reason) &&
|
||||||
getTokenCount() > 1 &&
|
getTokenCount() > 1 &&
|
||||||
rotateToken(lastRotationMessage)
|
rotateToken(lastRotationMessage, { ignoreRateLimits: true })
|
||||||
) {
|
) {
|
||||||
logger.info(
|
logger.info(
|
||||||
{ chatJid, group: group.name, runId, reason: trigger.reason },
|
{ chatJid, group: group.name, runId, reason: trigger.reason },
|
||||||
@@ -422,7 +422,9 @@ export async function runAgentForGroup(
|
|||||||
retryAfterMs: retryAttempt.streamedTriggerReason.retryAfterMs,
|
retryAfterMs: retryAttempt.streamedTriggerReason.retryAfterMs,
|
||||||
};
|
};
|
||||||
lastRotationMessage =
|
lastRotationMessage =
|
||||||
typeof retryOutput.result === 'string' ? retryOutput.result : undefined;
|
typeof retryOutput.result === 'string'
|
||||||
|
? retryOutput.result
|
||||||
|
: undefined;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -450,7 +450,7 @@ async function runTask(
|
|||||||
while (
|
while (
|
||||||
shouldRotateClaudeToken(trigger.reason) &&
|
shouldRotateClaudeToken(trigger.reason) &&
|
||||||
getTokenCount() > 1 &&
|
getTokenCount() > 1 &&
|
||||||
rotateToken(lastRotationMessage)
|
rotateToken(lastRotationMessage, { ignoreRateLimits: true })
|
||||||
) {
|
) {
|
||||||
logger.info(
|
logger.info(
|
||||||
{
|
{
|
||||||
@@ -534,35 +534,33 @@ async function runTask(
|
|||||||
error = 'Claude usage exhausted';
|
error = 'Claude usage exhausted';
|
||||||
// Fall through to task completion handling below
|
// Fall through to task completion handling below
|
||||||
} else {
|
} else {
|
||||||
|
const attempt = await runTaskAttempt(provider);
|
||||||
|
result = attempt.attemptResult;
|
||||||
|
error = attempt.attemptError;
|
||||||
|
|
||||||
const attempt = await runTaskAttempt(provider);
|
if (
|
||||||
result = attempt.attemptResult;
|
provider === 'claude' &&
|
||||||
error = attempt.attemptError;
|
attempt.streamedTriggerReason &&
|
||||||
|
!attempt.sawOutput
|
||||||
if (
|
) {
|
||||||
provider === 'claude' &&
|
await retryClaudeTaskWithRotation(attempt.streamedTriggerReason);
|
||||||
attempt.streamedTriggerReason &&
|
} else if (attempt.output.status === 'error' && provider === 'claude') {
|
||||||
!attempt.sawOutput
|
const trigger = attempt.streamedTriggerReason
|
||||||
) {
|
? {
|
||||||
await retryClaudeTaskWithRotation(attempt.streamedTriggerReason);
|
shouldFallback: true,
|
||||||
} else if (attempt.output.status === 'error' && provider === 'claude') {
|
reason: attempt.streamedTriggerReason.reason,
|
||||||
const trigger = attempt.streamedTriggerReason
|
retryAfterMs: attempt.streamedTriggerReason.retryAfterMs,
|
||||||
? {
|
}
|
||||||
shouldFallback: true,
|
: detectFallbackTrigger(error);
|
||||||
reason: attempt.streamedTriggerReason.reason,
|
if (trigger.shouldFallback) {
|
||||||
retryAfterMs: attempt.streamedTriggerReason.retryAfterMs,
|
await retryClaudeTaskWithRotation({
|
||||||
}
|
reason: trigger.reason,
|
||||||
: detectFallbackTrigger(error);
|
retryAfterMs: trigger.retryAfterMs,
|
||||||
if (trigger.shouldFallback) {
|
});
|
||||||
await retryClaudeTaskWithRotation({
|
}
|
||||||
reason: trigger.reason,
|
} else if (attempt.output.status === 'error') {
|
||||||
retryAfterMs: trigger.retryAfterMs,
|
error = attempt.attemptError || 'Unknown error';
|
||||||
});
|
|
||||||
}
|
}
|
||||||
} else if (attempt.output.status === 'error') {
|
|
||||||
error = attempt.attemptError || 'Unknown error';
|
|
||||||
}
|
|
||||||
|
|
||||||
} // end else (non-exhausted path)
|
} // end else (non-exhausted path)
|
||||||
|
|
||||||
logger.info(
|
logger.info(
|
||||||
|
|||||||
Reference in New Issue
Block a user