LangGraph is a state machine where the STATE is made of messages.
Everything that happens in LangGraph is driven by:
state = {
"messages": [BaseMessage, BaseMessage, ...]
}
📌 No messages → No reasoning → No agent
| Component | Role |
|---|---|
| State | Holds conversation (messages) |
| Node | A function that reads & writes messages |
| Edge | Decides which node runs next |
| Messages | Memory + reasoning context |
HumanMessage("Explain RBI guidelines")
➡️ Added to state:
state.messages = [
HumanMessage(...)
]
🧠 This is the trigger
Node receives state
Reads entire message history
Decides what to do next
last_message = state.messages[-1]
📌 Nodes never guess — they read messages.
LLM sees:
[SystemMessage, HumanMessage, AIMessage, ...]
Produces:
AIMessage("Here are RBI guidelines...")
➡️ Appended to state:
state.messages.append(AIMessage)
🧠 State grows, nothing is overwritten
LangGraph checks:
Did AI ask to use a tool?
Did AI finish?
Is more reasoning needed?
Example:
if "search" in AIMessage.tool_calls:
→ Tool Node
else:
→ End
📌 Edges are logic gates, not code magic
Tool executes → returns result:
ToolMessage("Search results...")
➡️ Appended to state:
state.messages.append(ToolMessage)
Now LLM has external knowledge.
LLM now sees:
HumanMessage
AIMessage (tool call)
ToolMessage (result)
Produces refined:
AIMessage("Final structured answer")
🧠 This loop continues until END condition met
HumanMessage
↓
LLM Node → AIMessage
↓
Edge Decision
↓
Tool Node → ToolMessage
↓
LLM Node (again)
↓
Final AIMessage
📌 Messages = Memory + Reasoning + Control
| Reason | Explanation |
|---|---|
| 🧠 Memory | Full conversation preserved |
| 🔍 Explainability | You can replay reasoning |
| 🧩 Modularity | Any node can read messages |
| 🔁 Looping | Agents can think multiple times |
| ⚙️ Determinism | Same messages → same behavior |
In Agentic RAG, messages carry:
User intent
Retrieved documents
Tool outputs
Intermediate reasoning
Final answer
📌 Vector DB results → ToolMessage
📌 RAG context → AIMessage content
“In LangGraph, messages are the state. Nodes read messages, edges route based on messages, and agents reason by appending new messages.”
LangGraph is not a pipeline — it’s a conversation-driven state machine.