Parallel Workflow

Independent, concurrent tasks that can execute simultaneously for improved efficiency

Example Use-Cases: Multi-source research, parallel analysis, concurrent data processing

Parallel workflows maintain deterministic results while dramatically reducing execution time for independent operations.

Workflows parallel steps diagram

Example

1from kern.workflow import Parallel, Step, Workflow
2
3workflow = Workflow(
4 name="Parallel Research Pipeline",
5 steps=[
6 Parallel(
7 Step(name="HackerNews Research", agent=hn_researcher),
8 Step(name="Web Research", agent=web_researcher),
9 Step(name="Academic Research", agent=academic_researcher),
10 name="Research Step"
11 ),
12 Step(name="Synthesis", agent=synthesizer), # Combines the results and produces a report
13 ]
14)
15
16workflow.print_response("Write about the latest AI developments", markdown=True)

Handling Session State Data in Parallel Steps

When using custom Python functions in your steps, you can access and update the Worfklow session state via the run_context parameter.

If you are performing session state updates in Parallel Steps, be aware that concurrent access to shared state will require coordination to avoid race conditions.

Developer Resources

Reference

For complete API documentation, see Parallel Steps Reference.