@@ -300,6 +300,41 @@ def __init__(
300300 hook_manager=HookManager(verbose_logging=False, open_telemetry=True),
301301 )
302302 await workflow.execute()
303+
304+ .. _workflow-instantiation-params:
305+
306+ **Passing Parameters to Factories**
307+
308+ To provide parameters to your `graph_factory` or `store_factory` when
309+ you create a `Workflow`, you can wrap your factory function call in a
310+ `lambda`. This creates a new, argument-less factory that calls your
311+ function with the desired parameters when executed.
312+
313+ This is useful for injecting dependencies like configuration objects or
314+ API clients into your graph at instantiation time, while preserving
315+ concurrency safety.
316+
317+ .. code-block:: python
318+
319+ # Your factory function that requires a dependency
320+ def create_graph_with_dependency(emulator: Emulator) -> Graph:
321+ # ... setup graph using the emulator
322+ return Graph(...)
323+
324+ # An instance of the dependency
325+ my_emulator = Emulator()
326+
327+ # Instantiate the workflow, using a lambda to create the factory
328+ workflow = Workflow[MyState, MyStore](
329+ name="configured_workflow",
330+ graph_factory=lambda: create_graph_with_dependency(
331+ emulator=my_emulator
332+ ),
333+ store_factory=lambda: MyStore(initial_state=MyState())
334+ )
335+
336+ # The workflow can now be executed normally
337+ await workflow.execute()
303338 """
304339 super ().__init__ (
305340 graph_factory = graph_factory ,
0 commit comments