Skip to main content

LangGraph Examples

LangGraph is a library for building stateful, multi-step AI agents as graphs of computation. AgentVisor™ integrates natively with LangGraph, providing durable execution via Temporal, policy-enforced HTTP proxying, and seamless checkpointing — so your graph-based agents run safely without changes to your application code.

Prerequisites​

  • Ollama (or another LLM endpoint) — most examples use ollama via Docker Compose
  • Temporal — required for durable execution and checkpointing
  • AgentVisor CLI — agentvisor serve . starts the runtime
  • jq — used by the examples below to pretty-print API responses

The included compose.yml in each template starts both Ollama and Temporal locally.

Examples​

Work through these in order to build from fundamentals to expert patterns:

StepExampleDifficultyKey Feature
1Chatbot AgentBasicadd_messages, checkpointing, HTTP proxy
2QA AgentIntermediatebind_tools(), ReAct pattern, tool policies
3Task AgentIntermediateinterrupt(), human-in-the-loop, durable approval
4MCP AgentIntermediateMCP Gateway, dynamic tool discovery
5Tracing AgentIntermediateOpenLLMetry, manual spans, Jaeger, agent span forwarding
6Research AgentAdvancedFine-grained HTTP policies, internal network blocking
7Coordinator AgentExpertMulti-agent orchestration, sub-agent policies
8Pentest AgentExpertgVisor shell execution, credential substitution, agentvisor build

How It Works​

LangGraph agents in AgentVisor work through the LangGraph framework provider:

  1. Discovery: AgentVisor detects langgraph.json and selects the LangGraph provider automatically — checked first, ahead of every other framework's discovery file
  2. Schema extraction: Graph schemas are extracted via a three-tier fallback — a build-time cache, then dynamic extraction, then graph names only from langgraph.json
  3. Execution: python3 -m agentvisor.langgraph.runner loads and invokes your compiled graph inside the sandbox
  4. Checkpointing: AgentVisorCheckpointer is a drop-in BaseCheckpointSaver that stores graph state in Temporal automatically

Key Concepts​

ConceptWhat It IsWhere You'll See It
StateGraphLangGraph class for defining agent flow as a directed graphAll examples
add_messagesAnnotation that automatically accumulates conversation history in stateChatbot, QA, Task
bind_tools()Attaches tool definitions to an LLM so it can call themQA, Research, Coordinator
interrupt()Pauses graph execution and waits for human input via the Thread APITask Agent
langgraph.jsonConfig file AgentVisor reads to discover your graph entry pointsAll examples
AgentVisorCheckpointerDrop-in BaseCheckpointSaver that stores state in TemporalChatbot, QA, Task, Coordinator

Quick Start​

# Scaffold any example from a template
agentvisor template create langgraph/chatbot-agent
cd chatbot-agent

# Start Temporal and Ollama
docker compose up -d

# Run the agent
agentvisor serve .

Then open http://localhost:8090/swagger-ui/ to explore the API.

See Also​