Skip to content

Interview question · Agent Payments & Commerce

A research agent with x402 payments spent its whole daily budget overnight. How do you investigate and contain it?

The daily cap did its job and still failed: it stopped the spending only after all of it was gone. The investigation is about which task spent it and why nothing smaller stopped it first.

mediumNewUpdated Nov 2026

TL;DR: First contain: freeze payments for the agent (not the whole fleet) and keep the payment log. Then group payments by task, host and endpoint: drains almost always come from one task looping on one endpoint, or from payments to a host nobody intended. Fix the cause, then add the controls that would have stopped it earlier: per-task budgets as stop conditions, a host allowlist, per-endpoint repeat limits and an alert at a fraction of the budget.

How to approach it

Contain, then investigate from the payment records joined to traces, then fix the specific cause, then close the control gap that let a whole day's budget go before anything fired.

A strong answer

Contain without destroying evidence. Disable signing for this agent in the wallet layer, so it cannot pay while you look. Keep the x402 settlement records (PAYMENT-RESPONSEs, facilitator records) and the run traces.

Group the payments.

from collections import Counter

payments = (
    [{"task": "t-118", "host": "api.weatherdata.example", "path": "/forecast"}] * 212
    + [{"task": "t-121", "host": "api.geocode.example", "path": "/lookup"}] * 9
    + [{"task": "t-118", "host": "dataset-mirror.example", "path": "/full"}] * 3
)
by_task_path = Counter((p["task"], p["host"], p["path"]) for p in payments)
print(by_task_path.most_common(1))
# => [(('t-118', 'api.weatherdata.example', '/forecast'), 212)]

One task called one endpoint 212 times. Its trace will usually show why: a retry loop on a response the agent could not parse, a pagination bug that never advanced, or the model re-requesting the same data because the result was cleared from its context. The three payments to dataset-mirror.example need separate attention: why could the agent pay a host nobody listed?

Fix the cause. Make the failing response an observation the agent can act on (or a named exit), fix pagination, or keep the fetched result available instead of re-buying it. Add the trace as an evaluation case.

Close the control gap.

ControlWould have stopped
Per-task budget as a stop conditiont-118 after a few dollars, with a named exit
Repeat limit per endpoint per taskThe loop after a handful of identical calls
Host allowlist in the walletPayments to dataset-mirror.example
Alert at a fraction of the daily budgetA person seeing it at 2 a.m., not at 9
Cache of paid results per taskPaying twice for the same resource

Why the daily cap was not enough. It bounds the worst day, but one task can consume it all, and it fires only at the end. Smaller budgets closer to the cause turn a cost incident into a failed task.

What interviewers probe next

"Could the server have overcharged?" Check settlement records against the requirements the client accepted. The exact scheme should settle exactly; upto should never exceed the authorised ceiling.

"Should the agent decide whether data is worth buying?" It can propose; the wallet's policy decides. Keep money decisions in code.

How it's scored

Weak: Raises the daily budget or turns off x402.

Hire: Groups payments by task and endpoint, finds the loop, adds a per-task budget.

Strong Hire: Contains per agent while preserving evidence, joins payments to traces, fixes the specific cause with an eval case, adds per-task budgets, repeat limits, a host allowlist, early alerts and result caching, and explains why a daily cap alone fires too late.

Common mistakes

  • Freezing the whole fleet instead of one agent.
  • Looking only at totals, not at task and endpoint.
  • Ignoring the payments to an unexpected host.
  • Leaving the decision to pay in the model's hands.
You just read a free answer. Every topic opens its first 5 answers to anyone. Sign in and the count per topic goes to 6, and the site remembers where you stopped in each one.Google sign-in · free · no payment details
HOW DID IT GO?
0
READING SIGNED OUT

Signing in raises your free answers from 5 to 6 per topic, adds an applied lesson in every topic and easy practice tests, and the site starts remembering you: mastery per topic, bookmarks, and a next-focus recommendation. Free, no card.

Sign in free

FROM THE BLOG

UP NEXT ON YOUR JOURNEY
DISCUSSION · 0

Nobody has commented. Post a correction or another way to answer.