Skip to content

Commit 12c71f8

Browse files
feat: propagate errors from agent runtime to CAS
1 parent 77c98b8 commit 12c71f8

File tree

3 files changed

+52
-5
lines changed

3 files changed

+52
-5
lines changed

packages/uipath/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "uipath"
3-
version = "2.10.8"
3+
version = "2.10.9"
44
description = "Python SDK and CLI for UiPath Platform, enabling programmatic interaction with automation services, process management, and deployment tools."
55
readme = { file = "README.md", content-type = "text/markdown" }
66
requires-python = ">=3.11"

packages/uipath/src/uipath/_cli/_chat/_bridge.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
from urllib.parse import urlparse
1010

1111
from uipath.core.chat import (
12+
UiPathConversationErrorEvent,
13+
UiPathConversationErrorStartEvent,
1214
UiPathConversationEvent,
1315
UiPathConversationExchangeEndEvent,
1416
UiPathConversationExchangeEvent,
@@ -246,6 +248,51 @@ async def emit_exchange_end_event(self) -> None:
246248
logger.error(f"Error sending conversation event to WebSocket: {e}")
247249
raise RuntimeError(f"Failed to send conversation event: {e}") from e
248250

251+
async def emit_exchange_error_event(
252+
self, error_id: str, message: str, details: Any | None = None
253+
) -> None:
254+
"""Send an exchange error event to signal an error to the UI.
255+
256+
Args:
257+
error_id: Identifier for the error type
258+
message: Human-readable error message
259+
details: Optional additional error details
260+
"""
261+
if self._client is None:
262+
raise RuntimeError("WebSocket client not connected. Call connect() first.")
263+
264+
if not self._connected_event.is_set() and not self._websocket_disabled:
265+
raise RuntimeError("WebSocket client not in connected state")
266+
267+
try:
268+
exchange_error_event = UiPathConversationEvent(
269+
conversation_id=self.conversation_id,
270+
exchange=UiPathConversationExchangeEvent(
271+
exchange_id=self.exchange_id,
272+
error=UiPathConversationErrorEvent(
273+
error_id=error_id,
274+
start=UiPathConversationErrorStartEvent(
275+
message=message, details=details
276+
),
277+
),
278+
),
279+
)
280+
281+
event_data = exchange_error_event.model_dump(
282+
mode="json", exclude_none=True, by_alias=True
283+
)
284+
285+
if self._websocket_disabled:
286+
logger.info(
287+
f"SocketIOChatBridge is in debug mode. Not sending event: {json.dumps(event_data)}"
288+
)
289+
else:
290+
await self._client.emit("ConversationEvent", event_data)
291+
292+
except Exception as e:
293+
logger.error(f"Error sending exchange error event to WebSocket: {e}")
294+
raise RuntimeError(f"Failed to send exchange error event: {e}") from e
295+
249296
async def emit_interrupt_event(self, resume_trigger: UiPathResumeTrigger):
250297
if self._client and self._connected_event.is_set():
251298
try:

packages/uipath/uv.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)