Skip to main content

Python-first agent framework that compiles agent definitions into backend-specific configurations

Project description

OpenAgentCompiler

Python-first agent framework that compiles agent definitions into backend-specific configurations for OpenCode agents.

Installation

pip install open-agent-compiler

Or with uv:

uv add open-agent-compiler

For local/editable development:

uv add --editable ../OpenAgentCompiler

Quick start

from open_agent_compiler.builders import AgentBuilder, ConfigBuilder, ToolBuilder
from open_agent_compiler.compiler import compile_agent
from open_agent_compiler.writers import OpenCodeWriter
from open_agent_compiler._types import (
    ModelConfig, ModelOptions, ProviderConfig, ProviderOptions,
)

# Define a tool
search = (
    ToolBuilder()
    .name("file-search")
    .description("Search files by glob pattern")
    .from_script("scripts/file_search.py")
    .build()
)

# Configure the model
config = (
    ConfigBuilder()
    .provider(ProviderConfig(
        name="anthropic",
        options=ProviderOptions(api_key="env:ANTHROPIC_API_KEY"),
        models=(ModelConfig(
            name="sonnet",
            id="claude-sonnet-4-5-20250929",
            options=ModelOptions(temperature=0.0),
        ),),
    ))
    .default_model("anthropic/sonnet")
    .build()
)

# Build the agent
agent = (
    AgentBuilder()
    .name("my-agent")
    .description("My custom agent")
    .config(config)
    .tool(search)
    .system_prompt("You are a helpful assistant.")
    .build()
)

# Compile and write to disk
compiled = compile_agent(agent, target="opencode")
OpenCodeWriter(output_dir="build/").write(compiled)

Architecture

Builder -> AgentDefinition -> Compiler -> backend dict -> Writer -> disk -> Manager -> external process
  • Builders -- Fluent API classes that produce immutable data types via .build()
  • Compiler -- Transforms an AgentDefinition into a backend-specific dict
  • Writers -- Persist compiled dicts to disk (project files, configs, scripts)
  • Managers -- Async lifecycle managers that deploy/invoke/teardown agents

Development

uv sync --all-extras      # install with dev + bench deps
uv run pytest tests/ -v   # run all tests
uv run ruff check .       # lint
uv run mypy               # type check

Python version

Requires Python 3.12+.

License

See LICENSE for details.

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

open_agent_compiler-0.1.2.tar.gz (46.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

open_agent_compiler-0.1.2-py3-none-any.whl (61.2 kB view details)

Uploaded Python 3

File details

Details for the file open_agent_compiler-0.1.2.tar.gz.

File metadata

  • Download URL: open_agent_compiler-0.1.2.tar.gz
  • Upload date:
  • Size: 46.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for open_agent_compiler-0.1.2.tar.gz
Algorithm Hash digest
SHA256 73c2dda7edd9d3cfaf8e525778ebef037b17e593695089b45764581f336a0080
MD5 8dc6915ee53e02490ed17145bf9e552a
BLAKE2b-256 5e4a1bfa1842fb61f88259a2ddf5d44309e827a7db55f4ba9371a870b632ca4e

See more details on using hashes here.

Provenance

The following attestation bundles were made for open_agent_compiler-0.1.2.tar.gz:

Publisher: publish.yml on DehydratedWater/OpenAgentCompiler

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file open_agent_compiler-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for open_agent_compiler-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 6e754be49e65e3d4b0f229cd3f8c89829b2a58f91cdbd43d46f710322ae10bec
MD5 d43ba295588e77051d0b91acfadee1da
BLAKE2b-256 74c2f2fc884228b234b75135fc0f8c55a20b5fe9902f0d1d6e40954a4bd920ed

See more details on using hashes here.

Provenance

The following attestation bundles were made for open_agent_compiler-0.1.2-py3-none-any.whl:

Publisher: publish.yml on DehydratedWater/OpenAgentCompiler

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page