Skip to content
agentleash

agentleash

Python safety harness for AI agents that touch mon

Created on 20th May 2026

•

agentleash

agentleash

Python safety harness for AI agents that touch mon

The problem agentleash solves

AI agents that touch money (pay-per-API calls, autonomous purchases, on-chain bots) are starting to ship in production, but the safety primitives haven't caught up. A small bug or a malicious prompt can drain a Stripe key, fan out unbounded paid LLM calls, or post to a wrong endpoint before anyone notices.

agentleash is a single Python context manager that puts a leash on each agent run:

  • USD-per-run + per-call caps (token-budget-py under the hood; agent halts cleanly when cap hits)
  • Egress allowlist (wildcard hostnames; e.g. *.stripe.com only)
  • Optional tool-arg JSON Schema gate so bad args never reach the side-effectful function
  • Append-only JSONL audit log; tool args are sha256-hashed by default so PII / secrets never land on disk

It's the dollars-side companion to birddog (egress side, also today) and pairs with agentvet / agentsnap / agenttrace.

Challenges I ran into

Three things ate the most time.

  1. token-budget-py API mismatch. Tests kept failing on BudgetPool having no usd_used attribute. Fix was calling .snapshot().usd_used instead of reading state directly. Once I read the lib's source the API was obvious; lesson was to drop into the dep's code earlier, not later.

  2. PII in audit logs. First version dumped tool args verbatim into the JSONL, which means a Stripe customer ID or a personal email lands in plaintext on disk. Switched to sha256-hashing each arg by default so the audit trail still proves a call happened without leaking content.

  3. Where to halt. A naive cap check at the start of tool() misses the fact that the LLM has already produced output costing tokens. Moved the budget check to after the LLM call returns but before the side-effectful tool runs, so the agent halts at the latest safe point - the network/payment side-effect doesn't happen, but you don't lose the LLM output you already paid for.

Tracks Applied (1)

Using LocusFounder to Build a Business!

Paygentic agents are LLM-driven workers that move money - the second a model hallucinates a billing endpoint or fans out...Read More

Technologies used

Discussion

Builders also viewed

See more projects on Devfolio