Skip to main content

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 integration
  • caracal.cli: Command-line interface
  • caracal.config: Configuration management

Requirements

  • Python 3.10+
  • Dependencies: click, pyyaml, hypothesis, ase-protocol

License

GNU AFFERO GENERAL PUBLIC LICENSE v3 - See LICENSE file for details.

Contributing

Contributions are welcome! Please see CONTRIBUTING.md for guidelines.

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

caracal_core-0.1.1.tar.gz (77.7 kB view details)

Uploaded Source

Built Distribution

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

caracal_core-0.1.1-py3-none-any.whl (74.1 kB view details)

Uploaded Python 3

File details

Details for the file caracal_core-0.1.1.tar.gz.

File metadata

  • Download URL: caracal_core-0.1.1.tar.gz
  • Upload date:
  • Size: 77.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for caracal_core-0.1.1.tar.gz
Algorithm Hash digest
SHA256 86835f7f47e1d5b269e7f85ef42fe1dc44349b72a5f15f34fb9702ed39e6c35d
MD5 ffe19fffe4ef1f69db88b18edd497648
BLAKE2b-256 716c878397379ba09bdc97bf1759ce69cea9b4ae525d558938846eb7dd8dfec5

See more details on using hashes here.

File details

Details for the file caracal_core-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: caracal_core-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 74.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for caracal_core-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 da4ab75529cc5dd47c59c007c24d654e1bfd217e1d7e6c2cbc9f12014555bb99
MD5 eb7dbc9c4143e59764cebdc889758b57
BLAKE2b-256 110d00e5855ada436b8c2c7f217effa4fa0dd15f18e05c5f262779980c0ae029

See more details on using hashes here.

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