1616 UiPathRuntimeResult ,
1717 UiPathRuntimeStatus ,
1818)
19+ from uipath .runtime .resumable import UiPathResumeTriggerType
1920from uipath .runtime .resumable .protocols import (
2021 UiPathResumableStorageProtocol ,
2122 UiPathResumeTriggerProtocol ,
@@ -82,8 +83,11 @@ async def execute(
8283 suspension_result = await self ._handle_suspension (result )
8384
8485 # check if any trigger may be resumed
86+ # api triggers cannot be completed before suspending the job, skip them
8587 if suspension_result .status != UiPathRuntimeStatus .SUSPENDED or not (
86- fired_triggers := await self ._restore_resume_input (None )
88+ fired_triggers := await self ._restore_resume_input (
89+ None , skip_trigger_types = [UiPathResumeTriggerType .API ]
90+ )
8791 ):
8892 return suspension_result
8993
@@ -115,6 +119,7 @@ async def stream(
115119
116120 final_result : UiPathRuntimeResult | None = None
117121 execution_completed = False
122+ fired_triggers = None
118123
119124 while not execution_completed :
120125 async for event in self .delegate .stream (input , options = options ):
@@ -127,8 +132,12 @@ async def stream(
127132 if final_result :
128133 suspension_result = await self ._handle_suspension (final_result )
129134
135+ # check if any trigger may be resumed
136+ # api triggers cannot be completed before suspending the job, skip them
130137 if suspension_result .status != UiPathRuntimeStatus .SUSPENDED or not (
131- fired_triggers := await self ._restore_resume_input (None )
138+ fired_triggers := await self ._restore_resume_input (
139+ None , skip_trigger_types = [UiPathResumeTriggerType .API ]
140+ )
132141 ):
133142 yield suspension_result
134143 execution_completed = True
@@ -143,7 +152,9 @@ async def stream(
143152 options .resume = True
144153
145154 async def _restore_resume_input (
146- self , input : dict [str , Any ] | None
155+ self ,
156+ input : dict [str , Any ] | None ,
157+ skip_trigger_types : list [UiPathResumeTriggerType ] | None = None ,
147158 ) -> dict [str , Any ] | None :
148159 """Restore resume input from storage if not provided.
149160
@@ -180,14 +191,18 @@ async def _restore_resume_input(
180191 if not triggers :
181192 return None
182193
183- return await self ._build_resume_map (triggers )
194+ return await self ._build_resume_map (triggers , skip_trigger_types )
184195
185196 async def _build_resume_map (
186- self , triggers : list [UiPathResumeTrigger ]
197+ self ,
198+ triggers : list [UiPathResumeTrigger ],
199+ skip_trigger_types : list [UiPathResumeTriggerType ],
187200 ) -> dict [str , Any ]:
188201 # Build resume map: {interrupt_id: resume_data}
189202 resume_map : dict [str , Any ] = {}
190203 for trigger in triggers :
204+ if skip_trigger_types and trigger .trigger_type in skip_trigger_types :
205+ continue
191206 try :
192207 data = await self .trigger_manager .read_trigger (trigger )
193208 assert trigger .interrupt_id is not None , (
0 commit comments