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.3.tar.gz (46.8 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.3-py3-none-any.whl (61.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: open_agent_compiler-0.1.3.tar.gz
  • Upload date:
  • Size: 46.8 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.3.tar.gz
Algorithm Hash digest
SHA256 8808c9ed9ad96a5bc0fb6136c4711cf7ed74ae12ba9f8c27602cb3f2a07c21fa
MD5 bac8e25a6ddbf6f624e635d45e093c3e
BLAKE2b-256 df886f27be3a3d39192381b22a8e17a7418ae38379c52d6c5bfea5a6d39501bf

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for open_agent_compiler-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 16af36fcd7afdd5e0b6cb4afc2611dc8cd5bfe512065129b52d07904e589b8a1
MD5 3a978572ae89c73fe6e94a727853592c
BLAKE2b-256 a4cb079746a49e852ab0d72f80675ce3694eac32d2d76d4dd891914a5def60f8

See more details on using hashes here.

Provenance

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