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.0.tar.gz (46.1 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.0-py3-none-any.whl (60.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: open_agent_compiler-0.1.0.tar.gz
  • Upload date:
  • Size: 46.1 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.0.tar.gz
Algorithm Hash digest
SHA256 27296e1ef238c1415ce2be6ec0ffc58a6acdddcbcd355df6abbf38c368152ea9
MD5 4095180eb2b9c4f6f5dfe53806f063ee
BLAKE2b-256 6bf0cea243b6dcfc8d8b65b5d5169f0b8dbaeddde5e2528452493aaf2cd61d86

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for open_agent_compiler-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a9e180797a956a1970bedd7cbaafa7a7488f63cfc868301c285891c015bd73f0
MD5 bd7f258dc601e7e990486120d9937a6f
BLAKE2b-256 e2491dace8cc47aa47c45d7cc33ea64d00115a4a85606403d516429c561cd999

See more details on using hashes here.

Provenance

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