Find out why your support agent breaks refund policy: replay real tickets as JSON decisions, then let code enforce the rule
A solo operator's support agent kept refunding outside a 30-day window. Replaying 30 real cases 20 times each showed rule position, prompt length and a vague 'be flexible' line caused it; code now makes the final call.
Evidence: The source shows its work: steps, screenshots, code or data you can inspect.
The business problem
An AI support agent granted a refund on day 47 under a 30-day policy, logged it as a success, and the owner only noticed through the payment notification. Rewording the prompt did not stop it recurring, and every wrong decision cost real money.
What was tried
1. Force the agent to return a structured decision (decision, days since purchase, reason code, confidence) instead of a prose reply, so each answer can be checked. 2. Build about 30 test cases from real support transcripts, and write the expected decision for each from the actual policy document before running anything. (The author's first set, written from memory of the prompt, missed rules and passed while measuring nothing.) 3. Run each case about 20 times per prompt version through the Anthropic API with a short Python script and record how often the expected decision comes back. The author spent under $30 across five prompt versions. 4. Use the results to fix the prompt: move the policy rule where it wins (in the author's tests, the bottom of the prompt), scope tone lines so they cannot override decisions ('flexible in wording, never in the decision'), put the worked example right under the rule it shows, and cut length. 5. Do not delete rules that look redundant without re-testing: removing a separate 'chargeback threats always escalate' line let a chargeback case through to a refund. 6. Move the policy itself into ordinary code: a small function checks the agent's JSON against the policy table, and when code and model disagree the ticket goes to a person and is logged. Keep the prompt for tone, extraction and formatting.
What was reported (mixed)
The author reports that rule compliance depended heavily on placement (94% at the bottom, 23% at the top in their 30-case test), fell from 96% to 18% as the prompt grew from 190 to 1,410 words, and rose from 41% to 96% on late-refund cases after one scoping clause. A trimmed rule cost about $340 in wrong refunds over eleven days before it was caught. The final fix was a short code check plus a 240-word prompt. No figures after the change are given beyond these test results.
Limitations
Self-reported by a single operator with no inspectable logs or full test set; only parts of the code are shown. Percentages come from the author's own 30 cases and one model, so they may not carry over. The post ends by selling the author's own prompt pack, so it is labelled vendor. The account belongs to a series of very similar dramatic posts published almost daily, so treat details with some caution. Business type and size are not stated beyond a store with refunds and Stripe.
What you need
An AI agent that handles support or refunds through an API, access to past support transcripts, and enough Python to run a test loop.
Write the expected answer for each test case from your policy document, not from your prompt.
Sources
- DEV Community (ULNIT) ↗ Vendor case study, published October 30, 2026
Source published: October 30, 2026. Last reviewed here: November 2, 2026. Spot a mistake? Tell us.
Tools in this workflow
- Stripe: Payments, where the wrong refunds showed upTry Stripe
- Anthropic API (Claude): Model behind the support agent and the test runsTry Anthropic API (Claude)
Get new workflows like this by email
A short selection of the most useful new workflows, including the ones that did not work. Free, and you can unsubscribe at any time.
Related workflows
Keep your first 100 customers by hand with a free Claude Code retention skill: first result, weekly check, support templates and an honest cancel flow
A free, open-source Claude Code skill walks a solo founder through retention before 100 customers: define the first result, a 15-minute weekly check, simple support replies, a feedback loop and a no-dark-patterns cancellation flow.
A Claude-built support inbox that drafts replies, pulls orders and learns from the owner's edits
A small online seller had Claude build Relay, an internal web app that turns email, Facebook and Instagram messages into tickets every 10 minutes, drafts replies with order data, and handles cancellations and returns after his approval.
What AI agents running a small software shop could not do alone: a dated list of human hand-offs
Four AI agents that build and sell small software logged every step they needed a person for. Nineteen steps in about five weeks, with median wait of a day and one stuck for 16 days.
Let a team of AI agents run an X account for five days: big reach, almost no money
A one-person studio let AI agents post and reply on X for five days. Reach passed a million impressions, followers rose by about 60, and sales totalled $4.99.