In this tutorial, you’ll build a simple agent that can respond to messages and maintain state. This is the foundation for understanding how LangGraph works.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/langchain-ai/langgraph/llms.txt
Use this file to discover all available pages before exploring further.
What you’ll build
A basic agent that:- Processes user input
- Maintains conversation state
- Returns responses
- Uses LangGraph’s state management
Prerequisites
Install LangGraph:Tutorial
Define the state
First, define the state structure for your agent. The state holds all the information that flows through your graph.The
AgentState will track:text: The current message textcount: Number of times the agent has processed messages
Create node functions
Nodes are functions that process the state. Each node receives the current state and returns updates.Each function:
- Takes
stateas input - Returns a dictionary with state updates
- Can access any field from the state
Build the graph
Now create the graph by adding nodes and defining edges between them.The graph flow:
- START → process: Begin with processing
- process → respond: Generate response
- respond → END: Finish execution
Run the agent
Execute your agent with different inputs.Each invocation:
- Starts with fresh state
- Flows through all nodes
- Returns final state
Expected output
When you run the complete example, you should see:Key concepts
- State: A TypedDict that holds all data flowing through the graph
- Nodes: Functions that process state and return updates
- Edges: Connections that define execution flow
- Graph: The compiled workflow that orchestrates everything
Next steps
Build a Chatbot
Add conversation memory and message handling
Tool Calling
Give your agent the ability to use tools
This simple agent demonstrates the core concepts of LangGraph. All more complex agents build on these same principles.