fix: codex rate-limit retry immediately instead of next request

This commit is contained in:
Eyejoker
2026-03-23 23:07:35 +09:00
parent 816b0a39cc
commit 30be180f4b

View File

@@ -428,13 +428,13 @@ export async function runAgentForGroup(
} }
// Codex may report success but have streamed a rate-limit error. // Codex may report success but have streamed a rate-limit error.
// Rotate token so the NEXT request uses a fresh account. // Rotate token and retry immediately with the new account.
if ( if (
!isClaudeCodeAgent && !isClaudeCodeAgent &&
primaryAttempt.streamedTriggerReason && primaryAttempt.streamedTriggerReason &&
getCodexAccountCount() > 1 getCodexAccountCount() > 1 &&
rotateCodexToken()
) { ) {
if (rotateCodexToken()) {
logger.info( logger.info(
{ {
chatJid, chatJid,
@@ -442,8 +442,12 @@ export async function runAgentForGroup(
runId, runId,
reason: primaryAttempt.streamedTriggerReason.reason, reason: primaryAttempt.streamedTriggerReason.reason,
}, },
'Codex rate-limited (streamed), rotated account for next request', 'Codex rate-limited (streamed), retrying with rotated account',
); );
const retryAttempt = await runAttempt('codex');
if (!retryAttempt.error) {
markCodexTokenHealthy();
return 'success';
} }
} }