A small workflow
Parallel, then one editor
A workflow can use more than one pattern. Here two researchers work at the same time, then one editor shortens what they found.
The two names appear first. The editor’s sentence is last. That is the finished note.
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.")
editor = Agent(name="Editor", instructions="Shorten the notes to one sentence.")
flow = AgentFlow(steps=[
parallel([market, competitor]),
editor,
])
result = flow.start("Research note-taking apps")
for step in result["steps"]:
print(step["step"])
print(step["output"])
print()Example explained
- parallel — The researchers run together.
- editor — Runs after both have finished.
Cap the editor
Combine parallel plus a strict final step — common in production flows.
Example
from praisonai import Agent, AgentFlow, parallel
market = Agent(name="Market", instructions="One trend sentence.")
competitor = Agent(name="Competitor", instructions="One competitor sentence.")
editor = Agent(name="Editor", instructions="Max fifteen words total.")
flow = AgentFlow(steps=[parallel([market, competitor]), editor])
result = flow.start("Agents in healthcare")
print(result["steps"][-1]["output"])Example explained
- from praisonai import Agent, AgentFlow, parallel — Imports Agent, AgentFlow, parallel needed for cap the editor.
- Agent(…) — Instantiates the Agent configured for cap the editor.
- AgentFlow(…) — Chains agents, branches, parallel steps, or loops in a defined order.
- .start(…) — Executes the configured run for cap the editor and returns the result.
Reference: documentation