liveBook · Manning

Pipeline

As explained in Build an AI Agent (From Scratch)

A workflow is a predefined sequence of computational steps that controls execution while delegating selected steps to language models or other components.

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

How Build an AI Agent (From Scratch) covers it

How deep it goes
Defines single calls, chains, and routers, then develops sequential, parallel, loop, and nested multi-agent workflows through a shared run interface.
Examples
Uses document processing and a composed research, parallel-analysis, write–review, and editing pipeline.
What it assumes
Introduces the workflow–agent distinction before implementing multi-agent composition; assumes familiarity with basic code and LLM calls.
What you can do after
Build it from scratch: define agent order and context handling, then compose sequential, parallel, and loop stages behind one interface.
How it connects
Connects workflows to LLM routing, multi-agent orchestration, context sharing, and agents embedded within fixed stages.

Also explained in

Compare how 48 books explain pipeline →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build an AI Agent (From Scratch). The section links point to the parts of the book it draws on.