Skip to content
Draft
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 pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "uipath-runtime"
version = "0.10.1"
version = "0.10.2"
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
2 changes: 2 additions & 0 deletions src/uipath/runtime/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from uipath.core.triggers import (
UiPathApiTrigger,
UiPathIntegrationTrigger,
UiPathResumeTrigger,
UiPathResumeTriggerName,
UiPathResumeTriggerType,
Expand Down Expand Up @@ -60,6 +61,7 @@
"UiPathResumableStorageProtocol",
"UiPathResumeTriggerProtocol",
"UiPathApiTrigger",
"UiPathIntegrationTrigger",
"UiPathResumeTrigger",
"UiPathResumeTriggerType",
"UiPathResumableRuntime",
Expand Down
2 changes: 2 additions & 0 deletions src/uipath/runtime/resumable/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from uipath.core.triggers import (
UiPathApiTrigger,
UiPathIntegrationTrigger,
UiPathResumeTrigger,
UiPathResumeTriggerType,
)
Expand All @@ -19,6 +20,7 @@
"UiPathResumeTriggerReaderProtocol",
"UiPathResumeTriggerProtocol",
"UiPathApiTrigger",
"UiPathIntegrationTrigger",
"UiPathResumeTrigger",
"UiPathResumeTriggerType",
]
14 changes: 9 additions & 5 deletions src/uipath/runtime/resumable/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,10 @@ async def stream(
options.resume = True

async def _get_fired_triggers(self) -> dict[str, Any] | None:
"""Check stored triggers for any that have already fired (excluding API triggers).
"""Check stored triggers for any that have already fired.

API triggers cannot be completed before suspending the job, so they are skipped.
Skips async-external triggers (API, Inbox) whose payloads only arrive
asynchronously and cannot be polled at suspend time.

Returns:
A resume map of {interrupt_id: resume_data} for fired triggers, or None.
Expand All @@ -156,10 +157,13 @@ async def _get_fired_triggers(self) -> dict[str, Any] | None:
if not triggers:
return None

non_api_triggers = [
t for t in triggers if t.trigger_type != UiPathResumeTriggerType.API
pollable_triggers = [
t
for t in triggers
if t.trigger_type
not in (UiPathResumeTriggerType.API, UiPathResumeTriggerType.INBOX)
]
return await self._build_resume_map(non_api_triggers)
return await self._build_resume_map(pollable_triggers)

async def _restore_resume_input(
self,
Expand Down
2 changes: 2 additions & 0 deletions src/uipath/runtime/resumable/trigger.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

from uipath.core.triggers import (
UiPathApiTrigger,
UiPathIntegrationTrigger,
UiPathResumeTrigger,
UiPathResumeTriggerName,
UiPathResumeTriggerType,
)

__all__ = [
"UiPathApiTrigger",
"UiPathIntegrationTrigger",
"UiPathResumeTrigger",
"UiPathResumeTriggerName",
"UiPathResumeTriggerType",
Expand Down
48 changes: 48 additions & 0 deletions tests/test_resumable.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,54 @@ async def read_trigger_impl(trigger: UiPathResumeTrigger) -> dict[str, Any]:
# Delegate should have been executed only once (no auto-resume)
assert runtime_impl.execution_count == 1

@pytest.mark.asyncio
async def test_resumable_skips_inbox_triggers_on_auto_resume_check(self) -> None:
"""Inbox triggers should be skipped when checking for auto-resume after suspension.

Inbox triggers are async-external (payload delivered via Integration
Services), so calling read_trigger on them at suspend time would hit a
404 and fault the run. They should behave like API triggers here.
"""

runtime_impl = MultiTriggerMockRuntime()
storage = StatefulStorageMock()
trigger_manager = make_trigger_manager_mock()

def create_inbox_trigger(data: dict[str, Any]) -> UiPathResumeTrigger:
return UiPathResumeTrigger(
interrupt_id="", # Will be set by resumable runtime
trigger_type=UiPathResumeTriggerType.INBOX,
payload=data,
)

trigger_manager.create_trigger = AsyncMock(side_effect=create_inbox_trigger) # type: ignore

# Track whether read_trigger is ever called — it must NOT be, otherwise
# the filter is broken and we'd hit the payload endpoint prematurely.
trigger_manager.read_trigger = AsyncMock(
side_effect=AssertionError(
"read_trigger must not be called for Inbox triggers pre-resume"
)
) # type: ignore

resumable = UiPathResumableRuntime(
delegate=runtime_impl,
storage=storage,
trigger_manager=trigger_manager,
runtime_id="runtime-1",
)

result = await resumable.execute({})

assert result.status == UiPathRuntimeStatus.SUSPENDED
assert result.triggers is not None
assert len(result.triggers) == 2
assert all(
t.trigger_type == UiPathResumeTriggerType.INBOX for t in result.triggers
)
trigger_manager.read_trigger.assert_not_called()
assert runtime_impl.execution_count == 1

@pytest.mark.asyncio
async def test_resumable_auto_resumes_task_triggers_but_not_api_triggers(
self,
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.

Loading