1616 RegisteredWorkflow ,
1717)
1818from workflows .runtime .types .internal_state import BrokerState
19- from workflows .context .context import Context
2019from workflows .runtime .types .step_function import StepWorkerFunction
2120from workflows .runtime .types .ticks import WorkflowTick
22- from workflows . decorators import R
21+
2322from workflows .workflow import Workflow
2423
2524
@@ -33,50 +32,31 @@ def register(
3332 self ,
3433 workflow : Workflow ,
3534 workflow_function : ControlLoopFunction ,
36- steps : dict [str , StepWorkerFunction [ R ] ],
35+ steps : dict [str , StepWorkerFunction ],
3736 ) -> RegisteredWorkflow | None :
3837 """
3938 Wrap the workflow control loop in a DBOS workflow so ticks are received via DBOS.recv
4039 and sent via DBOS.send, enabling durable orchestration.
4140 """
4241
43-
44-
45- # DBOS Python supports async workflow functions; we wrap and return replacement.
46- # Note: We do not wrap individual step workers here; the control loop retains
47- # responsibility for step execution. This can be extended later to split steps
48- # into child workflows if needed.
49-
5042 @DBOS .workflow ()
5143 async def _dbos_control_loop (
5244 start_event : Event | None ,
5345 init_state : BrokerState | None ,
54- plugin : WorkflowRuntime ,
55- context : Context ,
56- step_workers : dict [str , StepWorkerFunction ],
46+ run_id : str ,
5747 ) -> StopEvent :
58- # Ensure our runtime knows the workflow id for routing incoming ticks
59- assert isinstance (plugin , DBOSWorkflowRuntime )
60- # Pin a stable workflow id for this run using the runtime's run_id
61- with SetWorkflowID (plugin .run_id ):
62- # Delegate to the original control loop function
63- return await workflow_function ( # type: ignore[misc]
64- start_event , init_state , plugin , context , step_workers
65- )
48+ with SetWorkflowID (run_id ):
49+ return await workflow_function (start_event , init_state , run_id )
6650
6751 async def wrapper (
6852 start_event : Event | None ,
6953 init_state : BrokerState | None ,
70- plugin : WorkflowRuntime ,
71- context : Context ,
72- step_workers : dict [str , StepWorkerFunction ],
54+ run_id : str ,
7355 ) -> StopEvent :
7456 # Call the DBOS workflow directly; DBOS will orchestrate execution
75- return await _dbos_control_loop (
76- start_event , init_state , plugin , context , step_workers
77- )
57+ return await _dbos_control_loop (start_event , init_state , run_id )
7858
79- return RegisteredWorkflow (workflow_function = wrapper , steps = steps )
59+ return RegisteredWorkflow (workflow_function = _dbos_control_loop , steps = steps )
8060
8161 def new_runtime (self , run_id : str ) -> WorkflowRuntime :
8262 runtime : WorkflowRuntime = DBOSWorkflowRuntime (run_id )
0 commit comments