Inspiration

AI agents are starting to make purchases, book services, and handle payments on behalf of users. That creates a problem: what happens when an agent makes a purchase it shouldn't?

We wanted to build a system that checks an agent's spending before the payment is captured. The goal was to give developers control over agent spending while keeping a human involved when a transaction looks suspicious.

What it does

TrustRail is a spend-governance system for AI agents that connects with PayPal Sandbox.

Before a payment is captured, TrustRail checks the transaction against spending policies and an XGBoost risk model. It uses SHAP to explain the risk score and a Beta-distribution trust score to track each agent's payment history.

Depending on the result, TrustRail can allow a payment, block it, or hold it for human review.

We built three demo scenarios:

  • Rogue agent: An agent attempts to purchase a $4,500 gaming laptop. TrustRail flags the transaction and voids the authorization before capture.
  • Runaway agent: An agent repeats $29 payments to the same merchant. TrustRail detects the repeated activity and holds the third iteration.
  • Legitimate purchase: An agent requests a $2,800 Delta flight from SFO to LHR. TrustRail sends it for human review, and the reviewer approves the payment through the dashboard.

How we built it

We used TypeScript for the agents and integrated PayPal Orders v2 through direct REST API calls. Payments use the AUTHORIZE flow, which gives TrustRail a chance to evaluate a transaction before capture. Approved payments can be captured, while blocked authorizations can be voided.

The backend uses FastAPI and stores transaction and agent data in PostgreSQL through Supabase. We trained an XGBoost model using 11 transaction and behavioral features, including spending patterns, transaction velocity, merchant familiarity, and unusual activity.

For explanations, we integrated SHAP with TreeExplainer. TrustRail displays the top three factors behind a risk score and calculates a counterfactual explanation using a 20-step binary search.

We also implemented a Beta-distribution trust score that changes as agents receive approvals, automatic captures, and policy violations.

The dashboard uses React, Vite, and Tailwind CSS. It lets reviewers inspect transactions, read risk explanations, approve or deny held payments, and edit agent policies.

We deployed the frontend on Vercel and the backend on Render.

Challenges we ran into

The PayPal integration took careful work because authorization, buyer approval, capture, and voiding are separate steps. We had to make sure TrustRail evaluated payments at the correct point in that flow.

Another challenge was building useful behavioral features. A transaction amount alone does not tell us whether an agent is acting suspiciously. We had to account for repeated payments, merchant familiarity, transaction velocity, and changes in spending patterns.

We also had to make the model's decisions understandable. A risk score is difficult to act on without knowing what caused it, so we added SHAP explanations and a counterfactual calculation.

Testing PayPal Sandbox payments also took time because some checkout sessions were declined during testing. We recorded the demo scenarios separately and combined them into one video.

Accomplishments we're proud of

We connected TrustRail to the actual PayPal Sandbox payment lifecycle and demonstrated authorization, capture, and void operations.

We built an XGBoost risk model with a reported ROC-AUC of 0.9832 on our project evaluation data. We also added SHAP explanations, agent trust scoring, and policy-based decisions.

The three demo scenarios show different outcomes: a suspicious purchase gets blocked, repeated payments trigger a hold, and a legitimate purchase reaches human review before approval.

We also completed a working dashboard and deployed the frontend and backend.

What we learned

Working with PayPal taught us how payment authorization and capture work in practice, and why the timing of a spending decision matters.

We learned that transaction history can reveal patterns that a single transaction cannot. We also spent time understanding how to explain model predictions instead of showing reviewers a risk score without context.

Building the trust score helped us think about how an agent's past behavior should affect future spending decisions.

What's next for TrustRail

We want to add stronger authentication and access control, improve the behavioral model with more transaction history, and expand policy management for teams running multiple agents.

We also plan to explore more payment providers and add better support for payment disputes and webhooks.

TrustRail: Trust your agents. Govern their spending.

Built With

Share this project:

Updates

Submission history