fix(inference_provider): normalize provider endpoint errors#1797
Open
rodboev wants to merge 5 commits into
Open
fix(inference_provider): normalize provider endpoint errors#1797rodboev wants to merge 5 commits into
rodboev wants to merge 5 commits into
Conversation
Signed-off-by: Rod Boev <rod.boev@gmail.com>
Signed-off-by: Rod Boev <rod.boev@gmail.com>
Signed-off-by: Rod Boev <rod.boev@gmail.com>
Signed-off-by: Rod Boev <rod.boev@gmail.com>
Signed-off-by: Rod Boev <rod.boev@gmail.com>
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.
Summary
Normalize provider endpoint failures in
responses_api_models/inference_providerso/v1/chat/completionsand/v1/responsesreturn structured provider-aware errors instead of falling through to the generic inner-server500path.Closes #1748
Background
InferenceProvider.chat_completions()currently letsaiohttp.ClientResponseErrorescape directly fromcreate_chat_completion(). Shared middleware then collapses that into the same generic JSON500string for auth failures, rate limits, missing models, and upstream 5xx responses. As more OpenAI-compatible providers land, that hides whether a failure is retryable and strips the provider context callers need to debug the endpoint.Changes
ClientResponseErrorlocally inresponses_api_models/inference_provider/app.pyand raise a structuredHTTPExceptionbefore shared middleware flattens the failureprovider_status,retryable,provider_context,model,category, and a concise provider-derived message500failures through the shared retry path, status-zero fallback, and the/v1/responsesconverted pathmessageanddetailextraction, raw JSON fallback, string andNoneresponse_content, truncation, and the message-derived classification branchesOut of scope
nemo_gym/openai_utils.pyor shared middlewareValidation
uv run pytest responses_api_models/inference_provider/tests/test_app.py -xuv run pre-commit run --files responses_api_models/inference_provider/app.py responses_api_models/inference_provider/tests/test_app.pyruff check --config pyproject.toml responses_api_models/inference_provider/app.py responses_api_models/inference_provider/tests/test_app.pyruff format --config pyproject.toml --check responses_api_models/inference_provider/app.py responses_api_models/inference_provider/tests/test_app.pyNotes
Native Windows
uv runstill fails in this repo becauseuvloopcannot build on Windows during dependency resolution. That is the same known environment limitation called out in the local repo config, so the focused pytest and pre-commit commands remain unchecked here and CI is the authoritative proof surface for the behavioral tests added in this slice.