Skip to content

Commit 15f1d02

Browse files
committed
fix: chat runtime results should be suspended
1 parent aed58ac commit 15f1d02

File tree

6 files changed

+21
-8
lines changed

6 files changed

+21
-8
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# UiPath Runtime
22

3-
[![PyPI downloads](https://img.shields.io/pypi/dm/uipath-runtime.svg)](https://pypi.org/project/uipath-runtime/)
43
[![PyPI - Version](https://img.shields.io/pypi/v/uipath-runtime)](https://pypi.org/project/uipath-runtime/)
4+
[![PyPI downloads](https://img.shields.io/pypi/dm/uipath-runtime.svg)](https://pypi.org/project/uipath-runtime/)
55
[![Python versions](https://img.shields.io/pypi/pyversions/uipath-runtime.svg)](https://pypi.org/project/uipath-runtime/)
66

77
Runtime abstractions and contracts for the UiPath Python SDK.

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-runtime"
3-
version = "0.2.4"
3+
version = "0.2.5"
44
description = "Runtime abstractions and interfaces for building agents and automation scripts in the UiPath ecosystem"
55
readme = { file = "README.md", content-type = "text/markdown" }
66
requires-python = ">=3.11"

src/uipath/runtime/chat/runtime.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,21 @@ async def stream(
6666
await self.chat_bridge.connect()
6767

6868
async for event in self.delegate.stream(input, options=options):
69-
if isinstance(event, UiPathRuntimeMessageEvent):
69+
if isinstance(event, UiPathRuntimeResult):
70+
# In chat mode, convert successful completion to SUSPENDED
71+
# Breakpoints and resumable triggers are already suspended
72+
# Faulted jobs remain faulted
73+
if event.status == UiPathRuntimeStatus.SUCCESSFUL:
74+
yield UiPathRuntimeResult(
75+
status=UiPathRuntimeStatus.SUSPENDED,
76+
output=event.output,
77+
)
78+
else:
79+
yield event
80+
elif isinstance(event, UiPathRuntimeMessageEvent):
7081
if event.payload:
7182
await self.chat_bridge.emit_message_event(event.payload)
72-
73-
yield event
83+
yield event
7484

7585
async def get_schema(self) -> UiPathRuntimeSchema:
7686
"""Get schema from the delegate runtime."""

src/uipath/runtime/errors/exception.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
"""Base exception class for UiPath runtime errors with structured error information."""
22

3+
from __future__ import annotations
4+
35
import sys
46
import traceback
57
from typing import Any
@@ -105,7 +107,7 @@ def __init__(
105107
@classmethod
106108
def from_resume_trigger_error(
107109
cls, exc: UiPathFaultedTriggerError
108-
) -> "UiPathRuntimeError":
110+
) -> UiPathRuntimeError:
109111
"""Create UiPathRuntimeError from UiPathFaultedTriggerError."""
110112
return cls(
111113
code=UiPathErrorCode.RESUME_TRIGGER_ERROR,
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ async def test_chat_runtime_streams_and_emits_messages():
114114

115115
# Result propagation
116116
assert isinstance(result, UiPathRuntimeResult)
117-
assert result.status == UiPathRuntimeStatus.SUCCESSFUL
117+
assert result.status == UiPathRuntimeStatus.SUSPENDED
118118
assert result.output == {"messages": ["Hello", "How are you?", "Goodbye"]}
119119

120120
# Bridge lifecycle
@@ -158,6 +158,7 @@ async def test_chat_runtime_stream_yields_all_events():
158158
assert isinstance(events[0], UiPathRuntimeMessageEvent)
159159
assert isinstance(events[1], UiPathRuntimeMessageEvent)
160160
assert isinstance(events[2], UiPathRuntimeResult)
161+
assert events[2].status == UiPathRuntimeStatus.SUSPENDED
161162

162163
# Bridge methods called
163164
cast(AsyncMock, bridge.connect).assert_awaited_once()

uv.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)