Compile structured YAML configurations into production-grade LangGraph multi-agent architectures.
Project description
AgentGraph Compiler ๐ ๏ธ๐ฆ๐
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.
๐ Key Features
- 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.
๐ ๏ธ Quick Start
1. Install
Option A โ PyPI (once published)
pip install agentgraph-compiler
# or
uv add agentgraph-compiler
Option B โ Directly from GitHub (available now, no clone needed)
pip install agentgraph-compiler
Option C โ Clone for local development
git clone https://github.com/cvaws/agentgraph-compiler.git
cd agentgraph-compiler
uv sync
After any install, the forge CLI is available in your environment:
forge --help
2. Initialize a Project
uv run forge init
Creates:
configs/config.yamlโ Global settings (models, vector store, embedding)configs/agents/agent.yamlโ Starter agent workflow spec
3. Configure Environment
cp .env.example .env
# Fill in OPENAI_API_KEY (and optionally LANGCHAIN_API_KEY for tracing)
4. Validate Configuration
uv run forge validate configs/agents/agent.yaml
Runs Pydantic schema validation and checks all edge targets exist as declared nodes โ without writing any files.
5. Compile Agent Topology
# Preview without writing files
uv run forge compile configs/agents/agent.yaml --dry-run
# Compile Python scaffold
uv run forge compile configs/agents/agent.yaml
6. Run the Agent
uv run python my_agent/main.py "How do I build multi-agent graphs with AgentGraph Compiler?"
๐ก Try an Example
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.
๐ CLI Reference
| 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. |
โ๏ธ Global Configuration (configs/config.yaml)
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/"
๐ YAML Reference
Graph Config
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"
Node Types
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."
Chain Config
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."
Edge Types
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: true
Tool Config
tools:
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."
๐ Generated Flowchart
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;
๐ Generated Output Structure
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/
๐ Observability (LangSmith)
Enable full step-by-step tracing in .env:
LANGCHAIN_TRACING_V2=true
LANGCHAIN_API_KEY=your_langchain_api_key
LANGCHAIN_PROJECT=AgentGraph-Compiler-Agents
๐งช Tests
uv run pytest -v
CI runs on every push via .github/workflows/ci.yml.
๐ค Contributing
See CONTRIBUTING.md for dev setup, how to add new edge/node types, and the PR process.
๐ฆ License
Released under the Apache 2.0 License. Version 0.2.5.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file agentgraph_compiler-0.2.5.tar.gz.
File metadata
- Download URL: agentgraph_compiler-0.2.5.tar.gz
- Upload date:
- Size: 34.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.25 {"installer":{"name":"uv","version":"0.11.25","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
02c220e5b67b2a1eb0d0b57eea4acf987520d11731c8f79ef3785e3eda3a9ef8
|
|
| MD5 |
b72e484bccc8a07450f4d5655060a2ba
|
|
| BLAKE2b-256 |
d95ee35750169f998a51c89d88784bda9e61cd7af8f369221f3834fcc8a3df41
|
File details
Details for the file agentgraph_compiler-0.2.5-py3-none-any.whl.
File metadata
- Download URL: agentgraph_compiler-0.2.5-py3-none-any.whl
- Upload date:
- Size: 38.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.25 {"installer":{"name":"uv","version":"0.11.25","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c5a7dc166ba43e958c128fda023225d64134d6e6189e292712f630d897c98b1b
|
|
| MD5 |
51b42d228596460a1bb3e2a33f7ffe55
|
|
| BLAKE2b-256 |
744a9afd2e5e11feeffe1358a9ddb41f188dab3725c4dc5aa7ffb5613e450d4c
|