From 8863e3302d1e1154329bf36e05bc69765e48d5bd Mon Sep 17 00:00:00 2001 From: Gaurav Singh Date: Thu, 26 Feb 2026 15:36:36 -0800 Subject: [PATCH 1/2] fix: added retry mehanism to integration tools --- .../agent/tools/integration_tool.py | 34 +++++++++++++------ 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/src/uipath_langchain/agent/tools/integration_tool.py b/src/uipath_langchain/agent/tools/integration_tool.py index eac7523e2..43708b910 100644 --- a/src/uipath_langchain/agent/tools/integration_tool.py +++ b/src/uipath_langchain/agent/tools/integration_tool.py @@ -6,12 +6,18 @@ from langchain.tools import BaseTool from langchain_core.messages import ToolCall from langchain_core.tools import StructuredTool +from tenacity import ( + retry, + retry_if_exception, + stop_after_attempt, + wait_exponential_jitter, +) from uipath.agent.models.agent import AgentIntegrationToolResourceConfig from uipath.eval.mocks import mockable from uipath.platform import UiPath from uipath.platform.connections import ActivityMetadata, ActivityParameterLocationInfo +from uipath.platform.errors import EnrichedException from uipath.runtime.errors import UiPathErrorCategory - from uipath_langchain.agent.exceptions import AgentStartupError, AgentStartupErrorCode from uipath_langchain.agent.react.jsonschema_pydantic_converter import create_model from uipath_langchain.agent.react.types import AgentGraphState @@ -165,6 +171,18 @@ def create_integration_tool( sdk = UiPath() + def _is_429(exc: BaseException) -> bool: + return ( + isinstance(exc, EnrichedException) + and getattr(exc, "status_code", None) == 429 + ) + + @retry( + retry=retry_if_exception(_is_429), + wait=wait_exponential_jitter(initial=10, max=120, jitter=5), + stop=stop_after_attempt(5), + reraise=True, + ) @mockable( name=resource.name, description=resource.description, @@ -173,15 +191,11 @@ def create_integration_tool( example_calls=resource.properties.example_calls, ) async def integration_tool_fn(**kwargs: Any): - try: - result = await sdk.connections.invoke_activity_async( - activity_metadata=activity_metadata, - connection_id=connection_id, - activity_input=sanitize_dict_for_serialization(kwargs), - ) - except Exception: - raise - + result = await sdk.connections.invoke_activity_async( + activity_metadata=activity_metadata, + connection_id=connection_id, + activity_input=sanitize_dict_for_serialization(kwargs), + ) return result async def integration_tool_wrapper( From 51a611008761318e19bcd785abb951b18d82c570 Mon Sep 17 00:00:00 2001 From: Gaurav Singh Date: Thu, 26 Feb 2026 19:07:31 -0800 Subject: [PATCH 2/2] fix: fixed lint error --- src/uipath_langchain/agent/tools/integration_tool.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/uipath_langchain/agent/tools/integration_tool.py b/src/uipath_langchain/agent/tools/integration_tool.py index 43708b910..4fb277739 100644 --- a/src/uipath_langchain/agent/tools/integration_tool.py +++ b/src/uipath_langchain/agent/tools/integration_tool.py @@ -18,6 +18,7 @@ from uipath.platform.connections import ActivityMetadata, ActivityParameterLocationInfo from uipath.platform.errors import EnrichedException from uipath.runtime.errors import UiPathErrorCategory + from uipath_langchain.agent.exceptions import AgentStartupError, AgentStartupErrorCode from uipath_langchain.agent.react.jsonschema_pydantic_converter import create_model from uipath_langchain.agent.react.types import AgentGraphState