fix(exceptions): categorize LLM provider HTTP errors by status class#933
Open
cotovanu-cristian wants to merge 1 commit into
Open
fix(exceptions): categorize LLM provider HTTP errors by status class#933cotovanu-cristian wants to merge 1 commit into
cotovanu-cristian wants to merge 1 commit into
Conversation
raise_for_provider_http_error mapped only 403 -> DEPLOYMENT and dumped every other status (429, 408, 5xx) to UNKNOWN. This is the root cause behind a large share of "Unknown" agent-execution failures in SRE-610701: e.g. a provider 429 rate-limit (Cat 14) and the awsbedrock 503 family were tagged Unknown even though the runtime already treats them as System elsewhere. Replace the single-status check with a status->category mapping: - 401/403 -> DEPLOYMENT (auth / entitlement / licensing) - 408/429/5xx -> SYSTEM (timeout / throttling / provider/gateway failure) - everything else -> UNKNOWN (left to the last-resort mapper) Categorizing at the source means these no longer fall through to the uipath-agents exception mapper as Unknown. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR improves how LLM provider HTTP errors are categorized when they’re converted into AgentRuntimeError, reducing the number of misclassified UNKNOWN failures by mapping common HTTP status classes to more appropriate UiPathErrorCategory values.
Changes:
- Added a status-code → category mapping helper so
401/403becomeDEPLOYMENT,408/429/5xxbecomeSYSTEM, and others remainUNKNOWN. - Updated provider-error tests to validate category mapping across a set of representative HTTP status codes.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/uipath_langchain/agent/exceptions/licensing.py |
Introduces _category_for_status() and uses it in raise_for_provider_http_error() to categorize provider HTTP errors by status class. |
tests/chat/test_provider_errors.py |
Adjusts existing assertions and adds a parametrized test covering expected category mapping for multiple status codes. |
Comment on lines
+31
to
+35
| if status_code in (401, 403): | ||
| return UiPathErrorCategory.DEPLOYMENT | ||
| if status_code == 408 or status_code == 429 or status_code >= 500: | ||
| return UiPathErrorCategory.SYSTEM | ||
| return UiPathErrorCategory.UNKNOWN |
|
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.



Problem
raise_for_provider_http_error(the single point where an LLM provider HTTP status becomes a runtime error category) mapped only403 → DEPLOYMENTand dumped every other status toUNKNOWN:This is a root cause behind a large share of the miscategorized "Unknown" agent-execution failures in SRE-610701. Concretely:
Unknowninstead ofSystem, even though it never reached the uipath-agents exception mapper's own429 → SYSTEMpath (it was already wrapped here).Unknown.Fix
Map by status class at the source:
DEPLOYMENTSYSTEMUNKNOWN403 → DEPLOYMENTbehavior is preserved. Categorizing here means these errors no longer fall through touipath-agents'exception_mapper.pyasUnknown.Tests
test_other_status_falls_back_to_http_error_and_str(no longer asserts500 → UNKNOWN).test_status_code_maps_to_expected_categorycovering 401/403/408/429/500/503/400/404.ruff+mypyclean.Found via the
investigate-alert-execution-failuresrun on SRE-610701.🤖 Generated with Claude Code