Lightweight DAG orchestration framework with enterprise pipeline capabilities
Project description
hexDAG -- Operating System for AI Agents
Just as Linux provides processes, syscalls, drivers, and
/libso programs don't reinvent the wheel, hexDAG provides pipelines, ports, drivers, and a standard library so AI agents don't reinvent orchestration.
hexDAG transforms complex AI workflows into deterministic, testable, and maintainable systems through declarative YAML pipelines and DAG-based execution. It is async-first, type-safe with Pydantic, and built on hexagonal architecture so you can swap any infrastructure dependency without touching business logic.
The OS Analogy
| Linux | hexDAG | Purpose |
|---|---|---|
| Kernel | kernel/ |
Core execution engine, system call interfaces (Protocols), domain models |
| System calls | kernel/ports/ |
Contracts for external capabilities (LLM, Memory, Database, etc.) |
| Drivers | drivers/ |
Low-level infrastructure (executor, observer manager, pipeline spawner) |
/lib |
stdlib/ |
Standard library -- built-in nodes, adapters, macros, system libs |
| Processes | Pipeline runs | Tracked by ProcessRegistry (like ps) |
fork/exec |
PipelineSpawner |
Launch sub-pipelines from within a running pipeline |
| Process scheduler | Scheduler |
Delayed and recurring pipeline execution |
| State machines | EntityState |
Business entity lifecycle management |
/usr/bin |
api/ |
User-facing tools (MCP + Studio REST) |
| Shell | cli/ |
Command-line interface (hexdag init, hexdag lint, etc.) |
Quick Start
Installation
# Install from PyPI
pip install hexdag
# Or with uv (recommended)
uv pip install hexdag
# With optional dependencies
pip install hexdag[openai] # OpenAI adapter
pip install hexdag[anthropic] # Anthropic adapter
pip install hexdag[all] # Everything
Development
git clone https://github.com/omniviser/hexdag.git
cd hexdag
uv sync
Your First Pipeline
Define a workflow in YAML:
# research_agent.yaml
apiVersion: hexdag/v1
kind: Pipeline
metadata:
name: research-workflow
description: AI-powered research assistant
spec:
ports:
llm:
adapter: hexdag.stdlib.adapters.openai.OpenAIAdapter
config:
model: gpt-4
nodes:
- kind: agent_node
metadata:
name: researcher
spec:
initial_prompt_template: "Research the topic: {{topic}}"
max_steps: 5
available_tools: ["web_search", "summarize"]
dependencies: []
- kind: llm_node
metadata:
name: analyst
spec:
prompt_template: |
Analyze the research findings: {{researcher.results}}
Provide actionable insights.
dependencies: [researcher]
- kind: function_node
metadata:
name: formatter
spec:
fn: "myapp.reports.format_report"
input_mapping:
findings: "researcher.results"
insights: "analyst.output"
dependencies: [researcher, analyst]
Run it:
from hexdag import PipelineRunner
runner = PipelineRunner()
result = await runner.run("research_agent.yaml", input_data={"topic": "AI trends 2025"})
With port overrides for testing:
from hexdag import PipelineRunner, MockLLM
runner = PipelineRunner(port_overrides={"llm": MockLLM(responses="Mock analysis result")})
result = await runner.run("research_agent.yaml", input_data={"topic": "AI trends 2025"})
Or validate without executing:
runner = PipelineRunner()
issues = await runner.validate(pipeline_path="research_agent.yaml")
# [] means valid
Architecture
hexdag/
kernel/ -- Core primitives. Protocols, domain models, orchestration. (/kernel)
stdlib/ -- Standard library. Built-in nodes, adapters, macros, libs. (/lib)
drivers/ -- Low-level infrastructure. Executor, observer, spawner. (/drivers)
api/ -- Public API. MCP tools + Studio REST endpoints. (/usr/bin)
cli/ -- CLI commands (hexdag init, hexdag lint, hexdag studio, etc.)
The kernel defines contracts and depends on nothing external. The stdlib ships implementations users interact with directly. Drivers provide low-level infrastructure the orchestrator needs internally. The API exposes everything to users via MCP and REST.
Decision Rules
When adding something new:
- Defines a Protocol or domain model? -->
kernel/ - Implements a Protocol for users to use or extend? -->
stdlib/ - Low-level infrastructure the orchestrator needs internally? -->
drivers/ - User-facing function (MCP tool or REST endpoint)? -->
api/
Uniform Entity Pattern
All framework entities follow one pattern: kernel defines contract, stdlib ships builtins, users write their own.
| Entity | Kernel Contract | Stdlib Builtins | User Custom |
|---|---|---|---|
| Ports | kernel/ports/llm.py |
-- | myapp.ports.X |
| Adapters | Protocol in kernel/ports/ |
stdlib/adapters/openai/ |
myapp.adapters.X |
| Nodes | NodeSpec + BaseNodeFactory |
LLMNode, AgentNode, FunctionNode |
myapp.nodes.X |
| Macros | (convention) | ReasoningAgent, ConversationAgent |
myapp.macros.X |
| Prompts | (convention) | tool_prompts, error_correction |
myapp.prompts.X |
| Libs | HexDAGLib base class |
ProcessRegistry, EntityState, Scheduler |
myapp.lib.X |
Components are referenced by full Python module path in YAML:
nodes:
- kind: hexdag.stdlib.nodes.LLMNode # Full path
- kind: llm_node # Built-in alias
- kind: myapp.nodes.CustomNode # User custom
System Libraries (Libs)
Libs are system-level capabilities for multi-pipeline coordination. Every public async
method on a HexDAGLib subclass auto-becomes an agent-callable tool.
| Lib | Linux Analogy | Purpose |
|---|---|---|
| ProcessRegistry | ps |
Track pipeline runs -- status, duration, results, parent/child relationships |
| EntityState | State machines | Declarative state machines for business entities with validated transitions and audit trails |
| Scheduler | cron / at |
Delayed and recurring pipeline execution via asyncio timers |
| DatabaseTools | sqlite3 CLI |
Agent-callable SQL query tools wrapping any SupportsQuery adapter |
from hexdag.kernel.lib_base import HexDAGLib
from hexdag.kernel.ports.data_store import SupportsKeyValue
class OrderManager(HexDAGLib):
def __init__(self, store: SupportsKeyValue) -> None:
self._store = store
async def acreate_order(self, customer_id: str, items: list[dict]) -> str:
"""Create a new order. Auto-exposed as agent tool."""
...
async def aget_order(self, order_id: str) -> dict:
"""Get order by ID. Auto-exposed as agent tool."""
...
Key Features
YAML-First Pipelines
Declarative workflows versioned in git. Environment-specific configs for dev/staging/prod.
Jinja2 templating, !include tags for modular composition, and automatic field mapping
between nodes.
Pipeline Linting
Static analysis for YAML pipelines: cycle detection, hardcoded secret scanning, missing timeout/retry warnings, naming conventions, and unused output detection.
hexdag lint my_pipeline.yaml
Macro System
Reusable pipeline templates that expand into full DAG subgraphs at build time.
Built-in macros: ReasoningAgent, ConversationAgent, LLMMacro, ToolMacro.
Event-Driven Observability
Comprehensive event system (PipelineStarted, NodeCompleted, NodeFailed, etc.)
with pluggable observers for logging, cost profiling, and custom monitoring.
Hexagonal Architecture (Ports & Adapters)
Swap OpenAI for Anthropic, PostgreSQL for SQLite, or any adapter -- with one config line. Business logic stays pure. Test everything with mock adapters.
Pydantic Validation Everywhere
Type safety at every layer. Automatic schema compatibility checking between connected nodes. Runtime type coercion and validation.
MCP Server
hexDAG includes a built-in Model Context Protocol server that exposes pipeline building capabilities to Claude Code, Cursor, and other LLM-powered editors:
# Install MCP dependencies
uv sync --extra mcp
# Configure in Claude Desktop
{
"mcpServers": {
"hexdag": {
"command": "uv",
"args": ["run", "python", "-m", "hexdag", "--mcp"]
}
}
}
The MCP server provides tools to:
- List available nodes, adapters, tools, and macros from your registry
- Build and validate YAML pipelines interactively
- Get component schemas and documentation
- Manage processes (spawn, schedule, track pipeline runs)
- Auto-discover custom plugins from
HEXDAG_PLUGIN_PATHS
Custom Plugin Discovery
hexDAG supports three levels of component discovery:
- Builtin -- Core adapters and nodes from
hexdag.stdlib - Plugins -- Community plugins from the
hexdag_pluginsnamespace - User-authored -- Your custom components via
HEXDAG_PLUGIN_PATHS
export HEXDAG_PLUGIN_PATHS="./my_adapters:./my_nodes"
CLI
| Command | Purpose |
|---|---|
hexdag init |
Initialize a new hexDAG project |
hexdag pipeline validate |
Validate a YAML pipeline |
hexdag pipeline execute |
Execute a pipeline |
hexdag lint |
Lint YAML for best practices and security |
hexdag create |
Create pipeline templates from schemas |
hexdag build |
Build Docker containers for pipelines |
hexdag studio |
Launch the visual pipeline editor |
hexdag plugins |
Manage plugins and adapters |
hexdag docs |
Generate and serve documentation |
Documentation & Learning
Interactive Notebooks
| Notebook | Topic | Time |
|---|---|---|
| 01. Introduction | Your first pipeline | 15 min |
| 02. YAML Pipelines | Declarative workflows | 25 min |
| 03. Practical Workflow | Real-world patterns | 30 min |
| 06. Dynamic Reasoning Agent | Advanced agent patterns | -- |
| YAML Includes & Composition | Modular pipeline composition | -- |
Docs
- Architecture -- System architecture and the four layers
- Philosophy & Design -- Six pillars and design principles
- Hexagonal Architecture -- Ports and adapters explained
- Implementation Guide -- Production-ready workflows
- Plugin System -- Custom component development
- CLI Reference -- Complete CLI documentation
- Roadmap -- Planned kernel extensions (EventBus, LockPort, CentralAgent)
Examples
- MCP Research Agent -- Deep research agent with environment configs
- Demo: Startup Pitch -- Live demo with rich terminal UI
Development
# Setup
uv sync
uv run pre-commit install
# Test
uv run pytest
uv run pytest --cov=hexdag --cov-report=term-missing
# Code quality
uv run ruff check hexdag/ --fix
uv run pyright ./hexdag
uv run pre-commit run --all-files
The Six Pillars
- Async-First Architecture -- Non-blocking execution for maximum performance
- Event-Driven Observability -- Real-time monitoring via comprehensive event system
- Pydantic Validation Everywhere -- Type safety at every layer
- Hexagonal Architecture -- Clean separation of business logic and infrastructure
- Composable Declarative Files -- Complex workflows from simple YAML components
- DAG-Based Orchestration -- Intelligent dependency management and parallelization
License
Apache License 2.0 -- see LICENSE for details.
Built for the AI community by the hexDAG team.
Project details
Release history Release notifications | RSS feed
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 hexdag-0.7.0.dev1.tar.gz.
File metadata
- Download URL: hexdag-0.7.0.dev1.tar.gz
- Upload date:
- Size: 517.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b90144a78e2124ad2e76044d8a482bba3279a8f625cd31af3bd5aea2719b1201
|
|
| MD5 |
b396a5535b0624efda5a9c3b5cba807c
|
|
| BLAKE2b-256 |
bcb1ee0a0156e8d0c9f492b98d5165f05433ccc7536f6dd13a18406838501dee
|
Provenance
The following attestation bundles were made for hexdag-0.7.0.dev1.tar.gz:
Publisher:
release.yml on omniviser/hexDAG
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
hexdag-0.7.0.dev1.tar.gz -
Subject digest:
b90144a78e2124ad2e76044d8a482bba3279a8f625cd31af3bd5aea2719b1201 - Sigstore transparency entry: 976344091
- Sigstore integration time:
-
Permalink:
omniviser/hexDAG@88ebaddbf3014f0eaa8e5b4f4d6b8d08f936c0d2 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/omniviser
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@88ebaddbf3014f0eaa8e5b4f4d6b8d08f936c0d2 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file hexdag-0.7.0.dev1-py3-none-any.whl.
File metadata
- Download URL: hexdag-0.7.0.dev1-py3-none-any.whl
- Upload date:
- Size: 677.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8b8ab5fd8ef92e105956adab79207b0c26030b9b5bb69d75316bc2f8fd2a0481
|
|
| MD5 |
fed71c01389d85ae40dd5261812682fb
|
|
| BLAKE2b-256 |
c72e23810320855498c6922559214fee00ae61d1e1478920c8e6089ba646f8d3
|
Provenance
The following attestation bundles were made for hexdag-0.7.0.dev1-py3-none-any.whl:
Publisher:
release.yml on omniviser/hexDAG
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
hexdag-0.7.0.dev1-py3-none-any.whl -
Subject digest:
8b8ab5fd8ef92e105956adab79207b0c26030b9b5bb69d75316bc2f8fd2a0481 - Sigstore transparency entry: 976344093
- Sigstore integration time:
-
Permalink:
omniviser/hexDAG@88ebaddbf3014f0eaa8e5b4f4d6b8d08f936c0d2 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/omniviser
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@88ebaddbf3014f0eaa8e5b4f4d6b8d08f936c0d2 -
Trigger Event:
workflow_dispatch
-
Statement type: