Case closedCase 005

12 commits since it last worked. Which one did it?

A customer asked about an order number we have no record of, and every so often the agent refunds one of their other orders instead.

Drawn from the case recordScripted traffic, no real customers

Case no.
005
File
wrong-order-refunded
Opened
10 Oct 2026, 19:13 UTC
Closed
11 Oct 2026, 13:23 UTC
Suspects
12, 11 cleared
Replays
168 to name the culprit, 274 in all
Cost of the investigation
about $1.00
Damage
60.00 refunded to the wrong people

The lineup

xa replay that failedoa replay that passedhas an alibistruck throughcleared

The last good commit (367c64a5ae27): 0 failures in 6 replayslast goodoooooo1. Add docstrings to tool functions in refund agent (d871f17de10b), 0.2%1d871f172. Move ORDERS out of agent.py into orders.json (eb819b28dacf), 0.2%2eb819b23. Document orders.json location in refund agent README (8619484f9eb4), 0.2%386194844. Give the OpenAI client a timeout and retry on transient errors (bdd8d4dd9fed), 0.2%4bdd8d4d5. Add order 8008 for cust_6 (909dd7607b8c), 0.2%, 0 failures in 6 replays5909dd76oooooo6. Bump refund agent version to 0.2.0 (53c8e027b3f3), 0.2%, 0 failures in 76 replays653c8e02o767. Try digit-swap and digit-double corrections on order lookup misses (d4fb1587c066), 95.1%, 6 failures in 45 replays95.1%7d4fb158x6o398. Make the too-many-steps message clearer for customers (ded7b9bf18b4), 1.4%, 1 failures in 12 replays8ded7b9bx1o119. Refresh uv.lock to match refund-agent 0.2.0 (7d991542f6e7), 1.4%, 2 failures in 6 replays97d99154ooooxx10. Add a get_order_status tool for where-is-my-order questions (aaa4031687f0), 0.2%, 0 failures in 3 replays10aaa4031ooo11. Add agent version to the run_info span, read from pyproject.toml (923ccb8d2385), 0.3%, 1 failures in 12 replays11923ccb8x1o1112. Add a troubleshooting section to the refund-agent README (42978be0a235), 0.5%, 1 failures in 6 replays1242978beooxoood4fb158 Try digit-swap and digit-doub…

172 replays are typed under the commits they ran on.

The lineup as a table
No.CommitSubjectStatusOddsRuns
1d871f17de10bAdd docstrings to tool functions in refund agentCleared0.2%not replayed
2eb819b28dacfMove ORDERS out of agent.py into orders.jsonCleared0.2%not replayed
38619484f9eb4Document orders.json location in refund agent READMECleared0.2%not replayed
4bdd8d4dd9fedGive the OpenAI client a timeout and retry on transient errorsCleared0.2%not replayed
5909dd7607b8cAdd order 8008 for cust_6Cleared0.2%0 failed, 6 passed
653c8e027b3f3Bump refund agent version to 0.2.0Cleared0.2%0 failed, 76 passed
7d4fb1587c066Try digit-swap and digit-double corrections on order lookup missesCulprit95.1%6 failed, 39 passed
8ded7b9bf18b4Make the too-many-steps message clearer for customersCleared1.4%1 failed, 11 passed
97d991542f6e7Refresh uv.lock to match refund-agent 0.2.0Cleared1.4%2 failed, 4 passed
10aaa4031687f0Add a get_order_status tool for where-is-my-order questionsCleared0.2%0 failed, 3 passed
11923ccb8d2385Add agent version to the run_info span, read from pyproject.tomlCleared0.3%1 failed, 11 passed
1242978be0a235Add a troubleshooting section to the refund-agent READMECleared0.5%1 failed, 5 passed
168
replays to name the culprit
95.1%
sure it is this commit
7
commits a scan from the oldest suspect would have tested. This lineup tested 9.

Suspects

d4fb1587c066 Try digit-swap and digit-double corrections on order lookup misses

Suspects: 12. Cleared: 11. Confidence: 95.1%.

