Concept Intermediate · 3 min read

What is a LangGraph node

Quick answer
A LangGraph node is a function or unit within a StateGraph that processes input state and returns an updated state, enabling stateful, graph-based AI workflows. Nodes represent discrete steps or actions in the graph, connected by edges to define the flow of data and control.
LangGraph node is a functional unit in a StateGraph that processes and transforms state data to drive AI agent workflows.

How it works

A LangGraph node acts like a processing step in a directed graph where each node receives a state dictionary, performs computations or transformations, and returns a new state. The StateGraph manages these nodes and their connections (edges), defining the flow of data and control between them. This design enables complex, stateful AI agents that can maintain context and branch logic dynamically, similar to nodes in a workflow or data pipeline.

Concrete example

Here is a minimal example defining a LangGraph node that appends a response to a message list in the state, then compiles and invokes the graph:

python
from langgraph.graph import StateGraph, END
from typing import TypedDict

class State(TypedDict):
    messages: list

def my_node(state: State) -> State:
    return {"messages": state["messages"] + ["response from node"]}

graph = StateGraph(State)
graph.add_node("my_node", my_node)
graph.set_entry_point("my_node")
graph.add_edge("my_node", END)

app = graph.compile()
result = app.invoke({"messages": ["Hello"]})
print(result["messages"])
output
['Hello', 'response from node']

When to use it

Use LangGraph nodes when building AI agents or workflows that require explicit state management, branching logic, or modular, composable steps. They are ideal for complex multi-step reasoning, tool use, or orchestrating multiple AI calls with persistent context. Avoid if your task is a simple one-shot prompt without state or flow control.

Key terms

TermDefinition
LangGraph nodeA function that takes and returns state, representing a step in a StateGraph.
StateGraphA graph structure managing nodes and edges to define AI agent workflows.
StateA typed dictionary holding data passed between nodes.
ENDA special terminal node indicating graph completion.

Key Takeaways

  • LangGraph nodes are stateful functions that transform input state to output state within a graph.
  • Nodes connect via edges in a StateGraph to define complex AI workflows with branching and persistence.
  • Use nodes to modularize AI agent logic, enabling maintainable and composable multi-step processes.
  • Nodes receive and return typed state dictionaries, ensuring structured data flow.
  • Avoid LangGraph if your use case does not require stateful or graph-based orchestration.
Verified 2026-04
Verify ↗