Spendpol โ AI Spend Protocol. Delegated spending governance for autonomous AI agents.
Project description
๐ Spendpol
AI Spend Protocol โ Governance for autonomous agent spending.
Spendpol is an open protocol that sits between AI agents and payment systems. It answers one question:
"Should this agent be allowed to make this expenditure?"
Spendpol does not move money. It governs whether money should move.
Why Spendpol?
AI agents are calling APIs, purchasing compute, and consuming paid services. But spending controls are stuck in the human era: hardcoded API keys, manual approval, cloud budget alerts.
As agents scale from 1 to 1,000 and delegate tasks to sub-agents, the uncontrolled spending surface grows exponentially. Spendpol provides the governance layer.
Agent Logic โ [Spendpol] โ Payment Execution
โ
โโโ Is this agent authorized?
โโโ Within spending limits?
โโโ Anomaly detected?
โโโ Audit logged โ
Install
pip install spendpol
Quick Start
from spendpol import SpendpolClient
client = SpendpolClient()
# Human grants spending authority to an agent
client.grant(
delegator="user:john@acme.com",
delegatee="agent-research",
max_per_transaction=1.00,
max_daily=10.00,
max_monthly=200.00,
allowed_vendors=["openai", "anthropic"],
allowed_actions=["api_call"],
)
# Agent requests permission to spend
verdict = client.check_intent(
agent_id="agent-research",
vendor="openai",
action="api_call",
amount=0.03,
purpose="Generate embeddings for ticket #4521",
)
if verdict.allowed:
result = call_openai_api() # Your payment execution
client.log_receipt(verdict, actual_amount=0.028)
elif verdict.denied:
print(f"Blocked: {verdict.evaluations[-1].detail}")
CrewAI Integration
from spendpol.crewai import SpendpolCrewMiddleware
asp = SpendpolCrewMiddleware(
delegator="user:john@acme.com",
default_daily_limit=10.00,
allowed_vendors=["openai", "anthropic"],
)
# Decorator: one line to control any tool's spending
@asp.controlled(vendor="openai", action="api_call", cost_per_call=0.03)
def embedding_tool(text: str) -> list[float]:
return openai.embeddings.create(input=text)
# Automatically: checks policy โ executes โ logs receipt
result = embedding_tool("Hello world")
Core Concepts
| Concept | What it does |
|---|---|
| SpendIntent | Agent declares "I want to spend $X on Y" |
| PolicyVerdict | Engine responds: allow / deny / escalate |
| SpendReceipt | Records what actually happened |
| AuditQuery | Anyone can inspect spending history |
| DelegationGrant | Human gives agent permission with limits |
| Attenuation | Sub-agents can only have fewer permissions, never more |
What Spendpol Is NOT
- Not a wallet โ holds no funds
- Not a payment processor โ moves no money
- Not a blockchain โ no consensus, no tokens
- Not KYC/AML โ no identity verification
- Not a legal entity โ agents have no personhood
Spendpol's regulatory surface is equivalent to a logging tool, not a financial service.
Architecture
spendpol/
โโโ schemas.py # Protocol message types
โโโ delegation.py # Delegation chains + attenuation
โโโ wallet.py # Non-custodial spending tracker
โโโ policy.py # Deterministic policy engine
โโโ audit.py # Append-only audit log
โโโ validator.py # Message validation + verification
โโโ service.py # Agent-to-agent commerce registry
โโโ client.py # High-level SDK
โโโ crewai.py # CrewAI middleware
โโโ langgraph.py # LangGraph middleware
โโโ autogen.py # AutoGen middleware
โโโ schemas/ # JSON Schema definitions (Draft 2020-12)
โ โโโ spend-intent.schema.json
โ โโโ policy-verdict.schema.json
โ โโโ spend-receipt.schema.json
โ โโโ delegation-grant.schema.json
โ โโโ audit-query.schema.json
โ โโโ cost-estimate.schema.json
โ โโโ service-offer.schema.json
โ โโโ service-quote.schema.json
โ โโโ service-result.schema.json
โโโ examples/ # Test vector payloads
โ โโโ spend-intent.json
โ โโโ policy-verdict-allow.json
โ โโโ policy-verdict-deny.json
โ โโโ spend-receipt.json
โ โโโ delegation-grant.json
โ โโโ audit-query.json
โ โโโ service-offer.json
โ โโโ service-quote.json
โ โโโ service-result.json
โโโ test_core.py # 67 core tests
โโโ test_langgraph.py # 22 LangGraph tests
โโโ test_autogen.py # 23 AutoGen tests
โโโ WHITEPAPER.md # Full protocol specification
Run Tests
pip install pytest
python -m pytest test_core.py test_langgraph.py test_autogen.py -v
Protocol Specification
Read the full WHITEPAPER.md for:
- Complete message schemas with JSON examples
- Delegation model and attenuation principle
- Policy engine evaluation order
- Anomaly detection specification
- Trust and liability model
- Audit role taxonomy
Roadmap
- Core protocol (4 message types)
- Delegation chains with attenuation
- Deterministic policy engine
- Anomaly detection (confidence-aware)
- Audit log with role-based access
- CrewAI integration
- LangGraph integration
- AutoGen integration
- REST API server (spendpol-cloud)
- Dashboard (spend analytics)
- PyPI publish
- Agent-to-agent commerce (Phase 1)
Contributing
Spendpol is an open protocol. Contributions welcome.
- Fork the repo
- Create your feature branch (
git checkout -b feature/my-feature) - Run tests (
python -m pytest test_core.py test_langgraph.py test_autogen.py -v) - Submit a PR
License
- Python code (reference implementation): MIT
- Protocol specification (WHITEPAPER.md, JSON Schemas): CC-BY-4.0
See DISCLAIMER.md for important legal notices.
Cloud computing gave machines compute. Spendpol gives machines governance.
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 spendpol-0.2.0.tar.gz.
File metadata
- Download URL: spendpol-0.2.0.tar.gz
- Upload date:
- Size: 34.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4e322084886db59f6320b7b523bae8eb40fe15bea7ef5a0337e5f7976d32fee6
|
|
| MD5 |
616049af8825d8ee4bd1307a8cddd997
|
|
| BLAKE2b-256 |
251a63efb7ca335b223a59340690d72eb3199ff4f9b307070507d88e68ee3d38
|
File details
Details for the file spendpol-0.2.0-py3-none-any.whl.
File metadata
- Download URL: spendpol-0.2.0-py3-none-any.whl
- Upload date:
- Size: 40.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d3f56adbbd44a278efd145f869f9573ea9d78813294127af2cced014609b6134
|
|
| MD5 |
95a89579d8aa0159bdc532ed466201d3
|
|
| BLAKE2b-256 |
c9b6175ba3fad55796e3ce6128cb296baffa0ec81c089b011297db1d94704818
|