Inspiration

What happens when an AI purchasing agent says it is paying the right merchant, but the payment goes somewhere else? What if the owner approves an $85 purchase and the order changes to $99 before payment?

We built Leash around this gap: an agent’s request, the owner’s approval, and the payment provider’s order must remain consistent.

Our intended users are developers building AI purchasing agents, particularly for small-business teams that need spending boundaries and a clear record of purchases.

What it does

Leash sits between an agent’s payment request and PayPal. It retrieves order details from PayPal and checks them against owner-approved rules.

Those rules include allowed merchants, per-purchase limits, rolling spending budgets, purchase counts, expiry, and approval thresholds. Owner approval cannot override a hard spending limit.

Before capturing a payment, Leash checks the order again. If it differs from the purchase the owner reviewed, Leash blocks it.

Leash also records payment events in a hash-chained audit log and builds evidence reports connecting purchases, checks, approvals, and dispute information. Verification can detect edits to the recorded history.

AI proposes rules. The owner confirms them. Deterministic code controls payments.

How we built it

Leash is a Python application with a command-line interface and a local browser dashboard built with FastAPI. The dashboard displays spending rules, budget information, payment results, approval controls, and evidence reports. AG Grid Community presents the audit events in a table.

The PayPal Sandbox integration retrieves order details, supports buyer checkout approval, and captures approved payments using test money. PayPal is central to the workflow: Leash checks provider-reported payment details rather than relying on the agent’s description.

For AI-assisted rule interpretation, we integrated OpenAI GPT-OSS-120B hosted on Groq through an OpenAI-compatible client. Natural-language instructions become proposed structured rules that are validated and shown to the owner for confirmation.

A simulated payment provider supports repeatable offline demonstrations and adversarial testing without external credentials.

What makes Leash distinctive

Leash connects three stages of an agent purchase:

  1. Before payment: enforce the owner’s spending boundaries and verify the recipient and amount.
  2. After review: recheck that the order still matches the purchase that was approved.
  3. After payment: preserve a verifiable history that can support investigation when a dispute arrives.

The project demonstrates why a correct-looking agent response is not enough to authorize a payment. The payment details and the owner’s permission must agree.

Challenges we faced

One important challenge was approval becoming outdated. During development, we identified a case where a merchant could change an order while it waited for owner approval. We updated the workflow so approval is tied to the reviewed order, with revalidation before payment proceeds.

PayPal Sandbox also restricted automated dispute creation with a permissions error. We created the sandbox dispute manually and generated its evidence report, documenting that limitation in the setup instructions.

Another challenge was keeping AI assistance separate from payment authority. The model can help interpret instructions, but proposed rules still require validation and owner confirmation.

Testing on Windows also exposed text-encoding and environment-isolation issues in the test suite. These highlighted the importance of checking the actual development environment and making tests independent of locally configured API keys.

Accomplishments

We completed a PayPal Sandbox payment through buyer checkout and capture, and successfully tested live Groq-powered rule interpretation in the dashboard.

The demonstration also shows simulated wrong-recipient requests, changed orders, dispute evidence, and detection of edits to a copied audit log.

We built a 22-scenario attack suite alongside automated tests for the rules engine, payment guard, audit log, evidence generation, parser, command-line interface, and dashboard.

The source code is publicly available under the MIT License, with local setup instructions and a manual testing checklist.

What we learned

Payment controls need to operate on verified facts, even when the surrounding agent workflow uses probabilistic AI.

We also learned that approval is meaningful only when it applies to the exact purchase being completed. Rechecking the order is essential when details can change between review and capture.

Finally, a payment result alone does not explain what happened. Recording the rules, decisions, and payment events makes later investigation more useful.

What's next for LEASH — Spending Controls for AI Agents

Leash is a local, single-process sandbox prototype. Next steps include authenticated owner approval, transactional storage for concurrent requests, a production-oriented webhook workflow, and broader order support.

We also want to make evidence reports easier to inspect and extend testing across additional provider responses and failure conditions.

Leash: spending controls before payment. Evidence afterwards.

Built With

Share this project:

Updates

Submission history