AI Hints
Home›LangGraph Tutorial›Pipelines and Updates
LangGraph · Lesson 10 of 120

A Pipeline

Nodes in a row.

⏱ 2 min read▶ Video at 9:34🎓 Free
Watch this lesson in the LangGraph courseWatch on YouTube ↗Full LangGraph course

The simplest useful graph is a pipeline. Steps in a row, each doing one job. Let's process a customer's order. Clean the input, work out the price, then write a receipt.

A Pipeline
From the video: A Pipeline
  • Steps in a row
  • One job each
  • Process an order

An order pipeline

Clean tidies the title. Price looks it up in a small price list, and multiplies by the quantity. Receipt writes a line for the customer. Add sequence adds all three nodes, with edges between them, in order. Run it. A messy title goes in, and a tidy receipt comes out.

pipeline.pypython
from typing import TypedDict
from langgraph.graph import StateGraph, START, END

PRICES = {"Dune": 9.99, "Circe": 10.99}

class Order(TypedDict):
    title: str
    quantity: int
    total: float
    receipt: str

def clean(s):   return {"title": s["title"].strip().title()}
def price(s):   return {"total": round(PRICES[s["title"]] * s["quantity"], 2)}
def receipt(s): return {"receipt": f"{s['quantity']} x {s['title']} = £{s['total']}"}

b = StateGraph(Order)
b.add_sequence([clean, price, receipt])
b.add_edge(START, "clean"); b.add_edge("receipt", END)
print(b.compile().invoke({"title": "  dune ", "quantity": 2})["receipt"])
Output
2 x Dune = £19.98

Why split into nodes?

You could do this in one function. But separate nodes are easier to test, and to change. You can add a step in the middle, like a discount, by changing two edges. And later, each step can be streamed, traced, or retried on its own.

keyvalue
Testeach step alone
Changeadd steps easily
Streamsee progress
Retryone step at a time

Summary

A pipeline is nodes in a row, each with one job, and add sequence builds one quickly. Splitting work into nodes makes it easy to test and change. Next, how updates combine with the state.

Key takeaways
  • One job per node
  • add_sequence
  • Easy to extend
Next up: Partial Updates — return only changes