Agent development with LangGraph¶
LangGraph provides both low-level primitives and high-level prebuilt components for building agent-based applications. This section focuses on the prebuilt, reusable components designed to help you construct agentic systems quickly and reliably—without the need to implement orchestration, memory, or human feedback handling from scratch.
What is an agent?¶
An agent consists of three components: a large language model (LLM), a set of tools it can use, and a prompt that provides instructions.
The LLM operates in a loop. In each iteration, it selects a tool to invoke, provides input, receives the result (an observation), and uses that observation to inform the next action. The loop continues until a stopping condition is met — typically when the agent has gathered enough information to respond to the user.
Key features¶
LangGraph includes several capabilities essential for building robust, production-ready agentic systems:
- Memory integration: Native support for short-term (session-based) and long-term (persistent across sessions) memory, enabling stateful behaviors in chatbots and assistants.
- Human-in-the-loop control: Execution can pause indefinitely to await human feedback—unlike websocket-based solutions limited to real-time interaction. This enables asynchronous approval, correction, or intervention at any point in the workflow.
- Streaming support: Real-time streaming of agent state, model tokens, tool outputs, or combined streams.
- Deployment tooling: Includes infrastructure-free deployment tools. LangGraph Platform supports testing, debugging, and deployment.
- Studio: A visual IDE for inspecting and debugging workflows.
- Supports multiple deployment options for production.
High-level building blocks¶
LangGraph comes with a set of prebuilt components that implement common agent behaviors and workflows. These abstractions are built on top of the LangGraph framework, offering a faster path to production while remaining flexible for advanced customization.
Using LangGraph for agent development allows you to focus on your application's logic and behavior, instead of building and maintaining the supporting infrastructure for state, memory, and human feedback.
Package ecosystem¶
The high-level components are organized into several packages, each with a specific focus.
Package | Description | Installation |
---|---|---|
langgraph-prebuilt (part of langgraph ) |
Prebuilt components to create agents | pip install -U langgraph langchain |
langgraph-supervisor |
Tools for building supervisor agents | pip install -U langgraph-supervisor |
langgraph-swarm |
Tools for building a swarm multi-agent system | pip install -U langgraph-swarm |
langchain-mcp-adapters |
Interfaces to MCP servers for tool and resource integration | pip install -U langchain-mcp-adapters |
langmem |
Agent memory management: short-term and long-term | pip install -U langmem |
agentevals |
Utilities to evaluate agent performance | pip install -U agentevals |
Visualize an agent graph¶
Use the following tool to visualize the graph generated by
create_react_agent
and to view an outline of the corresponding code.
It allows you to explore the infrastructure of the agent as defined by the presence of:
tools
: A list of tools (functions, APIs, or other callable objects) that the agent can use to perform tasks.pre_model_hook
: A function that is called before the model is invoked. It can be used to condense messages or perform other preprocessing tasks.post_model_hook
: A function that is called after the model is invoked. It can be used to implement guardrails, human-in-the-loop flows, or other postprocessing tasks.response_format
: A data structure used to constrain the type of the final output, e.g., apydantic
BaseModel
.
Features
Graph
The following code snippet shows how to create the above agent (and underlying graph) with
create_react_agent
: