Skip to main content

Financial governance infrastructure for AI agents — spend controls, rules engine, kill switch, and audit trail.

Project description

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'}

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
  • Event Callbackswallet.on("deny", callback) for webhooks/alerts
  • Dashboard API — FastAPI server for real-time monitoring
  • CLIagentwallet demo and agentwallet dashboard

Built-in Safety Rules

Every wallet ships with four default rules (highest priority first):

  1. Kill Switch (priority 1000) — blocks everything when activated
  2. Max Per Transaction (priority 900) — caps individual spend
  3. Daily Limit (priority 800) — caps rolling 24-hour spend
  4. 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

License

MIT

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

agentwallet_gov-0.1.0.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

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

agentwallet_gov-0.1.0-py3-none-any.whl (3.0 kB view details)

Uploaded Python 3

File details

Details for the file agentwallet_gov-0.1.0.tar.gz.

File metadata

  • Download URL: agentwallet_gov-0.1.0.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for agentwallet_gov-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a1b4b2842f45a2897339cf5a72b7da1c74b128ce5744b41cb0bf0c8113a58e16
MD5 0d0023a0f17c4ffe22488c0f7a52ec25
BLAKE2b-256 a97ccc5d07f70f7cdb7f77b410af9d8b200418da39721e01924d46ecae428345

See more details on using hashes here.

File details

Details for the file agentwallet_gov-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for agentwallet_gov-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 29d3c9e3a8c8232a55e30fa468853753168aa0b47ba794a8755d7e1cc13284d5
MD5 1cb0e3d26d70c205274664870c44adc4
BLAKE2b-256 95aedbb9c8800c9df42cc6c0b51341da597f79d8d95250472376b3d932df69d5

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