In short.
This guide helps Python developers construct parallel execution workflows with pydantic-graph, but saving graph state for recovery requires a separate approach. It explains typed state and dependencies, decorated asynchronous steps, branching, parallel paths and reducers that collect results. Examples cover basic execution, processing a list, inspecting execution events and generating diagrams. Runtime behavior, performance and release compatibility were not assessed.
Researched and written by an AI model and checked by a second AI model. How it works
Coverage includes the complete captured page at [https://pydantic.dev/docs/ai/graph/builder/index.md], including its preamble, examples, asyncio execution notes, API comparison and persistence/resumability notice. Linked pages, package source, API references and issue discussions are excluded. Installation, example execution, integrations and performance were not tested. Exact release compatibility, costs and licensing terms are not established.
The overview
identity
The Graph Builder API page documents a function-based way to construct execution graphs in the Python package pydantic-graph. The resource is an instructional guide at [https://pydantic.dev/docs/ai/graph/builder/index.md].
It explains the builder API alongside the original class-based BaseNode API, which the page describes as supported and interoperable with the builder.
assessment
The guide is useful for learning workflows in which tasks branch, process multiple inputs concurrently and combine their results. Its progression from a counter to parallel collection makes the central abstractions concrete.
It is insufficient on its own for choosing a crash-recoverable workflow architecture. The page explicitly states that graph state is not snapshotted, and the examples provide no evidence of production reliability or performance.
users
The intended readers are Python developers who need explicit control over task order, branching, parallel paths and aggregation. The examples assume familiarity with async functions, decorators, type annotations and dataclasses.
Beginners can start with the counter example before approaching mapping and joins. Experienced developers can examine shared state, injected dependencies, execution events and compatibility with BaseNode-based graphs.
capabilities
The documented building blocks include asynchronous step nodes, conditional decision nodes, mapping over iterable items, broadcasting the same input to multiple paths, and joins that aggregate results through reducers. The page links to further documentation on decisions and parallel execution; the contents of those linked pages are outside the available evidence.
The guide also shows execution-event inspection through graph.iter() and Mermaid diagram generation through graph.render(). GraphRun exposes upcoming tasks, final output and manual advancement with optional value injection.
Using it
requirements
The examples require a Python environment with pydantic-graph, installed directly or through pydantic-ai, and an asynchronous execution context. A minimum Python version and exact package versions are not specified.
The worked examples perform arithmetic and contain no model calls or provider configuration. Requirements for adding AI services to graph steps are not described.
mechanism
GraphBuilder represents four types: shared mutable state, injected dependencies, initial input and final output. Functions decorated with @g.step receive StepContext, whose state, deps and inputs attributes provide the values needed by each step.
Edges connect the start node, work nodes and end node. A map operation sends iterable items into separate parallel executions; a join combines arriving results using a reducer. The example uses reduce_list_append to collect outputs into a list.
Calling g.build() produces the graph. graph.run() executes it to completion, while graph.iter() exposes execution events for closer control.
setup
The page gives two installation options: pip install pydantic-graph, or pip install pydantic-ai. Its basic pattern is to define state, create GraphBuilder, decorate asynchronous step functions, add edges, build the graph and await graph.run().
The asynchronous examples define main() without invoking it in their code blocks. Their accompanying notes explicitly require importing asyncio and adding asyncio.run(main()) to run them as scripts.
example
The counter example starts with state.value equal to zero. One step increments it and returns one; the next doubles that input. The page presents a final output of two and a final state value of one, illustrating the distinction between shared state and data passed between steps.
The parallel example maps a square function over [1, 2, 3, 4, 5], collects results through a join and presents sorted output [1, 4, 9, 16, 25], with five items processed. Sorting for display does not establish the collection's native ordering. These are documented outputs; no example was executed.
Assessment & evidence
limitations
Neither graph API snapshots graph state. The page states that pydantic_graph.persistence was removed in V2 because consistent snapshotting with parallel execution was complex.
It points to Harness StepPersistence for saving, resuming and forking agent-run state, and to durable execution engines for surviving crashes and restarts. Those are distinct capabilities whose integration is not explained here.
The page does not establish retry behavior, cancellation semantics, concurrency limits, synchronization rules for shared mutable state or production throughput.
reasoning
The guide's practical value comes from making data flow explicit: edges show connections, mapping distributes items and reducers collect results. These features make it a useful starting point when routing and aggregation are central to a workflow.
Adoption requires a separate recovery decision. A graph that describes parallel work does not, by itself, establish that interrupted work can be restored.
alternatives
The alternative described on this page is the original graph API built from BaseNode subclasses. It may suit developers who prefer representing steps as classes. The page says both approaches remain supported and can be combined.
The documentation presents the builder as more concise for simple workflows and more explicit about parallelism and reducers. These are qualitative comparisons; no comparative measurements or evaluations of other libraries are provided.
evidence
The documentation supplies installation commands, API explanations and examples covering sequential steps, parallel collection, execution inspection and diagram rendering. Its explicit persistence notice establishes an important architectural constraint.
The examples illustrate intended behavior rather than independently verified results. Linked API references, feature guides, issue discussions and recovery documentation are outside the available evidence. No code was executed, and performance was not assessed.
Access & freshness
costs
The page provides no pricing terms or operating-cost estimates. Package pricing, deployment costs and charges for external services added to graph steps are unknown from this evidence.
The arithmetic examples contain no model calls or token-usage figures from which to estimate AI-provider spending.
rights
The page does not state licensing or redistribution terms for the documentation, package or example code. Those permissions remain unknown from this evidence; consult the applicable licences before redistributing the material.
freshness
The page was captured on 24 November 2026 at 01:19:06 UTC. It mentions a V2 persistence removal but does not identify the exact pydantic-graph release used by its examples or provide a page update date.
Compatibility with a particular installed release and changes after the capture are unknown.
actions
Match the documentation to the package release you intend to use. Start with the counter example, including its asyncio entry point, then adapt the map-and-join example to a small representative workload.
Before adoption, check result ordering, failure handling and shared-state behavior against your requirements. If recovery across crashes matters, investigate the linked persistence and durable-execution options before committing to the graph design.
