LangGraph
How to Visualize LangGraph Agent Graphs
LangGraph is a state machine-based agent orchestration library from LangChain that lets you model complex agent behavior as a directed graph of nodes and conditional edges. When your state machine grows to include multiple routing conditions and feedback loops, reasoning about it from code alone becomes difficult. Using AgentLens as your LangGraph diagram tool lets you convert your graph definition to YAML and explore the full topology interactively — including conditional edges, re-routing loops, and model assignments across nodes.
What You'll Need
- AgentLens — free, no login required, runs entirely in your browser
- Your LangGraph YAML config — or use the example below to try it out immediately
Step 1 — Write Your LangGraph YAML
AgentLens uses a straightforward YAML schema. A workflow file has two top-level keys: agents and routes. In LangGraph terms, agents map to nodes and routes map to edges.
Each agent requires an id (no spaces) and a name. Optionally set a model (common values: opus, sonnet, haiku) and a list of tools. Each route requires an id, source, target, and a labeldescribing the transition. The optional condition field maps directly to LangGraph's conditional edge logic.
Here is a complete example modelling a LangGraph RAG pipeline with a relevance-grading loop:
version: "1.0.0"
name: "LangGraph State Machine"
agents:
- id: entry_node
name: "Entry Node"
model: sonnet
description: "Initial state processing and routing"
- id: researcher
name: "Researcher Node"
model: opus
tools: [TavilySearch, WebLoader]
description: "Performs research based on the query"
- id: grader
name: "Relevance Grader"
model: haiku
description: "Grades document relevance and decides next step"
- id: generator
name: "Answer Generator"
model: opus
tools: [LLMChain]
description: "Generates the final answer from relevant docs"
routes:
- id: r1
source: entry_node
target: researcher
label: "Route to research"
- id: r2
source: researcher
target: grader
label: "Documents retrieved"
- id: r3
source: grader
target: generator
label: "Relevant docs"
condition: "relevance_score > 0.7"
- id: r4
source: grader
target: researcher
label: "Re-search"
condition: "relevance_score <= 0.7"Step 2 — Paste into AgentLens
Open AgentLens by clicking the button below. Paste your YAML into the left panel and the graph updates on the right within 150 ms. The ELK layout engine automatically positions nodes so that edges do not overlap, making even complex state machines easy to follow.
Step 3 — Read the Graph
Each box corresponds to a node (agent) in your LangGraph graph. Directed arrows represent routes, with the label shown on each edge. Routes that include a condition display the condition expression, making branching logic immediately visible. Node color indicates the assigned model — useful for spotting which nodes invoke the most capable models. Click any node to open the inspector and view the full configuration.