Handle OpenAI device auth rate limits#3969
Open
baditaflorin wants to merge 2 commits into
Open
Conversation
Collaborator
|
[Automatic Post]: It has been a while since there was any activity on this PR. @baditaflorin, are you still working on it? If so, please go ahead, if not then please request review, close it, or request that someone else follow up. This comment was created by an AI agent (OpenHands) on behalf of the repository maintainers. |
Author
|
@openhands-agent waiting for youy to merge it |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
HUMAN:
Florin requested this fix after hitting the OpenAI device-auth 500 locally.
AGENT:
Why
OpenAI can rate-limit ChatGPT device-code sign-in. When that happens today, the SDK raises a generic
RuntimeError; the agent-server route does not translate it into an HTTP response, so FastAPI reports an unhandled exception and returns500 Internal Server Error. In local reproduction,POST /api/llm/subscription/openai/device/startreturned a 500 withDevice code request failed with status 429.This PR makes the provider failure explicit and returns a retryable
429 Too Many Requestsresponse to callers instead of treating OpenAI rate limiting as an internal server crash.Summary
OpenAIDeviceAuthErrorso OpenAI device-auth failures carry the upstream status code.Issue Number
N/A
How to Test
I ran the targeted router tests and formatting/lint checks:
Result:
I also reproduced the behavior locally before making the PR: OpenAI returned status 429 from the device-code endpoint, which previously surfaced as a 500. After the same change was applied locally, the agent-server route returned
429 Too Many Requestswith a clear retry message.Video/Screenshots
N/A, API behavior change covered by route tests and local curl reproduction.
Type
Bug fix