Economic control plane for AI agents
Project description
Caracal Core
Economic control plane for AI agents.
Overview
Caracal Core is an open-source economic infrastructure layer for AI agents that provides:
- Economic Identity: Unique identifiers for agents with ownership metadata
- Budget Policies: Spending limits with time-based constraints
- Policy Enforcement: Fail-closed budget checks before agent execution
- Immutable Ledger: Append-only audit trail of all spending events
- Metering: Resource usage tracking with cost calculation
Installation
Using uv (recommended)
# Create virtual environment
uv venv
# Activate virtual environment
source .venv/bin/activate # On Unix/macOS
# or
.venv\Scripts\activate # On Windows
# Install Caracal Core
uv pip install -e .
# Install with development dependencies
uv pip install -e ".[dev]"
Using pip
pip install caracal-core
Quick Start
Initialize Caracal
caracal init
This creates the ~/.caracal/ directory with default configuration.
Register an Agent
caracal agent register --name "my-agent" --owner "user@example.com"
Create a Budget Policy
caracal policy create --agent-id <agent-id> --limit 100.00 --window daily
Use the SDK
from caracal.sdk.client import CaracalClient
client = CaracalClient()
# Budget check context manager
with client.budget_check(agent_id="my-agent"):
# Your agent code here
result = call_expensive_api()
# Emit metering event
client.emit_event(
agent_id="my-agent",
resource_type="openai.gpt4.input_tokens",
quantity=1000
)
Query the Ledger
# Query by agent
caracal ledger query --agent-id <agent-id>
# Query by date range
caracal ledger query --start 2024-01-01 --end 2024-01-31
# Get spending summary
caracal ledger summary --agent-id <agent-id>
Development
Running Tests
# Run all tests
pytest
# Run unit tests only
pytest tests/unit/
# Run property-based tests
pytest tests/property/ -m property
# Run with coverage
pytest --cov=caracal --cov-report=html
Code Quality
# Format code
black caracal/ tests/
# Lint code
ruff caracal/ tests/
# Type checking
mypy caracal/
Architecture
Caracal Core follows a modular architecture:
caracal.core: Core primitives (identity, policy, ledger, metering)caracal.sdk: Python SDK for agent integrationcaracal.cli: Command-line interfacecaracal.config: Configuration management
Requirements
- Python 3.10+
- Dependencies: click, pyyaml, hypothesis, ase-protocol
License
Apache License 2.0 - See LICENSE file for details.
Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
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 Distribution
Built Distribution
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 caracal_core-0.1.0.tar.gz.
File metadata
- Download URL: caracal_core-0.1.0.tar.gz
- Upload date:
- Size: 73.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c2d520e944d00cfb8b570204b20ded7f8e45e857da98849d43fecede2e23c473
|
|
| MD5 |
080508a547fc8c56b6637e82cc85ebce
|
|
| BLAKE2b-256 |
8ad4a2a98d648d116d3575cb449b1ade701da974680dc2765e07932fafcc338f
|
File details
Details for the file caracal_core-0.1.0-py3-none-any.whl.
File metadata
- Download URL: caracal_core-0.1.0-py3-none-any.whl
- Upload date:
- Size: 71.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dbdb4365e2c7926a7b54b7b94633a394aab3efc854b5018f99a2829a0eb14508
|
|
| MD5 |
411e4f2b31b4561a3a3550b2f83621a0
|
|
| BLAKE2b-256 |
e1cc9eedeb53dd4e0030b81a643296f56b3792ef544a0f436310956d6f96e807
|