Two steps
Writer, then editor
AgentFlow runs the steps in order. The second step receives what the first one produced.
steps is the list. start sends the first prompt. The editor sees the writer’s draft. The result prints each step, then its answer.
Example
from praisonai import Agent, AgentFlow
writer = Agent(name="Writer", instructions="Write two sentences on the input.")
editor = Agent(name="Editor", instructions="Shorten the draft to one sentence.")
flow = AgentFlow(steps=[writer, editor])
result = flow.start("Write about AI agents")
for step in result["steps"]:
print(step["step"])
print(step["output"])
print()Example explained
- steps — The agents, in the order they should run.
- start — The prompt for the first step.
Hard limit on the editor
Production flows often cap length on the last step.
Example
from praisonai import Agent, AgentFlow
writer = Agent(name="Writer", instructions="Write three short sentences.")
editor = Agent(name="Editor", instructions="Reply in at most twelve words total.")
flow = AgentFlow(steps=[writer, editor])
result = flow.start("Write about observability")
print(result["steps"][-1]["output"])Example explained
- from praisonai import Agent, AgentFlow — Imports Agent, AgentFlow needed for hard limit on the editor.
- Agent(…) — Instantiates the Agent configured for hard limit on the editor.
- AgentFlow(…) — Chains agents, branches, parallel steps, or loops in a defined order.
- .start(…) — Executes the configured run for hard limit on the editor and returns the result.
Reference: documentation