open-agent-compiler
Composable agent-tree compiler for OpenCode, Claude Code, and Pi (via @tintinweb/pi-subagents). Define agents once as typed Python, compile them to any supported runtime, test them with mocks, and improve them with closed-loop optimization.
What it does
Define an agent once in Python:
from open_agent_compiler import (
AgentDefinition, AgentHeader, AgentRegistry,
CompilationConfig, ModelParameters,
TemplateSlot, TemplateTree,
)
def registry() -> AgentRegistry:
reg = AgentRegistry()
agent = AgentDefinition(
header=AgentHeader(agent_id="hello", name="hello",
description="Friendly greeter."),
usage_explanation_long="A minimal greeting agent.",
usage_explanation_short="greets",
system_prompt="You are a friendly greeter. Reply in one sentence.",
)
aid = reg.register_agent("hello", agent,
ModelParameters(model_name="zai-coding-plan/glm-4.5-air", temperature=0.7))
reg.register_template(TemplateTree(name="t",
slots=[TemplateSlot(name="primary", default_agent_id=aid)]))
reg.create_compilation_config(CompilationConfig(name="prod", template_name="t"))
return reg
Compile it into an opencode-loadable tree:
uv run oac compile myproj.agents:registry --config prod --target build
Run with OpenCode:
cd build && opencode run --agent primary "Hi"
> primary · glm-4.5-air
Hello there! Nice to meet you.
Or compile for Pi and run with pi-subagents:
uv run oac compile myproj.agents:registry --config prod --target build --dialect pi
cd build && pi run --agent primary "Hi"
Key features
- Pydantic-modeled agent/tool/skill/workflow definitions — no YAML hand-editing, types catch errors at registration time.
- Multi-variant compilation — same agent compiled side-by-side
against different providers/models via
VariantSpec.SplitProfilepicks per-agent presets by declaredmodel_class. - Dual tool format — bash command allowlist or OpenCode-style JSON-schema custom_tool, per-agent or per-tool.
- Built-in test framework —
CapabilityTest(introspection),ToolTest(mocked or real handler),AgentTest(end-to-end). 9 evaluator kinds. JSONL artifacts. Incremental skip via composite hash. - Bundled infrastructure scripts —
subagent_todo.py,workspace_io.py,opencode_manager.pyauto-included when the compiled tree references them. - Iterative improvement loop —
oac improvemutates prompts/tools/ resources, evaluates candidates against yourOptimisationCriterion, promotes winners. - Project scaffolder —
oac initgenerates a Docker-compose'd project with FastAPI + cron + optional Postgres / Redis / Qdrant / Ollama / Langfuse. Cron POSTs JSON events to the FastAPI server which invokes the compiled agents. - Multi-dialect — OpenCode (default) + Claude Code + Pi (via
@tintinweb/pi-subagents),
with a plug-in
Dialectprotocol for future runtimes. - Developer skill bundles —
oac sync-skillsdeploys opinionated markdown skill files into a project's.opencode/skills/and.claude/skills/so coding agents working in the repo know how to use the framework.
Install
pip install open-agent-compiler
# or
uv add open-agent-compiler
For development on the framework itself:
git clone https://github.com/DehydratedWater/OpenAgentCompiler
cd OpenAgentCompiler
uv sync
uv run oac --help
CLI
oac init <dir> --template web --llm anthropic … # scaffold a new project
oac compile <factory> --config prod --target build # compile agents
oac test <factory> --config prod # run embedded tests
oac improve <factory> --target X --criteria c.yaml # iterative improvement
oac promote improved/X/LATEST.json # re-introduce a winner
oac sync-skills <project> --skills opencode,claude # deploy dev skills
oac info <factory> # introspect registry
Examples gallery
| Example | Demonstrates |
|---|---|
examples/00_hello/ |
minimum working agent end-to-end with z.ai glm-4.5-air |
examples/10_multi_provider/ |
one agent compiled three ways: z.ai glm-4.5-air + glm-5.1 + local vLLM Qwen3.5-27B |
examples/20_optimization_run/ |
weak agent improved via oac improve with glm-5.1 as the optimiser |
examples/80_pi_agents/ |
orchestrator + subagents compiled for Pi runtime with pi-subagents |
All examples are tested end-to-end against real LLMs (see
examples/README.md).
Documentation
Start with the Developer Guide — the complete walkthrough: setup, core concepts, all three dialects, the worker vs interactive tier split, tools, workflows, variants, testing, the improvement loop, CLI reference, and a full examples index. Dialect deep-dive: pi-agent-dialect.md.
Documentation: developer skills
The framework ships 14 skill bundles you can deploy into any project
with oac sync-skills (highlights below; oac sync-skills --help for
the full set):
getting-started— three commands you'll use most, agent shapeauthoring-agents— workflow vs system_prompt, modes, todo_modeauthoring-tools— ScriptTool, MockableTool, AccessProfilewriting-tests— CapabilityTest / ToolTest / AgentTest + evaluatorsproviders-and-models— ModelPreset, per-agent model assignmentvariants-and-profiles— VariantSpec / SplitProfile / CompilationContextdocker-and-compose— the scaffolded Docker setup + failure modesimprovement-loop—oac improve+oac promote
uv run oac sync-skills ./myproject --skills opencode,claude
After this, coding agents (OpenCode or Claude Code) working in your project read the skill files and know how to add agents, write tests, debug Docker, configure providers, etc.
Project layout
open_agent_compiler/
__init__.py # Public API re-exports
cli/ # `oac` CLI subcommands
compiler/ # The compile pipeline + dialect registry
dialects/{opencode,claude_code,pi_agent}/
improvement/ # Phase 6 iterative loop
mutators/ # Mutator implementations
model/ # Pydantic models (agents/tools/skills/tests/…)
runtime.py # ScriptTool base class
scaffold/ # `oac init` template engine
files/ # File generators (Dockerfile, compose, app, …)
scripts/ # Bundled handler scripts (auto-copied)
skills/ # Developer skill bundles
testing/ # Test runner + evaluators + artifacts
tests/ # pytest tree (mirrors open_agent_compiler/)
examples/ # Working end-to-end examples
Status
Through Phase 36 (~36 numbered phases shipped). Headline features:
- Composable agent trees with
register_with_improvementsauto-merging promoted snapshots (Phase 10). - Multi-turn
AgentTest+ sequenced / statefulMockResponsefor streaming/monitoring scenarios (Phase 11). - Per-agent MCP allowlists + bundled MCP-server scaffold via
--with-mcp-server(Phases 12 + 24). - Tool-targeted mutators (description, rules, bash-vs-json
format) +
tool_failure_ratecriterion (Phase 13). ScriptTool.execute(input, resources)+ResourceHandlefor clean DB / API bindings (Phase 15).- Composable context blocks +
PromptAssemblerwith volatility-aware ordering (Phase 19). TaskHandle+SpawnAgentToolfor long-running and agent-spawned-from-tool patterns (Phases 20 + 21).- FastAPI dispatcher with sync / async / fire-and-forget modes,
variant routing, composable
RetryPolicy(Phase 23). oac init --interactive+ autouv sync(Phase 25).- Dual-compile (
also_compile_as_primary): every subagent slot can also emit a primary twin reachable directly viaopencode run --agent <name>-primaryor via opencode_manager dispatch (Phase 31). OpencodeRunner— the recommended sync eval runner with auto-retry on empty output + 0-1 score clamping (Phase 36).
19 numbered examples under examples/. 11 skills under
open_agent_compiler/skills/content/ totalling 20+ documented patterns from real
project pain.
Benchmark / verification
The framework's reproducibility benchmark is a complete spec for
building a real multi-agent media-tracking service (7 agents, 5
tools, Postgres, MCP, FastAPI dispatch) with the framework. Use it
to verify that a fresh agentic-coding instance can one-shot a real
project on top of open_agent_compiler. The reference
implementation is verified end-to-end (live search API, live z.ai
agent runs, live autoresearch producing a positive baseline delta).
License
MIT.
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 open_agent_compiler-1.0.0.tar.gz.
File metadata
- Download URL: open_agent_compiler-1.0.0.tar.gz
- Upload date:
- Size: 677.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dac94f6c51c1ebf9e88b1166c62ec68f0a0b923709c4cb6d3dd5fbb33dd67e1a
|
|
| MD5 |
a5f24c30d888e6f8f854c37fd40ae844
|
|
| BLAKE2b-256 |
9337df083c435b7a95080d73fdc75d26d0bc5c8d9ad4a2ac476ba58c5c260e45
|
Provenance
The following attestation bundles were made for open_agent_compiler-1.0.0.tar.gz:
Publisher:
publish.yml on DehydratedWater/OpenAgentCompiler
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
open_agent_compiler-1.0.0.tar.gz -
Subject digest:
dac94f6c51c1ebf9e88b1166c62ec68f0a0b923709c4cb6d3dd5fbb33dd67e1a - Sigstore transparency entry: 2195409791
- Sigstore integration time:
-
Permalink:
DehydratedWater/OpenAgentCompiler@a7947c8fef0e05c7bc5cf3c6aa936fdb99b5c09f -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/DehydratedWater
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a7947c8fef0e05c7bc5cf3c6aa936fdb99b5c09f -
Trigger Event:
push
-
Statement type:
File details
Details for the file open_agent_compiler-1.0.0-py3-none-any.whl.
File metadata
- Download URL: open_agent_compiler-1.0.0-py3-none-any.whl
- Upload date:
- Size: 421.3 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 |
20bf47401ead7544a452f3ec46ed72e15e51a72a70c07488eb11cb43cfc64351
|
|
| MD5 |
c26d3d7d198d34418c5bae1d2c818441
|
|
| BLAKE2b-256 |
7c21f36e58d780b77cb34c82b802a0287e47d6133cf382aceac4f0217a31473e
|
Provenance
The following attestation bundles were made for open_agent_compiler-1.0.0-py3-none-any.whl:
Publisher:
publish.yml on DehydratedWater/OpenAgentCompiler
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
open_agent_compiler-1.0.0-py3-none-any.whl -
Subject digest:
20bf47401ead7544a452f3ec46ed72e15e51a72a70c07488eb11cb43cfc64351 - Sigstore transparency entry: 2195409797
- Sigstore integration time:
-
Permalink:
DehydratedWater/OpenAgentCompiler@a7947c8fef0e05c7bc5cf3c6aa936fdb99b5c09f -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/DehydratedWater
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@a7947c8fef0e05c7bc5cf3c6aa936fdb99b5c09f -
Trigger Event:
push
-
Statement type: