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.
| Control | Would have stopped |
|---|---|
| Per-task budget as a stop condition | t-118 after a few dollars, with a named exit |
| Repeat limit per endpoint per task | The loop after a handful of identical calls |
| Host allowlist in the wallet | Payments to dataset-mirror.example |
| Alert at a fraction of the daily budget | A person seeing it at 2 a.m., not at 9 |
| Cache of paid results per task | Paying 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.