← sources

My agent's output tests stayed green while it refunded a customer twice. How are you testing what agents do, not what they say?

source: reddit (reddit:AI_Agents)published 2026-11-15 15:04ingested 2026-11-16 02:34

retained text

Context: I built a synthetic support agent to stress-test agent testing. It looks up orders, issues refunds and emails customers. The failure I planted is a boring one from real payment systems:

The payments API commits the refund, then times out before responding. The agent sees a timeout, retries without an idempotency key, and the customer is refunded twice. The agent's reply: "Your refund of $84.00 has been processed." Correct amount, polite, on-brand.

Every test I had passed. They all asserted on the reply, and the reply was fine. The bug lived in the tool calls and in the payments ledger, which none of them looked at.

What caught it, in the end:

- counting tool calls per business key (at most one refund call per order id)
- checking the end state of the system after the run (exactly one refund for that order), not just the transcript
- recording the incident run and replaying it in CI, so the test is deterministic and doesn't call the model
- deliberately mutating the recorded run (duplicate a tool call, drop one, reorder them) to see which mutations my tests missed. The output-only tests missed all 29.

Questions for people running agents that touch real systems:

1. Do you assert on side effects (DB rows, tickets, payments) in tests, or only on outputs and traces?
2. How do you handle retries and idempotency for tool calls? In the agent, in the tool, or both?
3. How do you keep CI deterministic and cheap: recorded responses, mocks, or live calls with a budget?

Disclosure: I maintain an open-source framework built around this approach. Per the sub rules the link is in the weekly project thread, not here.

document fetched 2026-11-16 00:18 · canonical https://reddit.com/r/AI_Agents/comments/1xwxphk/my_agents_output_tests_stayed_green_while_it