orchcore
Reusable orchestration core for AI coding agent CLI pipelines.
What is orchcore?
orchcore is an async-first Python library for launching, monitoring, and managing AI coding agent CLIs (Claude Code, Codex, Antigravity, Copilot, OpenCode) as subprocesses in phase-based pipelines. It was extracted from four production orchestration systems (Planora, Articles, Finvault, and Raven), where an estimated 60-70% of the orchestration code was the same infrastructure. Consuming projects keep only their domain-specific logic: pipeline definitions, prompts, output interpretation, and presentation.
Features
- Launches agent CLIs as async subprocesses, captures their output streams, and limits how many run at once.
- Normalizes five JSONL output formats into one
StreamEventmodel through a four-stage stream pipeline (filter, parse, monitor, stall detection). - Runs phases in dependency order, with each phase's agents running sequentially or in parallel, and supports resume, skip, and single-phase options.
- Detects rate limits, parses reset times (including named time zones), and retries after a backoff wait.
- Layers settings from TOML files,
.envand environment variables, constructor arguments, and named profiles. - Separates the engine from presentation through the
UICallbackprotocol, so the consuming project chooses Rich, Textual, or headless output. - Defines agents as data: a new agent CLI that uses a supported stream format needs only a TOML entry.
- On SIGINT or SIGTERM, terminates agent process trees and force-kills them after a 30-second grace period. With a workspace attached, completed phases are saved for resume.
- Starts agent subprocesses with a filtered environment by default and in an explicit working directory when one is given (
cwd). Git recovery runs only when a phase opts in.
Installation
orchcore requires Python 3.12 or later.
uv pip install orchcore
To install from source with the development dependencies:
git clone https://github.com/AbdelazizMoustafa10m/orchcore.git
cd orchcore
uv pip install -e ".[dev]"
Quick Start
1. Define Agents
# agents.toml
[agents.claude]
binary = "claude"
model = "claude-sonnet-4-20250514"
subcommand = "-p"
stream_format = "claude"
# Flag profiles — names are your project's workflow vocabulary, not orchcore's.
[agents.claude.flags]
plan = ["--think", "--verbose"]
[agents.claude.output_extraction]
strategy = "jq_filter"
jq_expression = ".content[0].text"
2. Run a Pipeline
"""Minimal orchcore pipeline setup.
Requires a matching ``agents.toml`` file and the configured agent CLI on
``PATH``. Use ``dry_run=True`` at the AgentRunner layer for artifact-level
smoke tests; a real pipeline run launches the configured CLI.
"""
from __future__ import annotations
import asyncio
from pathlib import Path
from orchcore.pipeline import Phase, PhaseRunner, PipelineRunner
from orchcore.registry import AgentRegistry, ToolSet
from orchcore.runner import AgentRunner
from orchcore.ui import NullCallback
async def main() -> None:
registry = AgentRegistry()
registry.load_from_toml(Path("agents.toml"))
phase = Phase(
name="planning",
agents=("claude",),
# Selects [agents.<name>.flags].plan — a name YOUR project defines.
flag_profile="plan",
tools=ToolSet(internal=("Read", "Glob", "Grep"), permission="read-only"),
)
runner = AgentRunner()
phase_runner = PhaseRunner(runner, registry, max_concurrency=4)
pipeline = PipelineRunner(phase_runner)
result = await pipeline.run_pipeline(
phases=[phase],
prompts={"planning": "Analyze the codebase and create a plan."},
ui_callback=NullCallback(),
)
print(f"Success: {result.success} | Cost: ${result.total_cost_usd}")
if __name__ == "__main__":
asyncio.run(main())
By default, agent subprocesses receive a filtered environment, so common API keys and provider-specific variables are not inherited. To pass them through, set env_policy = "inherit", list the names in env_passlist, or set explicit env_vars in the agent config.
Modules
| Module | Purpose |
|---|---|
stream/ |
4-stage pipeline (Filter → Parse → Monitor → Stall Detect) for 5 agent formats |
pipeline/ |
Phase orchestration: sequential or parallel multi-agent execution in topological dependency order |
runner/ |
Async subprocess management with stdout/stderr streaming and optional stdin prompt transport (prompt_via = "stdin") |
registry/ |
Agent configurations as data (TOML/dict) with runtime lookup |
config/ |
Layered settings from TOML files, profiles, .env, environment variables, and constructor arguments |
recovery/ |
Rate-limit detection, exponential backoff, git dirty-tree recovery |
workspace/ |
Artifact lifecycle management |
prompt/ |
Jinja2 template rendering with frontmatter stripping |
ui/ |
UICallback protocol for pluggable display layers |
signals/ |
Graceful SIGINT/SIGTERM shutdown |
display/ |
Colored stderr logging (no Rich dependency in core) |
observability/ |
Optional OpenTelemetry integration |
Documentation
The full documentation is published on the orchcore documentation site. The pages below are also readable on GitHub.
| Document | Description |
|---|---|
| Installation | Prerequisites, install options, extras |
| Quick Start | Define agents, build phases, run pipelines |
| Configuration Reference | Full settings table, profiles, env vars |
| Stream Events Reference | StreamEvent fields, types, agent states |
| UICallback Reference | Protocol methods and built-in implementations |
| Architecture | Package layout, core abstractions, design decisions |
| Stream Pipeline | How the four stream-processing stages work |
| Design Document | Problem statement, requirements, proposed design |
| Writing a UICallback | Build custom display layers |
| Agent Registry | TOML config, adding new agents, ToolSets |
| Recovery & Retry | Rate limits, backoff, failure modes |
| Contributing | Dev setup, code standards, testing |
Contributing
See CONTRIBUTING.md for development setup, testing instructions, and code standards. Contributors follow the Code of Conduct, and security issues are reported as described in the security policy.
License
orchcore is released under the MIT License.
Metadata
Release files for orchcore 3.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| orchcore-3.0.2.tar.gz | 1.2 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| orchcore-3.0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 1.3 MB
Release files / orchcore-3.0.2.tar.gz
| Download URL | orchcore-3.0.2.tar.gz |
|---|---|
| Size | 1.2 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6df9ee7087b42e62852bfaf5ce09f79c2085baac2bc89c4009b164bfe46d34f5
|
|
BLAKE2b-256 checksum How to use checksums |
0e1768e4af6e191e30a04548fd70cc3761af4d34ee4fb8c91dcce896e7786b87
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.
Transparency logRelease files / orchcore-3.0.2-py3-none-any.whl
| Download URL | orchcore-3.0.2-py3-none-any.whl |
|---|---|
| Size | 93.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5a877211ec953d73ad4448fbbd2adfa3adf9a7f9bc4328dfecc5c7eb44672ba4
|
|
BLAKE2b-256 checksum How to use checksums |
953051f19b4e41d088d8c2335a9e217aedf3cd9f88c3c1b23554490a7b7fb8ce
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 15, 2026.
Transparency log