Skip to content

fix(openai-compat): honor bounded rate-limit waits - #5435

Open
huangruiteng wants to merge 1 commit into
router-for-me:devfrom
huangruiteng:codex/openai-compat-bounded-rate-limit-waits
Open

fix(openai-compat): honor bounded rate-limit waits#5435
huangruiteng wants to merge 1 commit into
router-for-me:devfrom
huangruiteng:codex/openai-compat-bounded-rate-limit-waits

Conversation

@huangruiteng

Copy link
Copy Markdown

Summary

  • propagate standard Retry-After headers from OpenAI-compatible HTTP errors into the auth retry/cooldown path
  • use a one-minute bounded fallback only when a 429 explicitly identifies a tokens-per-minute limit and the provider omitted Retry-After
  • keep generic 429 behavior unchanged

This prevents large requests from being replayed immediately through providers that enforce minute-level token windows, while preserving provider-supplied deadlines when available.

Tests

  • go test ./... -count=1
  • executor tests cover delta-seconds and HTTP-date headers, header precedence, explicit TPM fallback, generic 429, non-429, and both streaming/non-streaming bootstrap paths

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 3, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-03T03:16:41.770486Z 6f16121 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6f16121554

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

log.Errorf("openai compat executor: close response body error: %v", errClose)
}
err = statusErr{code: httpResp.StatusCode, msg: string(b)}
err = newOpenAICompatStatusError(httpResp.StatusCode, httpResp.Header, b)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve retry metadata for streamed image errors

When SourceFormat is openai-image with streaming enabled, ExecuteStream returns through executeImagesStream before reaching this error path. That function's non-2xx branch still returns a plain statusErr at line 650, so a streamed image request receiving a 429 loses both the provider's Retry-After value and the new TPM fallback, causing the auth manager to use its shorter generic cooldown instead. Use newOpenAICompatStatusError in the image-stream bootstrap branch as well.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant