-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[WRONG BRANCH] fix(errors): surface plan usage-cap text instead of Codex 429 retries #4107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,5 @@ | ||
| import { parseRetryAfterMs } from "../combos"; | ||
| import { classifyError, parseRetryAfterFromMessage } from "./errors"; | ||
| import { classifyError, parseRetryAfterFromMessage, USAGE_LIMIT_ERROR_CODE } from "./errors"; | ||
|
|
||
| /** Small default when a retryable 429 has no upstream Retry-After (#507). */ | ||
| export const DEFAULT_RETRYABLE_429_RETRY_AFTER_SEC = "2"; | ||
|
|
@@ -48,7 +48,12 @@ export function resolveClientRetryAfter(opts: { | |
| if (opts.includeDefault === false) return undefined; | ||
| if (opts.status !== 429) return undefined; | ||
| const classified = classifyError(429, "rate_limit_error", message || "Too Many Requests"); | ||
| if (classified.type === "insufficient_quota" || classified.code === "insufficient_quota") { | ||
| if ( | ||
| classified.type === "insufficient_quota" | ||
| || classified.code === "insufficient_quota" | ||
| || classified.type === USAGE_LIMIT_ERROR_CODE | ||
| || classified.code === USAGE_LIMIT_ERROR_CODE | ||
| ) { | ||
|
Comment on lines
+51
to
+56
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win Classify usage-limit responses before resolving In 🤖 Prompt for AI Agents |
||
| return undefined; | ||
| } | ||
| return DEFAULT_RETRYABLE_429_RETRY_AFTER_SEC; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Honor
options.codefor usage-limit responses.At
src/bridge.ts:2145-2149,options.codeis applied only for cyber-policy errors. With a neutral message andstatus === 429,classifyErrorproducesrate_limit_exceeded, soclientStatusForClassifiedErrorkeeps HTTP 429 and the formatter emitsRetry-After. Copy the structured usage-limit code and type before the status and header mapping:Proposed fix
if (isCyberPolicyCode(options?.code)) { error.code = CYBER_POLICY_ERROR_CODE; error.type = cyberPolicyErrorType(type); + } else if (isUsageLimitCode(options?.code)) { + error.code = USAGE_LIMIT_ERROR_CODE; + error.type = USAGE_LIMIT_ERROR_CODE; }🤖 Prompt for AI Agents