Developer insights

Give Your Staff an AI Agent That Pays, Inside Your Rules​

Elton Tay Headshot
Elton Tay
Developer Relations Lead APAC, Developer and Ecosystem Marketing
November 23, 2026
6
min read
November 23, 2026
6
min read

Summary

AI agents are moving from recommendation to execution. In finance, they can now initiate payments and other actions, in some cases without a person reviewing each one. So before a company gives its staff an agent that can spend, it needs answers to a few plain questions: who may make the agent spend, on what and up to how much, and how will anyone know later what it bought and why?

Policymakers are starting to look at the same questions. The Monetary Authority of Singapore has published SAFR (Safeguards for Agentic Finance at Runtime), a white paper developed with financial institutions, that proposes a runtime checkpoint between an agent's decision and its execution. It is early work, a starting point for industry discussion rather than regulatory guidance.

We wanted to see what those controls look like when an agent actually spends money, so we built an example. This blog walks through it: an open-source sample app built on the Circle Agent Stack, where a LangChain research agent pays for AI model answers in USDC and every purchase is channelled through four steps, enforced in code you can read, run and change.

The setup

Picture ExampleCo, the fictional company in the sample app. Its analysts work with a research agent, and when a question calls for it, the agent can buy an answer from an AI model, paying per request.

Under the hood, an Agent Wallet holds the company's USDC, and the Circle CLI uses it to pay for services over x402, an open standard for paying for HTTP resources. The seller in this example is BlockRun.AI, an independent third party that sells AI model answers per request over x402, paid in USDC on Arc.

The agent itself can do very little, on purpose. It has just two tools, quote and buy, and it never sees the keys, the wallet or the rules. Every buy goes through a harness, and that harness checks the proposal against the configured rules.

One request, start to finish

Say an analyst asks the agent something like: "Which payment rails and protocols are emerging for AI agents, and how do they compare on speed, cost and use case?" To answer it, the agent decides to buy a model's answer. The purchase follows four steps, from checking who is asking to recording the outcome.

Who is asking?

The first question is who is behind the request. An agent ID alone proves little, because it can be copied. So before the model runs, the analyst and the agent each sign the request, and the harness checks both signatures against the company registry. The signed session covers the exact request, seller and rules, expires after a short window and can be used only once, so a copied agent ID, a reused session or a policy changed after signing all fail here. The most basic check is whether this employee is assigned to this agent at all, from src/identity.ts:

if (!agent.employees.includes(context.employeeId)) throw new Refusal('identity.assignment', 'Employee is not assigned to this agent');

What do the rules allow?

Next comes the money. The agent wants to spend, but it does not get to pick the seller or the price. Instead, the harness asks the seller to quote every model the company approves, and the analyst picks one. Each option has to fit the company's rules, which live in policy.json, a file the model cannot touch: the seller, the payee, the approved models, a cap per answer and a budget. An excerpt from the example policy:

"operations": { "chat_completion": { "maxUsdc": 0.01 } },
"scope": { "models": ["anthropic/claude-sonnet-5.5", "openai/gpt-6.1-sol", "google/gemini-2.5-flash"] }

‍

A second layer sits outside the app altogether: the Agent Wallet's own spending policies, set on the wallet itself, which apply whatever the app's rules say.

Execute, escalate or deny?

With the identity confirmed and the rules checked, the harness makes the call. Here the analyst's pick fits the rules, so the purchase executes. A failed check would have ended in a denial before any payment. And a price above the company's approval threshold waits for a person, who sees the price, the payee and the purpose before saying yes or no (src/harness.ts):

if (price > micro(this.options.policy.limits.approvalAboveUsdc)) {
  // ...shows the approver the price, chain, payee and purpose, then waits for an answer
  if (!rec.approved) { rec.outcome = 'approval_denied'; throw new Refusal('approval', 'Approver declined'); }
}


The decision travels with the payment, too. To pay, the harness runs the Circle CLI's services pay command against the seller's x402 endpoint, with --max-amount set to the price the rules accepted, so the payment itself cannot exceed it (payments/circle.ts):

const args = (req: Request) => ['services', 'pay', req.url, '-X', req.method, '--address', address, '--chain', chain, ...(req.body ? ['-d', req.body] : [])];

try { raw = await runCircleJson<unknown>([...args(req), '--max-amount', String(ceiling), '--timeout', '60']); }

‍

What happened?