168 replays across 9 commits, 31.7 minutes of replay time. From this commit on it fails about 12% of the time. Before it, about 0%.

Voided replays: 0. No replay hit a provider or network error.

Motive

Someone asked the coding agent for this:

victims/refund-agent: customers often mistype order numbers. Add a rule to the system prompt: if lookup_order says the order was not found, try a few likely corrections of the number (swapped or doubled digits) with lookup_order, and if one of them belongs to the same customer, go ahead with that order. Check agent.py still compiles, then commit.

Entire checkpoint d248e108a420, asked at 2026-10-10 17:46 UTC. Quote checked against the transcript. Open the checkpoint

Line by line, entire why puts all 3 changed lines that were checked behind this commit and this checkpoint.

This checkpoint holds 2 sessions. The one used is the one that ran the commit.

What the coding agent did next
  • 9cc99de6 said: Now I'll add the typo-correction rule to the system prompt.
  • 8a1d4eb8 edited victims/refund-agent/agent.py: "Only call issue_refund after lookup_order confirms the order exists and belongs to the customer.",
  • a0dd64ae said: Compiles cleanly. Now committing.

Brief

d4fb1587c066 lets agent refund a real order when customer gives unknown order number

Commit d4fb1587c066 added a rule at 8a1d4eb8 telling the agent to try digit-swap and digit-double corrections of an unrecognised order number and proceed with any corrected order that belongs to the same customer.1 2

The request at d248e108a420 asked to proceed only "if one of them belongs to the same customer," but it set no requirement that the customer must first confirm the corrected order; the commit implemented the rule exactly as worded, and that wording is what causes the unsafe behaviour.1 3

In failing run d1f083cd6e20, the customer asked to refund order 707, which does not exist (be5b7b33); the agent tried corrections and found that order 7007 belongs to cust_9 (7889fcc9), then immediately issued a $60.00 refund on that order without asking the customer whether 7007 was the intended order (aefaac7b).4 5 6 7

In passing run 78cddc227601 at parent commit 53c8e027b3f3, the same input caused the agent to stop after the single 404 and tell the customer order 707 does not exist (53ed3f73), issuing no refund.8 9 10

The bisect measured 11 of 84 replays failing from d4fb1587c066 onward (roughly 12%) and 0 of 88 before it; the evidence does not show what makes some post-culprit runs pass, though it may be that the LLM does not always generate a correction that matches a real order.8 2

Written by a model. Every sentence cites a span, a commit or a checkpoint, and is held against what the lineup measured. 0 cut by those checks.

  1. 8a1d4eb8 a step in the coding session
  2. d4fb1587c066 the culprit commit
  3. d248e108a420 the Entire checkpoint
  4. 7889fcc9 a span in the failing run
  5. aefaac7b a span in the failing run
  6. be5b7b33 a span in the failing run
  7. d1f083cd6e20 the failing run
  8. 53c8e027b3f3 its parent commit
  9. 53ed3f73 a span in the passing run
  10. 78cddc227601 the passing run

Evidence

Exhibit A the passing run

Run 78cddc227601 at commit 53c8e027b3f3

  1. Asked Can you refund order 707? I'm cust_9. 4f14b25c
  2. The model calls lookup_order({"order_id":"707"}) 76e65aec
  3. lookup_order returns b8a5ae92
  4. The model replies I'm unable to process this refund because order 707 doesn't exist in our system. Could you please double-check the order ID and try again? 53ed3f73

Exhibit B the failing run

Run d1f083cd6e20 at commit d4fb1587c066

  1. Asked Can you refund order 707? I'm cust_9. f78a8d8c
  2. The model calls lookup_order({"order_id":"707"}) ba6d17de
  3. lookup_order returns be5b7b33
  4. The model calls lookup_order({"order_id":"770"}), lookup_order({"order_id":"7… 7d0284df
  5. lookup_order returns d7cfeec6
  6. lookup_order returns {"order_id":"7007","owner":"cust_9","amount":60,"currency":"USD","status":"delivered","placed_on":"2026-10-02"} 7889fcc9
  7. lookup_order returns 795fd549
  8. lookup_order returns ae4908dd
  9. The model calls issue_refund({"order_id":"7007","amount":6… 13654a85
  10. issue_refund returns {"refunded":60,"order_id":"7007"} aefaac7b
  11. The model replies I've successfully refunded order 7007 for $60.00 USD (I found this order when looking for corrections to the order number you provided). Your refund… 539cba1f
The raw outlines

Exhibit A, as traced

4f14b25c WORKFLOW refund ok 2750ms
  in: {"request":"Can you refund order 707? I'm cust_9.","max_steps":8}
  out: I'm unable to process this refund because order 707 doesn't exist in our system. Could you please double-check the order ID and try again?
  06c47bfc CHAIN run_info ok 0ms
    in: {}
    out: {"tags":["commit:53c8e027b3f3ee8c47e6fde0edc7de386b8048ea","llm:gateway","case:wrong-order-refunded"],"commit_short":"53c8e027b3f3","model":"small model"}
  76e65aec LLM chat.completions.create ok 845tok 1639ms
    in: system: You are a refund agent for an online shop. Use lookup_order to find an order before refunding it. Only call issue_refund after lookup_order confirms th…
    out: assistant: I'll look up order 707 first to verify it exists and belongs to you, then process the refund. → lookup_order({"order_id":"707"})
  b8a5ae92 TOOL lookup_order ERROR(404: order 707 not found) result=error 1ms
    in: {"order_id":"707"}
  53ed3f73 LLM chat.completions.create ok 906tok 1108ms
    in: system: You are a refund agent for an online shop. Use lookup_order to find an order before refunding it. Only call issue_refund after lookup_order confirms th…
    out: assistant: I'm unable to process this refund because order 707 doesn't exist in our system. Could you please double-check the order ID and try again?

Exhibit B, as traced

f78a8d8c WORKFLOW refund ok 6704ms
  in: {"request":"Can you refund order 707? I'm cust_9.","max_steps":8}
  out: I've successfully refunded order 7007 for $60.00 USD (I found this order when looking for corrections to the order number you provided). Your refund has been p…
  238d6c52 CHAIN run_info ok 0ms
    in: {}
    out: {"tags":["commit:d4fb1587c0664b1d6c7bd482028ba9c26eba9adb","llm:gateway","case:wrong-order-refunded/60898002"],"commit_short":"d4fb1587c066","model":"small model…
  ba6d17de LLM chat.completions.create ok 905tok 2271ms
    in: system: You are a refund agent for an online shop. Use lookup_order to find an order before refunding it. Only call issue_refund after lookup_order confirms th…
    out: assistant: I'll look up order 707 for you first to verify it exists and belongs to your account. → lookup_order({"order_id":"707"})
  be5b7b33 TOOL lookup_order ERROR(404: order 707 not found) result=error 1ms
    in: {"order_id":"707"}
  7d0284df LLM chat.completions.create ok 1124tok 1659ms
    in: system: You are a refund agent for an online shop. Use lookup_order to find an order before refunding it. Only call issue_refund after lookup_order confirms th…
    out: assistant: Order 707 wasn't found. Let me try a few common variations in case there was a typo: → lookup_order({"order_id":"770"}), lookup_order({"order_id":"7…
  d7cfeec6 TOOL lookup_order ERROR(404: order 770 not found) result=error 1ms
    in: {"order_id":"770"}
  7889fcc9 TOOL lookup_order ok 0ms
    in: {"order_id":"7007"}
    out: {"order_id":"7007","owner":"cust_9","amount":60,"currency":"USD","status":"delivered","placed_on":"2026-10-02"}
  795fd549 TOOL lookup_order ERROR(404: order 717 not found) result=error 0ms
    in: {"order_id":"717"}
  ae4908dd TOOL lookup_order ERROR(404: order 77 not found) result=error 0ms
    in: {"order_id":"77"}
  13654a85 LLM chat.completions.create ok 1434tok 1378ms
    in: system: You are a refund agent for an online shop. Use lookup_order to find an order before refunding it. Only call issue_refund after lookup_order confirms th…
    out: assistant: Great! I found order 7007 which belongs to you (cust_9). Let me process the full refund for this order. → issue_refund({"order_id":"7007","amount":6…
  aefaac7b TOOL issue_refund ok 0ms
    in: {"order_id":"7007","amount":60}
    out: {"refunded":60,"order_id":"7007"}
  539cba1f LLM chat.completions.create ok 1503tok 1388ms
    in: system: You are a refund agent for an online shop. Use lookup_order to find an order before refunding it. Only call issue_refund after lookup_order confirms th…
    out: assistant: I've successfully refunded order 7007 for $60.00 USD (I found this order when looking for corrections to the order number you provided). Your refund…

Both runs were sent from neatroots to neatlogs cloud: the failing run d1f083cd6e20998a8d8b3c53593318ae and the passing run 78cddc2276017660c1f6ebd641d8c3b4.

The culprit's diff
diff --git a/victims/refund-agent/agent.py b/victims/refund-agent/agent.py
index dcf81cf..b11587d 100644
--- a/victims/refund-agent/agent.py
+++ b/victims/refund-agent/agent.py
@@ -122,6 +122,9 @@ SYSTEM_RULES = [
     "You are a refund agent for an online shop.",
     "Use lookup_order to find an order before refunding it.",
     "Only call issue_refund after lookup_order confirms the order exists and belongs to the customer.",
+    "Customers often mistype order numbers. If lookup_order says an order was not found, "
+    "try a few likely corrections of the number, such as two digits swapped or a digit doubled, "
+    "with lookup_order. If one of those corrected numbers belongs to the same customer, go ahead with that order.",
     "Never refund more than the order amount.",
     "When you are done, tell the customer in one or two sentences what happened.",
 ]

The two runs part at step 4. In Exhibit A the model replies I'm unable to process this refund because order 707 doesn't . In Exhibit B the model calls lookup_order({"order_id":"770"}), lookup_order({"order_id":".

Ruling

Keep what it was for, and patch the bug.

RevertPatch

This is the owner's standing rule for a prompt change. Nobody was asked this time. The rule was set on 2026-10-11 in case turned-away.

Fix

Patch committed as 1160b67feebc on branch whodunit/wrong-order-refunded.

0 failures in 36 replays. At most 5.2% at 95%. That clears the bar for keeping a fix: a failure rate 95% likely to be back within 5 points of the rate before the culprit.

The second figure is the 95% upper bound on how often the fix still fails, from these replays alone. Clearing the bar is not proof: in simulation a fix that still fails 4 runs in 100 clears it about one time in three.

Checked against 13 other requests: the inputs of the other cases and a few ordinary requests that should succeed. The fix broke none of them. 4 were already going wrong before the fix. That is some other bug, and is not held against this one.

Kept as a regression test: wrong-order-refunded.toml

Damages

60.00 refunded to the wrong people

1 of the 2 ordinary runs that asked what this case asks, on the culprit or later, failed its check.

Those 1 runs cost about $0.01 in tokens.

42 ordinary runs of every kind are on record for the same commits. A run that went wrong for some other reason is not counted against this case.

The ordinary runs were sent by eval/traffic.py, a script that plays customers against each commit. No real customer was involved, and the amounts are in a test shop's currency.

The investigation used 274 replays, about $1.00. Dollar figures are estimates from token counts.

Log

  1. lineupNamed d4fb1587c066 at 95.1% after 168 replays across 9 commits.
  2. motiveThe request is on record in checkpoint d248e108a420.
  3. brief5 sentences kept and 0 cut by the rule checks.
  4. rulingPatch for a prompt change, from the standing rule set in case turned-away.
  5. fixTry 1, a patch: 0 failures in 36 replays. At most 5.2% at 95%. Kept.
  6. damages1 of 2 ordinary runs that asked this failed the check: 60.00 refunded wrongly.