feat(licensing): consume normalized UiPathAPIError from the LLM client#946
Open
vldcmp-uipath wants to merge 1 commit into
Open
feat(licensing): consume normalized UiPathAPIError from the LLM client#946vldcmp-uipath wants to merge 1 commit into
vldcmp-uipath wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the agent to consume the LLM client’s newly normalized UiPathAPIError (with .status_code and .body) for consistent provider HTTP error handling, removing the in-repo per-provider error “duck typing” logic and aligning dependency constraints to the newer client versions.
Changes:
- Switch
llm_nodeand licensing error mapping to handleUiPathAPIErrordirectly and surface gatewaybody["detail"]when available. - Remove the legacy provider exception normalization module (
chat/provider_errors.py) and its tests, replacing coverage with new licensing-focused tests. - Bump
uipath-langchainto0.13.12and raiseuipath-langchain-clientfloor to>=1.15.0,<1.16.0(plus updated lockfile).
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| uv.lock | Updates locked versions for uipath-langchain, uipath-langchain-client, and uipath-llm-client to support normalized UiPathAPIError. |
| pyproject.toml | Bumps package version and updates uipath-langchain-client[...] dependency constraints to 1.15.x. |
| src/uipath_langchain/agent/react/llm_node.py | Narrows LLM error handling to UiPathAPIError and routes it through licensing mapping. |
| src/uipath_langchain/agent/exceptions/licensing.py | Rewrites mapping to consume UiPathAPIError.status_code / .body and convert to AgentRuntimeError. |
| src/uipath_langchain/chat/provider_errors.py | Deleted: removes per-provider exception normalization logic. |
| tests/chat/test_provider_errors.py | Deleted: removes tests for the deleted extractor. |
| tests/agent/test_licensing.py | Added: validates UiPathAPIError → AgentRuntimeError mapping for 403/non-403 and missing-detail bodies. |
Comment on lines
+121
to
+125
| try: | ||
| response = await llm.ainvoke(messages) | ||
| except Exception as e: | ||
| # LLM errors arrive as provider-specific exceptions (OpenAI, Bedrock, | ||
| # Vertex). Convert to a structured AgentRuntimeError with the HTTP | ||
| # status code so upstream handlers can categorise (e.g. 403 → licensing). | ||
| except UiPathAPIError as e: | ||
| raise_for_provider_http_error(e) | ||
| except Exception: |
Contributor
Author
There was a problem hiding this comment.
excelent catch. will address this
1a24468 to
758f638
Compare
uipath-langchain-client 1.15.0 (on uipath-llm-client 1.15.0) now normalizes provider HTTP errors into a UiPathAPIError carrying .status_code and .body. llm_node catches it and maps it to a structured AgentRuntimeError, reading the gateway message from body["detail"]. This removes the in-repo chat/provider_errors.py duck-typing extractor — the client owns that normalization now — and rewrites licensing.py to map the UiPathAPIError status code onto the agent taxonomy (403 -> LICENSE_NOT_AVAILABLE, otherwise HTTP_ERROR). Bumps the uipath-langchain-client floor to >=1.15.0,<1.16.0. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
758f638 to
11cdca7
Compare
|
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
uipath-langchain-client1.15.0 (onuipath-llm-client1.15.0) now normalizes provider HTTP errors into aUiPathAPIErrorcarrying.status_codeand.body(the gateway ProblemDetails). This PR makes the agent consume that normalized error instead of re-deriving it here.llm_nodecatchesUiPathAPIErrorand maps it to anAgentRuntimeError, reading the gateway message frombody["detail"].licensing.pyis rewritten to map theUiPathAPIErrorstatus code onto the agent taxonomy (403 → LICENSE_NOT_AVAILABLE/DEPLOYMENT, otherwiseHTTP_ERROR/UNKNOWN).chat/provider_errors.py(and its test) — the per-provider duck-typing extractor is no longer needed; the client owns that normalization across every provider (OpenAI/Anthropic/Vertex/Bedrock), including the LangChain-wrapped cases.uipath-langchain-clientfloor>=1.14.1,<1.15.0→>=1.15.0,<1.16.0.Why
Previously
provider_errors.pyduck-typed each SDK's exception shape (.body/.details/.response) to recover(status_code, detail). That logic now lives once, in the LLM client (UiPathAPIError.from_provider), so the agent layer just catchesUiPathAPIErrorand reads.status_code/.body.Verified end-to-end (on 1.15.0)
UiPathChatOpenAI.invoke()on a gateway 403 →UiPathAPIError(status_code=403, body=…)→AgentRuntimeError(code=LICENSE_NOT_AVAILABLE, status=403, category=DEPLOYMENT, detail="License not available… 'AGU'"). Confirmed via the actual chat-model classes (openai/anthropic) and the licensing mapping.Tests
New
tests/agent/test_licensing.py: 403 →LICENSE_NOT_AVAILABLEwith the detail surfaced; non-403 →HTTP_ERROR(detail preserved within the wrapped message); missing-detailbody → safe fallback.Follow-up (separate repo)
uipath-agentspinsuipath-langchain[bedrock,vertex]==0.13.11(exact) — it'll need its pin bumped to==0.13.12to pick this up.🤖 Generated with Claude Code