Parallel
Two researchers, then one summary
parallel runs several agents on the same input, then a later step can read all of their answers.
The market and competitor agents run together. The aggregator runs after both have finished. Each name is printed above its answer.
Example
from praisonai import Agent, AgentFlow, parallel
market = Agent(name="Market", instructions="Name one market trend in a sentence.")
competitor = Agent(name="Competitor", instructions="Name one competitor type in a sentence.")
aggregator = Agent(name="Aggregator", instructions="Combine the findings into two lines.")
flow = AgentFlow(steps=[
parallel([market, competitor]),
aggregator,
])
result = flow.start("Research note-taking apps")
for step in result["steps"]:
print(step["step"])
print(step["output"])
print()Example explained
- parallel — A list of agents that run at the same time.
Aggregator must mention both
Tighten the aggregator so it references both parallel outputs.
Example
from praisonai import Agent, AgentFlow, parallel
a = Agent(name="A", instructions="Reply with Risk: and one risk.")
b = Agent(name="B", instructions="Reply with Mitigation: and one mitigation.")
agg = Agent(name="Agg", instructions="Include both Risk and Mitigation labels in one paragraph.")
flow = AgentFlow(steps=[parallel([a, b]), agg])
result = flow.start("Agent deploy")
print(result["steps"][-1]["output"])Example explained
- from praisonai import Agent, AgentFlow, parallel — Imports Agent, AgentFlow, parallel needed for aggregator must mention both.
- Agent(…) — Instantiates the Agent configured for aggregator must mention both.
- AgentFlow(…) — Chains agents, branches, parallel steps, or loops in a defined order.
- .start(…) — Executes the configured run for aggregator must mention both and returns the result.
Reference: documentation