Sooner or later, someone will ask why the agent bought what it bought, and the answer should already be written down. The harness records every proposed purchase in a journal, including refusals. For a payment, it writes one entry before the payment goes out and another when the outcome is known.

  • the prompt the agent sent
  • who asked: the employee, the agent and the signed session
  • the seller's quote
  • the outcome, and for a refusal, the rule that stopped it
  • for a paid purchase, the amount, the transaction hash and the seller's answer

Here is one entry, trimmed:

{"stage":"complete","chosen":"google/gemini-2.5-flash",
 "identity":{"employeeId":"analyst","agentId":"research-agent"},
 "quote":{"priceUsdc":0.002111,"chain":"ARC"},"outcome":"paid"}


In the sample app, the journal is a local file that the harness only ever appends to: easy to inspect, but not tamper-evident. The harness also takes a failed write seriously. If an entry cannot be written before a payment, nothing is paid, and if one cannot be written afterwards, the agent stops buying.

In your own app, the same entries could go to your company's database or logging system, ideally one where they cannot be changed once written.

Now ask as someone else

Same question, different person: an employee who is registered at the company but not assigned to the research agent. This time the story ends at the first step. The identity check fails, the request is denied, and nothing reaches the model, the seller or the chain. The refusal still goes in the journal, and because it never touches the chain, the journal is the only place it shows up.

What we learned

Keep control in code, not in the prompt. The model proposes a purchase, and the harness checks it against the configured rules before payment. The same goes for errors: if a payment's result is unclear, the agent stops buying until a person checks, and it never retries on its own.

Most of the sample app can be swapped out. The four steps stay the same, and almost everything around them can change:

  • The question and the agent. The question is one line in a prompt file. The agent runs on LangChain here, but it only has two tools, quote and buy, so another framework works too. The Circle Agent Stack starter kits show an Agent Wallet with other frameworks.
  • The seller. BlockRun.AI is one example. The Agent Marketplace lists other x402 services that accept USDC, and adding one takes a service definition and a policy entry.
  • The rules. Models, caps, the budget and the approval threshold are values in one policy file. Set the threshold below the cap, for example, and purchases start waiting for a person to approve. The wallet also has its own spending policies, such as transfer limits or allowed addresses, set with the Circle CLI. 
  • Identity and records. The company registry and the journal are local files here. A company could use its own sign-in or an agent identity such as ERC-8004, and write to a log it controls.

Try it

Clone the sample app and follow its quick start. The offline version runs without keys or a wallet and uses simulated payments to replay both runs from the video. Then make it your own: ask a different question, tighten the rules, add a seller from the Agent Marketplace, or put your own agent behind the checkpoint.

When you're ready to give your agent a real wallet, start with the Agent Wallets quickstart, set its spending policies, and pay for x402 services with the Circle CLI. The Circle Agent Stack docs cover the rest.

This sample app started from the Circle Agent Stack starter kits. The sample app's README shows how its checks relate to SAFR, as an exploration for learning. It is not certified under, compliant with or endorsed by SAFR and/or the MAS. SAFR is an industry white paper and does not constitute regulatory guidance. BlockRun.AI is an independent third party that Circle does not operate. Its prices, availability and terms are its own. Answers shown were generated by third-party AI models, may be inaccurate, and do not reflect Circle's views.

Sample apps provided for demonstration and educational purposes only, intended for Arc testnet use only, and not production-ready. Arc testnet provided by Circle Technology Services, LLC, a software provider. Not a financial or advisory service. Not reviewed or approved by NYDFS. Users responsible for their own compliance. See arc.io for more.

Agent Wallets, Agent Marketplace, Circle CLI, Nanopayments, and Circle Skills (together, the “Agent Stack”) are offered by Circle Technology Services, LLC (“CTS”). CTS is a software provider and does not provide financial, advisory, or marketplace services. Agent Stack enables users, developers, and their artificial intelligence agents ("AI Agents") to build, deploy, discover, hold and transact their own funds, and interact with other third-party AI Agents, applications and services. Transactions initiated by AI Agents are executed based on user-defined permissions and may occur without real-time human review. Circle does not verify, screen, monitor, or make any representations or warranties regarding the identity, legitimacy, safety, security, reliability, or performance of any AI Agent, including any AI Agent developed by you, other users, or third parties, or any AI Agent that interacts with the Agent Stack. AI Agents may operate unpredictably, may be controlled by unknown or unauthorized parties, and may expose users to security, financial, or other risks. Users are solely responsible for their use of these tools, reviewing commands before execution, and for evaluating associated risks. For additional details, please see the Agent Platform Terms of Use available at agents.circle.com/terms-of-use and the Circle Developer Terms of Service available at console.circle.com/legal/developer-terms.

Contents