Compile structured YAML configurations into productionβgrade LangGraph multiβagent architectures.
AgentGraph Compiler eliminates LangGraph boilerplate by letting you declare your agent topology in YAML. Define nodes, chains, tools, edges, subβagents, and supervisors β the compiler scaffolds a complete, modular, runnable Python codebase ready for production.
π Full Developer Wiki β β complete reference for every YAML field, node type, edge type, and generated output.
- Declarative MultiβAgent Workflows β Define the full agent graph (nodes, edges, subβagents, supervisor routing) in simple YAML.
- TypedDict State (LangGraphβnative) β Generates
TypedDictclasses withAnnotated[..., add_messages]reducers by default. PydanticBaseModelis available viastate_type: pydantic. - Supervisor Orchestration β
type: supervisornodes generate an LLM-driven routing scaffold with configurableroute_fieldand compile-time validation. - Hierarchical Parent-Scoped Output β Sub-agent code is generated inside subdirectories under the parent
source_dir(e.g.my_agent/adaptive_rag/). - All LangGraph Edge Types β
standard,conditional,supervisor_route,tool_loop,fan_out(Send API), andinterrupt_beforehumanβinβtheβloop. - Parallel Fan-Out via
SendAPI βtype: fan_outdispatches one node to multiple inputs simultaneously usinglanggraph.types.Send. - Async Node Scaffolding β
async_fn: truegeneratesasync defnode functions with notes on awaiting LLM/tool calls. - Multi-Model LLM Support β
provider: openai | anthropic | ollama | groqper chain or supervisor node with model-specific imports scaffolded. - MCP Tool Client Stubs β
source: mcpin thetoolsblock scaffolds a Model Context Protocol client. - Checkpointing β
memory.type: sqlite | in_memorywiresSqliteSaver/MemorySaverintoworkflow.compile(). - Real-time Streaming β Generated
main.pyusesapp.stream()with thread config for node-by-node event output. - Mermaid Flowcharts β Auto-generates
flowchart.mdwith nested subgraph rendering and distinct supervisor styling. - CLI β
forge compile,forge validate,forge init,forge ingest, plus--dry-runpreview.
Option A β PyPI (once published)
pip install agentgraph-compiler
# or
uv add agentgraph-compilerOption B β Directly from GitHub (available now, no clone needed)
pip install agentgraph-compilerOption C β Clone for local development
git clone https://github.com/cvaws/agentgraph-compiler.git
cd agentgraph-compiler
uv syncAfter any install, the forge CLI is available in your environment:
forge --helpuv run forge initCreates:
configs/config.yamlβ Global settings (models, vector store, embedding)configs/agents/agent.yamlβ Starter agent workflow spec
cp .env.example .env
# Fill in OPENAI_API_KEY (and optionally LANGCHAIN_API_KEY for tracing)uv run forge validate configs/agents/agent.yamlRuns Pydantic schema validation and checks all edge targets exist as declared nodes β without writing any files.
# Preview without writing files
uv run forge compile configs/agents/agent.yaml --dry-run
# Compile Python scaffold
uv run forge compile configs/agents/agent.yamluv run python my_agent/main.py "How do I build multi-agent graphs with AgentGraph Compiler?"Six ready-to-compile examples cover every supported LangGraph pattern β all configs live in configs/agents/examples/:
| Example | Pattern |
|---|---|
simple_rag/ |
Single-agent RAG with conditional edges |
multi_agent/ |
Supervisor + 2 sub-agents via graphRef |
react_agent/ |
ReAct tool_loop + MCP tool client |
parallel_fanout/ |
Parallel fan_out via Send API |
human_in_loop/ |
interrupt_before + approve/revise cycle |
async_agent/ |
async_fn: true async nodes |
# Example: compile and run the ReAct agent
uv run forge compile configs/agents/examples/react_agent/agent.yaml
uv run python react_agent/main.py "What is the current price of Bitcoin?"See configs/agents/examples/README.md for compile/run instructions for all examples.
| Command | Usage | Description |
|---|---|---|
compile |
forge compile <path> [--dry-run] |
Compiles YAML into Python scaffolds under source_dir. |
validate |
forge validate <path> |
Schema validation + edge target reference checks. |
init |
forge init [directory] |
Scaffolds starter configs/config.yaml and agent.yaml. |
ingest |
forge ingest [--config path] |
Ingests URLs from config.yaml into Qdrant vector store. |
Centralize model providers, vector store settings, and ingestion URLs:
models:
chat:
name: gpt-4o
temperature: 0.5
embedding:
name: text-embedding-3-small
provider: openai
vector_store:
name: qdrant
url: "http://localhost:6333"
collection: "agent"
ingestion:
urls:
- "https://lilianweng.github.io/posts/2023-06-23-agent/"version: "1.0"
graph:
source_dir: "my_agent" # Output directory for scaffolded Python code
state_type: typeddict # "typeddict" (default, LangGraph-native) | "pydantic"
state_schema: "graphs.state.AgentState"
state_fields:
messages: "List[BaseMessage]" # β Annotated[List[BaseMessage], add_messages]
next: "str" # Supervisor routing field
context: "dict"
shared_fields: [messages, context] # Fields readable/writable by sub-agents
memory:
type: sqlite # "sqlite" | "in_memory" | omit for stateless
db_path: ".checkpoints/agent.db"nodes:
# Standard node β calls a Python function
my_node:
module: "graphs.nodes.my_node"
function: "my_node"
chains: ["my_chain"] # Chains to import into the node
description: "Does something useful."
# Async node
async_node:
module: "graphs.nodes.async_node"
async_fn: true # Scaffolds `async def async_node(state)`
# Supervisor node β LLM-driven router
supervisor:
type: supervisor
provider: openai # openai | anthropic | ollama | groq
llm: gpt-4o
route_field: next # State field the supervisor writes to (default: "next")
system_prompt: "templates/supervisor.prompt"
routes_to: [rag_agent, code_agent]
# Sub-agent reference β compiles recursively, nested under parent source_dir
rag_agent:
graphRef: "sub-agents/adaptive-rag.yaml"
description: "Adaptive RAG sub-agent."chains:
retrieval_grader:
module: "graphs.chains.retrieval_grader"
runnable: "retrieval_grader"
provider: anthropic # Per-chain provider
llm: claude-3-5-haiku-20241022
temperature: 0.0
prompt: "retrieval_grader" # Loads templates/retrieval_grader.prompt
tools: [web_search] # Binds tool imports into chain scaffold
description: "Binary relevance grader."edges:
# Standard directed edge
- type: standard
start: retrieve
end: grade_documents
# Conditional edge with a router function
- type: conditional
start: grade_documents
router:
module: "routers.router"
function: "route_after_grading"
mappings:
web_search: web_search
generate: generate
# Supervisor routing β dispatches based on state[route_field]
- type: supervisor_route
start: supervisor
routes_to: [rag_agent, code_agent]
end: post_process
# Tool loop β LLM node β ToolNode
- type: tool_loop
start: llm_node
tool_node: tools
end: END
# Fan-out β parallel dispatch via Send API
- type: fan_out
start: coordinator
target: worker # Node to fan out to (runs in parallel)
field: tasks # State field (iterable) to fan out over
key: task # Key name in each Send payload
end: aggregator
# Human-in-the-loop β pause before this node
- type: standard
start: generate
end: human_review
interrupt_before: truetools:
web_search:
module: "graphs.tools.web_search"
function: "web_search"
description: "Queries Tavily for web results."
# MCP Tool Client stub
my_mcp_tool:
module: "graphs.tools.my_mcp_tool"
function: "my_mcp_tool"
source: mcp
server_url: "http://localhost:8000/mcp"
description: "Calls remote MCP server."AgentGraph Compiler auto-generates flowchart.md for every compiled agent:
flowchart TD
START([START]) --> supervisor{{"Supervisor: supervisor\n(Routes request to sub-agent)"}}
supervisor -.->|rag_agent| rag_agent__START
supervisor -.->|code_agent| code_agent__START
subgraph rag_agent ["rag_agent (Adaptive RAG Sub-Agent)"]
direction TB
rag_agent__START --> retrieve["retrieve\n(Pulls document chunks from vector store)"]
retrieve --> grade_documents["grade_documents"]
grade_documents --> generate["generate"]
end
subgraph code_agent ["code_agent (Code Generator Sub-Agent)"]
direction TB
code_agent__START --> plan["plan\n(Breaks task into plan)"]
plan --> write_code["write_code"]
end
rag_agent__END --> post_process["post_process\n(Formats final response)"]
code_agent__END --> post_process
post_process --> END([END])
classDef supervisorStyle fill:#d35400,stroke:#fff,stroke-width:2px,color:#fff;
class supervisor supervisorStyle;
classDef nodeStyle fill:#2980b9,stroke:#fff,stroke-width:2px,color:#fff;
class post_process nodeStyle;
forge compile configs/agents/agent.yaml scaffolds the full hierarchy under source_dir:
my_agent/ β Parent source_dir
βββ flowchart.md β Mermaid diagram of the multi-agent DAG
βββ main.py β Runnable entrypoint with app.stream()
βββ graphs/
β βββ __init__.py
β βββ graph.py β Compiled StateGraph + checkpointer
β βββ state.py β TypedDict AgentState with add_messages reducer
β βββ chains/
β β βββ post_process_chain.py
β βββ nodes/
β βββ supervisor.py β LLM routing scaffold
β βββ post_process.py
β
βββ adaptive_rag/ β Sub-agent nested under my_agent/
β βββ graphs/
β β βββ graph.py
β β βββ state.py
β β βββ nodes/
β βββ routers/
β
βββ code_agent/ β Sub-agent nested under my_agent/
βββ graphs/
βββ routers/
Enable full step-by-step tracing in .env:
LANGCHAIN_TRACING_V2=true
LANGCHAIN_API_KEY=your_langchain_api_key
LANGCHAIN_PROJECT=AgentGraph-Compiler-Agentsuv run pytest -vCI runs on every push via .github/workflows/ci.yml.
See CONTRIBUTING.md for dev setup, how to add new edge/node types, and the PR process.
Released under the Apache 2.0 License. Version 0.2.5.