Skip to main content
Run independent agents at the same time, then merge their outputs in a final step.
from praisonaiagents import Agent, AgentFlow, parallel

ai = Agent(name="AI", instructions="Research AI trends")
ml = Agent(name="ML", instructions="Research ML trends")
summary = Agent(name="Summary", instructions="Combine research")
flow = AgentFlow(steps=[parallel([ai, ml]), summary])
flow.start("Research latest developments")
The user runs parallel steps for speed, then lets a summariser agent combine the results.

Quick Start

1

Simple Usage

Run two agents together, then summarise with a third.
from praisonaiagents import Agent, AgentFlow, parallel

ai = Agent(name="AI", instructions="Research AI trends")
ml = Agent(name="ML", instructions="Research ML trends")
summary = Agent(name="Summary", instructions="Combine research")
flow = AgentFlow(steps=[parallel([ai, ml]), summary])
flow.start("Research latest developments")
2

With Configuration

Choose how the group reacts to a failing agent.
from praisonaiagents import Agent, AgentFlow, parallel

flow = AgentFlow(steps=[
    parallel([ai, ml], on_failure="fail_fast"),
    summary,
])
flow.start("Research latest developments")

How It Works


Parallel Workflow

Run multiple agents at the same time instead of waiting for each one.

Speed Comparison

SequentialParallel
Time3 seconds~1 second
Speed1x3x faster

When to Use


Code

from praisonaiagents import Agent, AgentFlow
from praisonaiagents import parallel

# Create agents
ai_researcher = Agent(name="AI", instructions="Research AI trends")
ml_researcher = Agent(name="ML", instructions="Research ML trends")
nlp_researcher = Agent(name="NLP", instructions="Research NLP trends")
summarizer = Agent(name="Summary", instructions="Combine all research")

# Run in parallel, then summarize
flow = AgentFlow(steps=[
    parallel([ai_researcher, ml_researcher, nlp_researcher]),
    summarizer
])

result = flow.start("Research latest developments")

How Results Combine


Failure Handling

Choose how parallel execution responds to failures.

Strategy Examples

from praisonaiagents import WorkflowStepError

# Default: Continue with partial results
flow = AgentFlow(steps=[
    parallel([agent_a, agent_b, agent_c]),  # Some might fail
    summarizer  # Gets whatever succeeded
])

# Stop fast: First failure cancels others
flow = AgentFlow(steps=[
    parallel([agent_a, agent_b, agent_c], on_failure="fail_fast"),
    # This step never runs if any agent fails
])

# Fail all: Wait for everything, then report errors
try:
    flow = AgentFlow(steps=[
        parallel([agent_a, agent_b, agent_c], on_failure="fail_all"),
    ])
    result = flow.start("Process")
except WorkflowStepError as e:
    print(f"Failed agents: {len(e.errors)}")

Best Practices

parallel gives no benefit when a step depends on an earlier result. Use it for genuinely independent research or data pulls.
partial_ok (default) keeps going with what succeeded; fail_fast cancels the rest on the first error; fail_all collects every error. Choose per the cost of missing data.
Parallel steps return a list in parallel_outputs. Have the summariser combine that list rather than expecting a single string.
from praisonaiagents import parallel uses the friendly re-export, keeping the sample short and matching the SDK’s recommended surface.

Sequential

One step at a time

Routing

Send to the right expert