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.1.tar.gz (46.2 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.1-py3-none-any.whl (60.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: open_agent_compiler-0.1.1.tar.gz
  • Upload date:
  • Size: 46.2 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.1.tar.gz
Algorithm Hash digest
SHA256 27da63dd5df81b866ce83b790855bdbb28be3911d9a345429527b5851048b1ea
MD5 cf32649c0ef644ffcdd64ed2483ccaf0
BLAKE2b-256 dc4aca39d875d6615472f20fc5087afbb00471b02676f780e438ef2fd1d46a3f

See more details on using hashes here.

Provenance

The following attestation bundles were made for open_agent_compiler-0.1.1.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.1-py3-none-any.whl.

File metadata

File hashes

Hashes for open_agent_compiler-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d0ce378c344de3cc36ba4217a1847b99666b3c459834f3b87ec628efc03a2816
MD5 8e7b28c8bd308e9be638bf67ffd1b12e
BLAKE2b-256 5bb10c6c644dc46cce959f91fce78b69743c890125186fa1d23b845a726c8453

See more details on using hashes here.

Provenance

The following attestation bundles were made for open_agent_compiler-0.1.1-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