Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# UiPath Runtime

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

Runtime abstractions and contracts for the UiPath Python SDK.
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "uipath-runtime"
version = "0.2.4"
version = "0.2.5"
description = "Runtime abstractions and interfaces for building agents and automation scripts in the UiPath ecosystem"
readme = { file = "README.md", content-type = "text/markdown" }
requires-python = ">=3.11"
Expand Down
18 changes: 14 additions & 4 deletions src/uipath/runtime/chat/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ async def execute(
return (
result
if result
else UiPathRuntimeResult(status=UiPathRuntimeStatus.SUCCESSFUL)
else UiPathRuntimeResult(status=UiPathRuntimeStatus.SUSPENDED)
)

async def stream(
Expand All @@ -66,11 +66,21 @@ async def stream(
await self.chat_bridge.connect()

async for event in self.delegate.stream(input, options=options):
if isinstance(event, UiPathRuntimeMessageEvent):
if isinstance(event, UiPathRuntimeResult):
# In chat mode, convert successful completion to SUSPENDED
# Breakpoints and resumable triggers are already suspended
# Faulted jobs remain faulted
if event.status == UiPathRuntimeStatus.SUCCESSFUL:
yield UiPathRuntimeResult(
status=UiPathRuntimeStatus.SUSPENDED,
output=event.output,
)
else:
yield event
elif isinstance(event, UiPathRuntimeMessageEvent):
if event.payload:
await self.chat_bridge.emit_message_event(event.payload)

yield event
yield event

async def get_schema(self) -> UiPathRuntimeSchema:
"""Get schema from the delegate runtime."""
Expand Down
4 changes: 3 additions & 1 deletion src/uipath/runtime/errors/exception.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
"""Base exception class for UiPath runtime errors with structured error information."""

from __future__ import annotations

import sys
import traceback
from typing import Any
Expand Down Expand Up @@ -105,7 +107,7 @@ def __init__(
@classmethod
def from_resume_trigger_error(
cls, exc: UiPathFaultedTriggerError
) -> "UiPathRuntimeError":
) -> UiPathRuntimeError:
"""Create UiPathRuntimeError from UiPathFaultedTriggerError."""
return cls(
code=UiPathErrorCode.RESUME_TRIGGER_ERROR,
Expand Down
3 changes: 2 additions & 1 deletion tests/test_chat_runtime.py → tests/test_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ async def test_chat_runtime_streams_and_emits_messages():

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

# Bridge lifecycle
Expand Down Expand Up @@ -158,6 +158,7 @@ async def test_chat_runtime_stream_yields_all_events():
assert isinstance(events[0], UiPathRuntimeMessageEvent)
assert isinstance(events[1], UiPathRuntimeMessageEvent)
assert isinstance(events[2], UiPathRuntimeResult)
assert events[2].status == UiPathRuntimeStatus.SUSPENDED

# Bridge methods called
cast(AsyncMock, bridge.connect).assert_awaited_once()
Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.