22
33from pydantic import BaseModel
44from restack_ai .workflow import (
5+ NonRetryableError ,
56 ParentClosePolicy ,
67 import_functions ,
78 log ,
@@ -24,27 +25,35 @@ class RoomWorkflow:
2425 @workflow .run
2526 async def run (self ) -> RoomWorkflowOutput :
2627 agent_id = f"{ workflow_info ().workflow_id } -agent"
27- agent = await workflow .child_start (
28- agent = AgentVideo ,
29- agent_id = agent_id ,
30- start_to_close_timeout = timedelta (minutes = 20 ),
31- parent_close_policy = ParentClosePolicy .ABANDON ,
32- )
33-
34- log .info ("Agent started" , agent = agent )
35-
36- room_url = await workflow .step (
37- function = pipecat_pipeline ,
38- function_input = PipecatPipelineInput (
39- agent_name = AgentVideo .__name__ ,
40- agent_id = agent .id ,
41- agent_run_id = agent .run_id ,
42- ),
43- start_to_close_timeout = timedelta (minutes = 20 ),
44- )
45-
46- log .info ("Pipecat pipeline started" )
47-
48- log .info ("RoomWorkflow completed" , room_url = room_url )
49-
50- return RoomWorkflowOutput (room_url = room_url )
28+ try :
29+ agent = await workflow .child_start (
30+ agent = AgentVideo ,
31+ agent_id = agent_id ,
32+ start_to_close_timeout = timedelta (minutes = 20 ),
33+ parent_close_policy = ParentClosePolicy .ABANDON ,
34+ )
35+ except Exception as e :
36+ error_message = f"Error during child_start: { e } "
37+ raise NonRetryableError (error_message ) from e
38+ else :
39+ log .info ("Agent started" , agent = agent )
40+
41+ try :
42+ room_url = await workflow .step (
43+ function = pipecat_pipeline ,
44+ function_input = PipecatPipelineInput (
45+ agent_name = AgentVideo .__name__ ,
46+ agent_id = agent .id ,
47+ agent_run_id = agent .run_id ,
48+ ),
49+ start_to_close_timeout = timedelta (minutes = 20 ),
50+ )
51+ except Exception as e :
52+ error_message = f"Error during pipecat_pipeline: { e } "
53+ raise NonRetryableError (error_message ) from e
54+ else :
55+ log .info ("Pipecat pipeline started" )
56+
57+ log .info ("RoomWorkflow completed" , room_url = room_url )
58+
59+ return RoomWorkflowOutput (room_url = room_url )
0 commit comments