Skip to main content

Common Agent Runtime — Python bindings for deterministic AI agent execution

Project description

car-runtime (Python)

Python bindings for Common Agent Runtime (CAR) — a deterministic execution layer for AI agents. Models propose; the runtime validates and executes.

Pre-built wheels (abi3, Python 3.9+) for:

  • macosx_14_0_arm64, macosx_14_0_x86_64 — macOS 14+ required (MLX Metal shaders)
  • manylinux_2_17_x86_64, manylinux_2_28_aarch64

Building from source on macOS: set MACOSX_DEPLOYMENT_TARGET=14.0 when invoking maturin build — MLX's bundled Metal shaders don't compile against the default 11.0 target.

Install

From a release wheel (until PyPI is wired up):

pip install https://github.com/Parslee-ai/car/releases/download/vX.Y.Z/car_runtime-X.Y.Z-cp39-abi3-macosx_11_0_arm64.whl

Or build from source:

pip install maturin
cd car-rs/crates/car-ffi-pyo3
maturin develop --release

The import name is car_native (the native extension module).

Quickstart

import json
from car_native import CarRuntime, verify, execute

rt = CarRuntime()

# Tools + policies.
rt.register_tool("shell")
rt.register_policy(
    "no_rm",
    "deny_tool_param",
    target="shell",
    key="command",
    pattern="rm -rf",
)

# Ground with facts.
rt.add_fact("project_language", "Python", "pattern")

# Verify before executing.
proposal = json.dumps({
    "actions": [{
        "id": "a1",
        "type": "tool_call",
        "tool": "shell",
        "parameters": {"command": "ls"},
        "dependencies": [],
    }],
})

check = json.loads(rt.verify_proposal(proposal))
if not check["valid"]:
    raise RuntimeError(f"invalid proposal: {check['issues']}")

# Execute with a Python-side tool callback.
def tool_fn(tool: str, params_json: str) -> str:
    params = json.loads(params_json)
    # Dispatch to your actual implementation.
    return json.dumps({"stdout": "ok", "stderr": ""})

result_json = rt.execute_proposal(proposal, tool_fn)

Streaming inference

from car_native import CarRuntime

rt = CarRuntime()

def on_event(event_json: str) -> None:
    e = json.loads(event_json)
    if e["type"] == "text":
        print(e["data"], end="", flush=True)

rt.infer_stream(
    "Explain CAR in one sentence.",
    on_event,
    max_tokens=256,
)

Multi-agent coordination

import json
from car_native import register_agent_runner, run_swarm

def agent_fn(spec_json: str, task: str) -> str:
    spec = json.loads(spec_json)
    # Call your LLM of choice, returning an AgentOutput JSON.
    return json.dumps({"name": spec["name"], "response": "...", "tool_calls": []})

# Option A: register once, then call run_* without passing agent_fn each time.
register_agent_runner(agent_fn)
result = run_swarm(
    "parallel",
    json.dumps([
        {"name": "researcher", "role": "gather facts", "model": "gpt-5"},
        {"name": "writer",     "role": "compose summary", "model": "claude-opus-4-7"},
    ]),
    "summarize the CAR paper",
)

# Option B: pass agent_fn per call.
result = run_swarm("parallel", agents_json, task, agent_fn=agent_fn)

API surface

The runtime (CarRuntime) exposes:

  • State: state_set, state_get, state_exists, state_snapshot, state_keys
  • Memory: add_fact, query_facts, fact_count, build_context, build_context_fast, persist_memory, load_memory, consolidate
  • Skills: ingest_skill, find_skill, report_outcome, distill_skills, ingest_distilled_skills, list_skills, domains_needing_evolution, repair_skill, evolve_skills
  • Tools + policies: register_tool, register_agent_basics, register_policy, set_replan_config
  • Inference: infer, infer_tracked, infer_with_context, infer_with_context_tracked, embed, rerank, classify, prepare_speech_runtime, transcribe, synthesize, infer_stream
  • Models: list_models, pull_model, remove_model, list_models_unified, register_model, route_model, model_stats
  • Execution: event_count, verify_proposal, execute_proposal

Module-level standalone functions:

  • Verification: verify, simulate, optimize, equivalent
  • Stateless execute: execute (creates a fresh Runtime; for long-lived use, prefer CarRuntime.execute_proposal)
  • Multi-agent: register_agent_runner, run_swarm, run_pipeline, run_supervisor, run_map_reduce, run_vote
  • Scheduler: create_task, run_task, run_task_loop, ensure_dream_task
  • Planner: rank_proposals

Structured returns are JSON-encoded strings — json.loads them on the Python side. This keeps the FFI surface stable across binding and protocol changes.

Development

# Install dev deps.
pip install maturin pytest

# Build and install in editable mode.
cd car-rs/crates/car-ffi-pyo3
maturin develop

# Run the smoke tests.
pytest tests/ -v

Architecture

This package is a thin PyO3 wrapper over the Rust car-engine + car-memgine crates. Tool execution uses a callback pattern: the runtime doesn't own tools, you provide a Python function that dispatches them. See the repo README for the bigger picture.

License

Free for any use including commercial; free to redistribute unmodified. Modification, reverse engineering, and derivative works are not permitted. See LICENSE for the full text. Copyright © 2026 Parslee AI.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

car_runtime-0.4.5-cp39-abi3-win_amd64.whl (14.1 MB view details)

Uploaded CPython 3.9+Windows x86-64

car_runtime-0.4.5-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (15.9 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.17+ x86-64

car_runtime-0.4.5-cp39-abi3-macosx_14_0_x86_64.whl (13.5 MB view details)

Uploaded CPython 3.9+macOS 14.0+ x86-64

car_runtime-0.4.5-cp39-abi3-macosx_14_0_arm64.whl (17.1 MB view details)

Uploaded CPython 3.9+macOS 14.0+ ARM64

File details

Details for the file car_runtime-0.4.5-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: car_runtime-0.4.5-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 14.1 MB
  • Tags: CPython 3.9+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for car_runtime-0.4.5-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 20933b0f623720bd452dc1e2e02625f51ffb37d4c482ff6df017404fde2bd638
MD5 941387131a31e51380bc1811a539d6eb
BLAKE2b-256 5a9d1f9ee16af942adf234346dcfac04d5bda1e28f0568a4f3495950dce3c10a

See more details on using hashes here.

Provenance

The following attestation bundles were made for car_runtime-0.4.5-cp39-abi3-win_amd64.whl:

Publisher: build.yml on Parslee-ai/car

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

File details

Details for the file car_runtime-0.4.5-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for car_runtime-0.4.5-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 10b11e3b4c4d032e29e0bfebb89f6630d8a059e24607c474b0fdec75901aa158
MD5 eee2288ec146a440bbdc1a071acdb3c7
BLAKE2b-256 a7423a1e1d9e77a0f4a8f696b59b1df240d5ab1d65a2569f84cec94a5fd12a22

See more details on using hashes here.

Provenance

The following attestation bundles were made for car_runtime-0.4.5-cp39-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: build.yml on Parslee-ai/car

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

File details

Details for the file car_runtime-0.4.5-cp39-abi3-macosx_14_0_x86_64.whl.

File metadata

File hashes

Hashes for car_runtime-0.4.5-cp39-abi3-macosx_14_0_x86_64.whl
Algorithm Hash digest
SHA256 df4814496554a9fcbf9473541530872f4c7f8c3e2b6af43f00ed049ac548723f
MD5 4656300e11325e97a05e3e1a5f31489c
BLAKE2b-256 d87762ebd991d6ff583e927760fcddda6492621130b5861380940991d1c5ed2a

See more details on using hashes here.

Provenance

The following attestation bundles were made for car_runtime-0.4.5-cp39-abi3-macosx_14_0_x86_64.whl:

Publisher: build.yml on Parslee-ai/car

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

File details

Details for the file car_runtime-0.4.5-cp39-abi3-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for car_runtime-0.4.5-cp39-abi3-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 ab41ba9e975602707b94e4d77073d2d74ae3e8a6f6daf41d6eb6d7a345e990f0
MD5 a3c626a0d4f6251d4cca90e2a0bbd8dc
BLAKE2b-256 52e6a565fd7683f35b9c83ed5a1d600acab18d408447f248ffb162e2a8810857

See more details on using hashes here.

Provenance

The following attestation bundles were made for car_runtime-0.4.5-cp39-abi3-macosx_14_0_arm64.whl:

Publisher: build.yml on Parslee-ai/car

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