A pipeline is a developer-defined execution flow. Code determines the available steps and how they connect; a language model performs selected tasks within that structure. An agent differs by deciding its own next actions and when to stop. A pipeline makes the path predictable, though an individual model response may still vary. section 1.3 section 1.3.1
Start with the least control flow the task needs:
- Single call: send one focused task, such as classification or summarization, to a model. section 1.3.1
- Chain: feed one call’s output into the next. A presentation pipeline might extract key points, organize themes, draft slides, then refine them. section 1.3.1
- Router: let a model choose among predefined paths, such as billing or technical support. The model selects a route; the developer defines the routes. section 1.3.1
For a multi-agent pipeline, put the execution order in code. Run agents sequentially when later stages need earlier results, in parallel for independent analyses of the same input, or in a loop when a review condition calls for another pass. The developer also chooses whether stages share context or receive isolated contexts. section 9.3 section 9.2
Make each workflow expose the same `run()` interface as an agent. Then a parallel analysis can sit inside a sequential pipeline, and a write–review loop can become another stage. A caller still supplies input and receives one result. This avoids wiring every combination as a special case. section 9.3.1 section 9.3.5
workflow = SequentialWorkflow(
agents=[
researcher,
ParallelWorkflow(agents=[optimist, pessimist, realist]),
LoopWorkflow(
agents=[writer, reviewer],
stop_condition=quality_reached,
max_iterations=3,
),
editor,
]
)
result = await workflow.run("Write an AI market analysis report")
The listing assembles research, parallel perspectives, a write–review loop with a stop condition and iteration limit, and final editing into one callable workflow. section 9.3.5
Keep flexibility inside a bounded stage
A document-processing pipeline can validate and extract metadata, hand content analysis to an agent, then check compliance and route the result for delivery. The agent can investigate freely inside its stage; the surrounding workflow supplies a predictable review point if its result is unexpected. section 1.3.3
Prefer a pipeline when the steps are known ahead of time. It is easier to reason about and debug than an unrestricted agent loop, and flexible agent stages can be reserved for work that justifies their extra calls. In a shared-context sequential workflow, later agents can inspect earlier work; isolation hides intermediate steps, so choose context handling deliberately. section 1.3.3 section 9.4.3















































