These examples demonstrate the same patterns from PicoAgents implemented using LangGraph. LangGraph is LangChain's framework for building stateful, multi-actor applications with LLMs, using a graph-based approach.
# Install LangGraph
pip install langgraph langchain-openai python-dotenv
# Option 1: Azure OpenAI (used in examples)
export AZURE_OPENAI_ENDPOINT="https://your-endpoint.openai.azure.com/"
export AZURE_OPENAI_API_KEY="your-key"
# Option 2: OpenAI directly
export OPENAI_API_KEY="your-api-key"| Example | PicoAgents Equivalent | Description |
|---|---|---|
agents/basic_agent.py |
agents/basic-agent.py |
ReAct agent with weather and calculator |
agents/memory.py |
agents/memory.py |
Checkpointer-based conversation memory |
agents/structured_output.py |
agents/structured-output.py |
Pydantic model responses |
| Example | PicoAgents Equivalent | Description |
|---|---|---|
workflows/sequential.py |
workflows/sequential.py |
Sequential node pipeline |
| Example | PicoAgents Equivalent | Description |
|---|---|---|
orchestration/round_robin.py |
orchestration/round-robin.py |
Cyclic graph for agent turns |
orchestration/supervisor.py |
orchestration/supervisor.py |
Supervisor-controlled delegation |
- Graph-centric: Everything is nodes and edges in a StateGraph
- Channels & Reducers: State is managed through typed channels with reducers
- Checkpointing: Memory is handled via checkpointers (MemorySaver, SQLite, etc.)
- Conditional routing: Edges can be conditional based on state
- Built-in ReAct:
create_react_agentprovides tool-calling agents
# From the examples/frameworks/langgraph directory
python agents/basic_agent.py
python workflows/sequential.py
python orchestration/round_robin.pyExamples use Azure OpenAI with gpt-4.1-mini via AzureChatOpenAI. To use OpenAI directly instead, change the import and client:
# Azure OpenAI (current)
from langchain_openai import AzureChatOpenAI
llm = AzureChatOpenAI(azure_deployment="gpt-4.1-mini", ...)
# OpenAI directly
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(model="gpt-4o-mini", ...)Compatible models:
gpt-4o-mini/gpt-4.1-mini- Fast, cost-effectivegpt-4o- More capable for complex tasks- Any LangChain-compatible model (Anthropic, Google, etc.)