AgentWallet
Financial governance infrastructure for AI agents.
Spend controls, rules engine, kill switch, and audit trail — every financial action an agent takes flows through governance before a dollar moves.
Install
pip install agentwallet
Quick Start
from agentwallet import AgentWallet, SpendRule, RuleVerdict
# Create a governed wallet
wallet = AgentWallet("trading-agent", budget_cents=5000) # $50 budget
# Add custom governance rules
wallet.add_rule(SpendRule(
rule_id="block-expensive-models",
name="Block calls over $5",
condition=lambda ctx: ctx["amount_cents"] > 500
and "gpt-4" in ctx.get("metadata", {}).get("model", ""),
verdict=RuleVerdict.DENY,
))
# Every spend goes through governance
result = wallet.spend(200, "llm-inference", metadata={"model": "gpt-4"})
# {'approved': True, 'tx_id': '...', 'remaining_cents': 4800}
result = wallet.spend(800, "llm-inference", metadata={"model": "gpt-4"})
# {'approved': False, 'reason': 'Blocked by rule: block-expensive-models'}
Persistence (NEW in 0.2.0)
Add persist=True and wallet state survives process restarts. Zero config — uses SQLite under the hood.
# First run
wallet = AgentWallet("my-agent", budget_cents=5000, persist=True)
wallet.spend(200, "api-call")
wallet.spend(300, "web-search")
print(wallet.balance_cents) # 4500
# ... restart your process ...
# Second run — state is restored automatically
wallet = AgentWallet("my-agent", persist=True)
print(wallet.balance_cents) # 4500 — it remembered!
print(len(wallet.transactions)) # 2 — transactions restored too
Everything persists: balance, transactions, audit log, kill switch state. Multiple agents can share the same database file.
# Custom database path
wallet = AgentWallet("agent-1", persist=True, db_path="/data/governance.db")
# Query spend analytics (with persistence)
summary = wallet._storage.get_spend_summary("agent-1")
by_category = wallet._storage.get_spend_by_category("agent-1")
all_wallets = wallet._storage.list_wallets()
What's Included
- AgentWallet — Per-agent wallets with configurable budgets
- GovernanceEngine — Rules engine that evaluates every transaction
- SpendRule — Custom rules with priority-based evaluation
- Kill Switch — Instant shutdown of all agent spending
- AuditLog — Append-only JSONL audit trail for compliance
- SQLite Persistence —
persist=Trueand state survives restarts - Spend Analytics — Query spend by category, get summaries
- Event Callbacks —
wallet.on("deny", callback)for webhooks/alerts - Dashboard API — FastAPI server for real-time monitoring
- CLI —
agentwallet demoandagentwallet dashboard
Built-in Safety Rules
Every wallet ships with four default rules (highest priority first):
- Kill Switch (priority 1000) — blocks everything when activated
- Max Per Transaction (priority 900) — caps individual spend
- Daily Limit (priority 800) — caps rolling 24-hour spend
- Balance Check (priority 700) — prevents overdraft
Event Callbacks
Get notified when governance events fire:
import requests
# Webhook on denied transactions
wallet.on("deny", lambda data: requests.post(
"https://hooks.slack.com/your-webhook",
json={"text": f"🚫 Agent blocked: {data['reason']}"}
))
# Log all approved spend
wallet.on("approve", lambda data: print(f"✅ ${data['amount_cents']/100:.2f} approved"))
# Kill switch alerts
wallet.on("kill_switch", lambda data: print(f"🛑 Kill switch: {data}"))
Dashboard
pip install agentwallet[dashboard]
agentwallet dashboard
Or programmatically:
from agentwallet import AgentWallet, register_wallet, start_dashboard_server
wallet = AgentWallet("my-agent", budget_cents=10000)
register_wallet(wallet)
start_dashboard_server(port=8100) # API at http://localhost:8100/docs
CLI
agentwallet demo # Run a quick demo with sample transactions
agentwallet dashboard # Start the governance API server
agentwallet version # Show version
Zero Dependencies
The core SDK has zero external dependencies. Just Python 3.9+. The dashboard server optionally uses FastAPI + uvicorn.
Links
- Quickstart Repo: github.com/JackD720/agentwallet-quickstart
- Examples: 3 working examples (simple agent, LangChain, CrewAI)
- Reference: arXiv:2501.10114 "Infrastructure for AI Agents"
License
MIT
Metadata
Release files for agentwallet-gov 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| agentwallet_gov-0.3.0.tar.gz | 18.5 kB | Without provenance | Details for agentwallet_gov-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| agentwallet_gov-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for agentwallet_gov-0.3.0-py3-none-any.whl |
Total release size: 21.9 kB
Release files / agentwallet_gov-0.3.0.tar.gz
| Download URL | agentwallet_gov-0.3.0.tar.gz |
|---|---|
| Size | 18.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2ee7e778dae86627a1e1bd4fa206e7b2ae8c9cbbc7d624aa618719899fcc16c2
|
|
BLAKE2b-256 checksum How to use checksums |
2caf9cf138af38cb774f917f81e14518cc3e35634f45cffccf35279460b34bc5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.9
|
Release files / agentwallet_gov-0.3.0-py3-none-any.whl
| Download URL | agentwallet_gov-0.3.0-py3-none-any.whl |
|---|---|
| Size | 3.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2f8bb8bb6d8a27ef0363b1b5eaf555480dfc6fa83490e1a025dcfea3e00cd32f
|
|
BLAKE2b-256 checksum How to use checksums |
0adeda3773ff48fe27178143dbe31a111af1e404d347433d37594bbf78796919
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.9
|
Security for agentwallet-gov 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.