Agentic AI Compiler Framework — AI workflow pre-compilation and highly controllable scheduling execution engine
Project description
AACF - Agentic AI Compiler Framework
A Python framework for building LLM-driven agent pipelines through decorators, dependency analysis, and DAG-based scheduling.
What It Does
You declare AI nodes with a decorator. AACF handles prompt construction, LLM calls, dependency analysis, and execution scheduling.
from aacf import AACF, LLMConfig
app = AACF(__name__, config=LLMConfig(
model="qwen2.5-7b-instruct",
url="http://127.0.0.1:8080/v1/chat/completions",
))
@app.node("translate").who("Translator").what("Translate Chinese to English")
def translate(text: str):
pass
print(translate(text="Hello World"))
# -> Hello World
Core Ideas
Five-tuple DSL. Reduce prompts to who / where / what / why / how. Each AI node is an atomic function with a clear role.
Human-controlled flow. LLMs act as classifiers within nodes, not as controllers. Developers use native Python (if/elif/for) to direct data flow.
Precompilation. Before execution, AACF analyzes parameter names, infers dependencies, builds a DAG, and generates a topological execution plan.
Atomic execution nodes. Each node is independently schedulable, retryable, and cacheable. Failed nodes retry with configurable backoff.
Rust-style errors. ExecutionResult makes error handling explicit and mandatory. No silent failures.
OpenAI-compatible. Switch between cloud APIs and local models by changing a URL. No code changes.
Explicit code override. Function body is pass -> framework calls LLM. Function body has code -> your code runs. Switch back to pass anytime.
Quick Start
pip install aacf
agents.py -- Define nodes:
from aacf import AACF, LLMConfig
app = AACF(__name__, config=LLMConfig(
model="qwen2.5-7b-instruct",
url="http://127.0.0.1:8080/v1/chat/completions",
language="en", # "zh" or "en"
))
@app.node("title_generator").who("Title Writer").what("Generate 3 article titles for a topic").stream(True)
def title_generator(topic: str):
pass
@app.node("article_writer").who("Article Writer").what("Write a 200-word article from a title")
def article_writer(title: str):
pass
@app.node("content_router").who("Content Director").what("Route requests to the right node").module([title_generator, article_writer])
def content_router(user_req: str):
pass
main.py -- Call them:
from agents import title_generator, article_writer, content_router
# Streaming
for chunk in title_generator(topic="AI in daily life"):
print(chunk, end="", flush=True)
# Regular call
print(article_writer(title="When AI learned to cook"))
# Smart routing -- auto-dispatches to the best node
print(content_router(user_req="Write me an article about quantum computing"))
Precompilation
AACF analyzes node dependencies before execution:
app.compile() # Build DAG and execution plan
app.get_execution_order() # -> ["title_generator", "article_writer", ...]
app.get_parallel_groups() # -> [["title_generator"], ["article_writer"], ...]
app.get_dependency_graph() # -> {"article_writer": {"title_generator"}, ...}
Dependency inference works by matching parameter names to node names. If article_writer(title) has a parameter title and there is a node called title_generator, the dependency is inferred when names align.
Features
Streaming Output
@app.node("writer").who("Writer").what("Write a short story").stream(True)
def writer(topic: str):
pass
for chunk in writer(topic="Cyberpunk city"):
print(chunk, end="", flush=True)
Structured JSON
@app.node("extractor").who("Data Extractor").what("Extract person info").format("json")
def extractor(text: str):
pass
import json
data = json.loads(extractor(text="Li Lei, 28, engineer"))
Explicit Code Override
@app.node("calculator").who("Calculator").what("Calculate result")
def calculator(expression: str):
# Your code runs instead of the default LLM call
return str(eval(expression))
Error Handling
from aacf import PipelineError
try:
results = app.run_pipeline(inputs={...})
except PipelineError as e:
print(f"Pipeline failed: {e}")
DAG Visualization
from aacf import DAGVisualizer
visualizer = DAGVisualizer(app)
visualizer.generate_html("dag.html") # Interactive HTML
Caching
@app.node("analyzer").who("Analyzer").what("Analyze text").cache(ttl=300)
def analyzer(text: str):
pass
CLI
aacf init my_project # Initialize project (creates venv + installs aacf)
aacf init my_project --no-venv # Initialize project (skip venv, instant)
aacf run main.py # Run script
aacf sync . # Inject docstrings into source
aacf watch . # Watch and auto-inject
aacf doc aacf --port 8080 # API doc server
MCP Server
AACF provides an MCP (Model Context Protocol) server for AI-assisted development. AI clients like Claude Desktop can use AACF tools to help you build and manage projects.
# Install with MCP support
pip install aacf[mcp]
# Start MCP server (stdio mode)
aacf-mcp
Client Configuration
Qoder (.qoder/mcp.json):
{
"mcpServers": {
"aacf": {
"command": "python",
"args": ["-m", "aacf_mcp"]
}
}
}
Claude Desktop (claude_desktop_config.json):
{
"mcpServers": {
"aacf": {
"command": "python",
"args": ["-m", "aacf_mcp"]
}
}
}
Use
python -m aacf_mcpinstead ofaacf-mcpfor better compatibility across environments.
**Available MCP Tools:**
| Category | Tools |
|----------|-------|
| Project | `init_project`, `read_project`, `validate_project` |
| Nodes | `create_node`, `list_nodes`, `get_node_info`, `configure_node` |
| Pipeline | `compile_pipeline`, `get_dependency_graph`, `get_execution_order`, `get_parallel_groups`, `run_pipeline` |
---
## API Reference
### `@app.node()` Chainable API
```python
# Basic usage
@app.node("name").who("Role").what("Task")
def my_node(param: str):
pass
# Full chainable configuration
@app.node("name") \
.who("Role") \
.where("Context") \
.what("Task") \
.why("Intent") \
.how("Steps") \
.stream(True) \
.format("json") \
.cache(ttl=300) \
.retry(max_attempts=3, delay=1.0) \
.timeout(30)
def my_node(param: str):
pass
Chainable Methods
| Method | Description |
|---|---|
.who(role) |
Set agent role |
.where(context) |
Set business context |
.what(task) |
Set core task |
.why(intent) |
Set execution intent |
.how(steps) |
Set steps or constraints |
.module([nodes]) |
Set sub-nodes for smart routing |
.out(format) |
Set output format requirements |
.stream(True) |
Enable streaming output |
.format("json") |
Enable JSON mode |
.cache(ttl=300) |
Enable caching with TTL |
.retry(max_attempts=3, delay=1.0) |
Configure retry behavior |
.timeout(30) |
Set execution timeout |
LLMConfig
config = LLMConfig(
model="qwen2.5-7b-instruct",
url="http://localhost:8080/v1/chat/completions",
api_key="", # optional, omit for local models
temperature=0.7,
max_tokens=1024,
language="en",
)
# Derive new config (original unchanged)
hot_config = config(temperature=1.2)
Uses OpenAI-compatible Chat Completions API (POST /v1/chat/completions). Works with OpenAI, DeepSeek, Azure OpenAI, vLLM, Ollama, LM Studio, LocalAI, and more. See Wiki.md for full configuration guide.
Project Structure
aacf/
__init__.py # Exports: AACF, LLMConfig, ExecutionResult, ...
core.py # Engine: config, HTTP client, decorator
compiler.py # Dependency analysis, DAG, atomic scheduler, error handling
visualize.py # Interactive HTML DAG visualization (pyvis)
cli.py # CLI commands
_messages.py # Bilingual prompt templates
aacf_mcp/ # MCP Server (optional)
__init__.py # Exports: create_server
server.py # FastMCP server with stdio transport
tools/
nodes.py # Node management tools
pipeline.py # Pipeline analysis tools
project.py # Project management tools
examples/
agents.py # Demo: content creation assistant
main.py # Demo: invocation entry point
Installation
# From PyPI (recommended)
pip install aacf
# With MCP server support
pip install aacf[mcp]
# From source
git clone https://github.com/Roxy-DD/aacf-py.git
cd aacf-py
pip install -e .
Python >= 3.10. Core dependencies: typer, rich. Optional: pyvis (visualization), mcp (MCP server).
Documentation
For detailed documentation, see Wiki.md.
License
GPL-3.0. See LICENSE.
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 aacf-0.10.1.tar.gz.
File metadata
- Download URL: aacf-0.10.1.tar.gz
- Upload date:
- Size: 83.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ab8c9a2bf816e0ef5219c78f1b7d4cc74a9629b576e9e22a8aed2ca199207500
|
|
| MD5 |
68c87f6b72fa712cc845367c085c510d
|
|
| BLAKE2b-256 |
c4485bebb5cae80c59cd7767b1f400f6dadc36e6dd5dd4cc224523bee5121e64
|
Provenance
The following attestation bundles were made for aacf-0.10.1.tar.gz:
Publisher:
publish.yml on Roxy-DD/aacf-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aacf-0.10.1.tar.gz -
Subject digest:
ab8c9a2bf816e0ef5219c78f1b7d4cc74a9629b576e9e22a8aed2ca199207500 - Sigstore transparency entry: 2138157591
- Sigstore integration time:
-
Permalink:
Roxy-DD/aacf-py@4cf285216ce3c09e1fd317d5cf980fbf9ea68f5b -
Branch / Tag:
refs/tags/v0.10.1 - Owner: https://github.com/Roxy-DD
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@4cf285216ce3c09e1fd317d5cf980fbf9ea68f5b -
Trigger Event:
release
-
Statement type:
File details
Details for the file aacf-0.10.1-py3-none-any.whl.
File metadata
- Download URL: aacf-0.10.1-py3-none-any.whl
- Upload date:
- Size: 78.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
aff300126f344cbc030b2b3e5c585b431a4e25bfad1fa1c50befb06f139c424b
|
|
| MD5 |
c13b2523e1d8af0617fd063d24549ff6
|
|
| BLAKE2b-256 |
26deb174a9e0a4c564f94f682331c7f3adbe35c3a95d6097be12e72e9210b78e
|
Provenance
The following attestation bundles were made for aacf-0.10.1-py3-none-any.whl:
Publisher:
publish.yml on Roxy-DD/aacf-py
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aacf-0.10.1-py3-none-any.whl -
Subject digest:
aff300126f344cbc030b2b3e5c585b431a4e25bfad1fa1c50befb06f139c424b - Sigstore transparency entry: 2138157602
- Sigstore integration time:
-
Permalink:
Roxy-DD/aacf-py@4cf285216ce3c09e1fd317d5cf980fbf9ea68f5b -
Branch / Tag:
refs/tags/v0.10.1 - Owner: https://github.com/Roxy-DD
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@4cf285216ce3c09e1fd317d5cf980fbf9ea68f5b -
Trigger Event:
release
-
Statement type: