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.
As of v0.8, this package is a thin daemon client: every method
proxies to a singleton car-server daemon over WebSocket. Inference,
the per-session memory graph, and tool dispatch all live on the
daemon side. Start car-server once per host before using the
bindings (car-server ships in the same wheel; see "Start the
daemon" below).
Pre-built wheels (abi3, Python 3.9+) for:
macosx_15_0_arm64— macOS 15+ on Apple Silicon (Intel Macs dropped — see CHANGELOG)manylinux_2_17_x86_64,manylinux_2_28_aarch64
Building from source on macOS: set MACOSX_DEPLOYMENT_TARGET=15.0 when
invoking maturin build. MLX's bundled Metal shaders don't compile against
the default 11.0 target, and our release wheels target 15.0 because the
compiled extension pulls in libc++ symbols (notably
std::exception_ptr::__from_native_exception_pointer) that only exist on
macOS 15+. A lower target produces a wheel whose tag doesn't match what the
binary actually requires at dlopen time.
Install
From a release wheel (substitute the current version for X.Y.Z):
pip install https://github.com/Parslee-ai/car/releases/download/vX.Y.Z/car_runtime-X.Y.Z-cp39-abi3-macosx_15_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_runtime (matching the PyPI package name).
Start the daemon
# The car-server binary ships inside the wheel. Default port 9100;
# auth on by default. Foreground (Ctrl-C to stop):
python -m car_runtime.server
# Or background:
python -m car_runtime.server &
# Override the URL the bindings use:
export CAR_DAEMON_URL=ws://127.0.0.1:9100
On macOS the SwiftUI menubar host (CAR Host.app) launches the
daemon for you. Install it once from the .pkg installer on the
latest GitHub release; from then on it supervises car-server and
keeps itself up to date via Sparkle.
Quickstart
import json
from car_runtime import CarRuntime, verify
rt = CarRuntime() # lazy-connects to ws://127.0.0.1:9100/
# Tools + policies — proxied to the daemon's per-session runtime
# and persist for the lifetime of this CarRuntime's WS connection.
rt.register_tool("shell")
rt.register_policy(
"no_rm",
"deny_tool_param",
target="shell",
key="command",
pattern="rm -rf",
)
# Ground with facts (proxied to the daemon's per-session memgine).
rt.add_fact("project_language", "Python", "pattern")
# Static verification — runs on the daemon side, no model needed.
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']}")
# Proposal execution with a Python tool callback is not exposed on
# the PyO3 surface in v0.8 — connect to the daemon's WebSocket
# directly with `websockets` (or any WS library) and use:
# - `proposal.submit` (your client → daemon)
# - a `tools.execute` handler on the same connection (daemon → you)
# See docs/websocket-protocol.md and
# car-rs/examples/ws-client-python/ for a working sketch.
Streaming inference
from car_runtime 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_runtime 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, preferCarRuntime.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.
Type stubs
The wheel ships car_runtime.pyi alongside the compiled
extension and a py.typed marker (PEP 561). mypy, pyright, Pylance, and
similar tools pick up the full method signatures, parameter docstrings, and
return-shape descriptions automatically — no extra install needed.
If you're editing the source tree (not the published wheel), the same files
live at crates/car-ffi-pyo3/car_runtime.pyi and must be kept in sync with
src/lib.rs. See CLAUDE.md for the FFI-bindings parity rule.
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 client to the singleton car-server
daemon over WebSocket — CarRuntime() lazy-connects, every method
proxies through the JSON-RPC dispatcher, and the daemon owns
inference / memory / tool dispatch / per-session state.
Pre-v0.8 (the RuntimeMode::Embedded path) the wheel hosted an
in-process car-engine + car-memgine and ran inference under
py.allow_threads(...). That path was retired to close the
multi-tenant overcommit hazard CAR-issue #139 was opened for —
two FFI consumers in different processes each spawned a fresh
admission semaphore + model cache, and concurrent runs could
overwhelm the host. v0.8 takes the harder path: one daemon per
host, every client attaches.
See the repo README for the
broader CAR architecture and docs/proposals/daemon-as-default-runtime.md
for the v0.8 rationale.
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file car_runtime-0.18.0-cp39-abi3-win_amd64.whl.
File metadata
- Download URL: car_runtime-0.18.0-cp39-abi3-win_amd64.whl
- Upload date:
- Size: 24.7 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5cc92b2078972b1ef3a000b5c943e353d5388c8250864ded190d1b50e73d702a
|
|
| MD5 |
a8c4845e9ff352e462125a0295125cf8
|
|
| BLAKE2b-256 |
f4353b3bda112b11f63c17cb6ec98ec6472479c308cc24774961d0c452eaa55c
|
Provenance
The following attestation bundles were made for car_runtime-0.18.0-cp39-abi3-win_amd64.whl:
Publisher:
build.yml on Parslee-ai/car
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
car_runtime-0.18.0-cp39-abi3-win_amd64.whl -
Subject digest:
5cc92b2078972b1ef3a000b5c943e353d5388c8250864ded190d1b50e73d702a - Sigstore transparency entry: 1633822350
- Sigstore integration time:
-
Permalink:
Parslee-ai/car@73ee6d7c862abed013a2c404d1519b187f17172a -
Branch / Tag:
refs/tags/v0.18.0 - Owner: https://github.com/Parslee-ai
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yml@73ee6d7c862abed013a2c404d1519b187f17172a -
Trigger Event:
push
-
Statement type:
File details
Details for the file car_runtime-0.18.0-cp39-abi3-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: car_runtime-0.18.0-cp39-abi3-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 29.0 MB
- Tags: CPython 3.9+, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c215661b24029b5765d021cdb606109bfa1ab5d0183624ddc9c82b62ab4dbc20
|
|
| MD5 |
6f550f501b5fdddf7f2ba649a6f420b4
|
|
| BLAKE2b-256 |
c93739bbe93bffdf961d0e8cd29ef6bb7e12b4ca623e5dbb4899ff9c0b142266
|
Provenance
The following attestation bundles were made for car_runtime-0.18.0-cp39-abi3-manylinux_2_28_x86_64.whl:
Publisher:
build.yml on Parslee-ai/car
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
car_runtime-0.18.0-cp39-abi3-manylinux_2_28_x86_64.whl -
Subject digest:
c215661b24029b5765d021cdb606109bfa1ab5d0183624ddc9c82b62ab4dbc20 - Sigstore transparency entry: 1633822334
- Sigstore integration time:
-
Permalink:
Parslee-ai/car@73ee6d7c862abed013a2c404d1519b187f17172a -
Branch / Tag:
refs/tags/v0.18.0 - Owner: https://github.com/Parslee-ai
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yml@73ee6d7c862abed013a2c404d1519b187f17172a -
Trigger Event:
push
-
Statement type:
File details
Details for the file car_runtime-0.18.0-cp39-abi3-macosx_15_0_arm64.whl.
File metadata
- Download URL: car_runtime-0.18.0-cp39-abi3-macosx_15_0_arm64.whl
- Upload date:
- Size: 22.9 MB
- Tags: CPython 3.9+, macOS 15.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
01d8a2166a72b916db73b55a90e5908ce6e14855b14e35cf3dcd72d59299a04b
|
|
| MD5 |
c6c7fa1b891805c840c38aac2136fdf8
|
|
| BLAKE2b-256 |
8fd0209a20a28b52badce556fba82e8e840b9e4876aa525285fe0f8b15ae4b1f
|
Provenance
The following attestation bundles were made for car_runtime-0.18.0-cp39-abi3-macosx_15_0_arm64.whl:
Publisher:
build.yml on Parslee-ai/car
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
car_runtime-0.18.0-cp39-abi3-macosx_15_0_arm64.whl -
Subject digest:
01d8a2166a72b916db73b55a90e5908ce6e14855b14e35cf3dcd72d59299a04b - Sigstore transparency entry: 1633822305
- Sigstore integration time:
-
Permalink:
Parslee-ai/car@73ee6d7c862abed013a2c404d1519b187f17172a -
Branch / Tag:
refs/tags/v0.18.0 - Owner: https://github.com/Parslee-ai
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
build.yml@73ee6d7c862abed013a2c404d1519b187f17172a -
Trigger Event:
push
-
Statement type: