Skip to content

fix(exceptions): categorize LLM provider HTTP errors by status class#933

Open
cotovanu-cristian wants to merge 1 commit into
mainfrom
fix/provider-http-error-categorization
Open

fix(exceptions): categorize LLM provider HTTP errors by status class#933
cotovanu-cristian wants to merge 1 commit into
mainfrom
fix/provider-http-error-categorization

Conversation

@cotovanu-cristian

Copy link
Copy Markdown
Collaborator

Problem

raise_for_provider_http_error (the single point where an LLM provider HTTP status becomes a runtime error category) mapped only 403 → DEPLOYMENT and dumped every other status to UNKNOWN:

category = DEPLOYMENT if status_code == 403 else UNKNOWN

This is a root cause behind a large share of the miscategorized "Unknown" agent-execution failures in SRE-610701. Concretely:

  • A provider 429 rate-limit (investigation Cat 14) surfaced as Unknown instead of System, even though it never reached the uipath-agents exception mapper's own 429 → SYSTEM path (it was already wrapped here).
  • The awsbedrock 503 family (Cat 2) and gateway timeouts (408) likewise fell to Unknown.

Fix

Map by status class at the source:

Status Category Why
401, 403 DEPLOYMENT auth / entitlement / licensing
408, 429, 5xx SYSTEM timeout / throttling / provider/gateway failure
else UNKNOWN left to the last-resort mapper

403 → DEPLOYMENT behavior is preserved. Categorizing here means these errors no longer fall through to uipath-agents' exception_mapper.py as Unknown.

Tests

  • Corrected test_other_status_falls_back_to_http_error_and_str (no longer asserts 500 → UNKNOWN).
  • Added a parametrized test_status_code_maps_to_expected_category covering 401/403/408/429/500/503/400/404.
  • Full file: 17 passed; ruff + mypy clean.

Found via the investigate-alert-execution-failures run on SRE-610701.

🤖 Generated with Claude Code

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>
Copilot AI review requested due to automatic review settings June 24, 2026 15:28

Copilot AI 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.

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/403 become DEPLOYMENT, 408/429/5xx become SYSTEM, and others remain UNKNOWN.
  • 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
@sonarqubecloud

Copy link
Copy Markdown

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.

2 participants