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

Partial Updates

Return only changes.

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

A node doesn't return the whole state. It returns only the keys it wants to change. LangGraph merges that update into the state, and keeps everything else as it was.

Partial Updates
From the video: Partial Updates
  • Return only changes
  • LangGraph merges
  • Everything else stays

Watching the merge

The first node sets the total. The second sets only the delivery fee. Each node prints the state it receives. Run it. The second node sees the total written by the first, and the final state has every key, even though no node returned them all.

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

class State(TypedDict):
    title: str
    total: float
    delivery: float

def set_total(state):
    print("set_total sees:", state)
    return {"total": 19.98}
def set_delivery(state):
    print("set_delivery sees:", state)
    return {"delivery": 2.99}

b = StateGraph(State)
b.add_sequence([set_total, set_delivery])
b.add_edge(START, "set_total"); b.add_edge("set_delivery", END)
print("final:", b.compile().invoke({"title": "Dune"}))
Output
set_total sees: {'title': 'Dune'}
set_delivery sees: {'title': 'Dune', 'total': 19.98}
final: {'title': 'Dune', 'total': 19.98, 'delivery': 2.99}

Careful with keys

By default, a new value replaces the old one. If a node returns a key that isn't in the state, it's ignored. So a typo like totl instead of total is silently lost. Keep key names consistent, and test your nodes.

keyvalue
Defaultnew value replaces old
Unknown keysignored
Typossilently lost
Sotest your nodes

Summary

Nodes return partial updates, which LangGraph merges into the state. New values replace old ones by default. Next, a quiz on the basics.

Key takeaways
  • Return only changes
  • Merged into state
  • Watch for typos
Next up: Basics Quiz — test yourself