From 693a6f96cf8ff7c5fba9c161c10d5be5137fbb9a Mon Sep 17 00:00:00 2001 From: Jon Church Date: Thu, 17 Apr 2025 16:15:01 -0400 Subject: [PATCH] fix: update regex to better match the retry error messages (#266) I think the retry issue is just that the regex is wrong, checkout the reported error messages folks are seeing: > message: 'Rate limit reached for o4-mini in organization org-{redacted} on tokens per min (TPM): Limit 200000, Used 152566, Requested 60651. Please try again in 3.965s. Visit https://platform.openai.com/account/rate-limits to learn more.', The error message uses `try again` not `retry again` peep this regexpal: https://www.regexpal.com/?fam=155648 --- codex-cli/src/utils/agent/agent-loop.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codex-cli/src/utils/agent/agent-loop.ts b/codex-cli/src/utils/agent/agent-loop.ts index cd971f39..f42a277d 100644 --- a/codex-cli/src/utils/agent/agent-loop.ts +++ b/codex-cli/src/utils/agent/agent-loop.ts @@ -599,7 +599,7 @@ export class AgentLoop { // Parse suggested retry time from error message, e.g., "Please try again in 1.3s" const msg = errCtx?.message ?? ""; - const m = /retry again in ([\d.]+)s/i.exec(msg); + const m = /(?:retry|try) again in ([\d.]+)s/i.exec(msg); if (m && m[1]) { const suggested = parseFloat(m[1]) * 1000; if (!Number.isNaN(suggested)) {