In the demo the agent finds the right invoice, matches it to the order and prepares the accounting entry. In the first real week the order number is missing, a document is unreadable, the API does not respond. What ran cleanly in the demo is now a pile of cleanup on someone's desk.
Before you swap the model, take that one failed run apart. Were the invoice and the order in the context the agent could see? Did it read the details and still decide wrong? Or did it stall on the failure because nobody had said what should happen next? Those are three different fixes. A new model is a candidate only for the second case. Examples or a tighter task can fix that same failure too.
Not every process needs an agent
When the steps are fixed, a fixed workflow is often easier to test. The model classifies the document; ordinary code handles matching and storage. An agent is the right tool when the next step depends on the intermediate state and cannot reasonably be fixed in advance: a missing receipt, an unclear supplier, a second document that overturns the first match.
Building effective agents separates those fixed workflows from processes the model directs. Ask it more narrowly. Which decision does the model have to make while the run is underway? If there is none, the extra autonomy mostly buys you more states that can go wrong.
A failure list that points at the fix
| Observation | Investigate first | Useful change |
|---|---|---|
| Invented customer agreement | Was the agreement accessible in context? | Improve data access and source evidence |
| Correct information, wrong conclusion | Were the task and decision criteria explicit? | Review examples, model or task decomposition |
| Tool call with wrong parameters | Are names, types and error messages clear? | Simplify the interface and validate inputs |
| Action executed twice | Was its status unclear after a timeout? | Check execution state and design for idempotency |
| Task runs indefinitely | Is completion objectively verifiable? | Add stopping conditions, time and call limits |
| Good result, no economic benefit | Does it remove work from the whole process? | Include handoffs and review in the calculation |
An API error is not a completed task. A tidy closing message is not one either. It does not show that the accounting entry exists in the system, or that the file is where it should be.
Test outcomes, not just replies
For the first set, take ordinary cases, edge cases and known failures from your own process. The cases you build the agent on and the held-out set for acceptance stay apart. Otherwise you tune for tasks whose quirks you already know.
Invoice review: Check separately whether the supplier and amount were identified correctly, the purchase order was matched, and missing evidence triggered an escalation. “Do not book” can be exactly the response you want when the data is incomplete. Count the escalations that were unnecessary. A system that refuses everything otherwise looks clean.
Run the same cases more than once. The same agent does not react the same way every time. Keep model version, configuration, tools and test data on record. Anthropic's agent evaluation guide separates task, trial, trace and grading. You still set the bar for when an invoice is actually done.
Long runs need checks in the middle
A simplified calculation, and no more than that: ten required steps, each correct 95% of the time, treated as independent. The whole run then succeeds with probability 0.95^10 ≈ 59.9%. Real errors are not independent. The figure is not a performance promise. It only shows why a strong single answer does not carry the process.
Read the handoffs from the destination system, not from the model’s own report. Is the file there? Was the payment only prepared, or already sent? Was the order approved?
Write access follows a run that held up
Start in shadow mode. The agent writes proposals; the destination system stays untouched. Then a narrow deployment, with a person approving. Further permissions only for the task you actually tested, not for the agent in general.
Writes that can be repeated need a plan for the second call. Stripe’s documentation describes the idempotency-key principle: retries of the same intended action should not create multiple effects. What is actually guaranteed depends on the API. For payments on a blockchain, the nonce of a transaction plays a partly similar protective role. You can read nonce and recipient from a signed raw transaction in the Transaction Decoder.
Before you widen the deployment, it has to be clear who handles exceptions, how a bad run stops, and how you undo what it did. A pilot is useful when it shows that boundary. That includes the case where a step stays with a person.
Further reading by level
| Source | Type | Level | What for |
|---|---|---|---|
| Building effective agents | Vendor guide | Beginner | The distinction between fixed workflows and model-driven agents; vendor perspective. |
| A practical guide to building agents | Vendor guide (PDF) | Beginner | When an agent is worth it, structure and guardrails; vendor perspective. |
| Demystifying evals for AI agents | Vendor guide | Intermediate | Separating task, trial, transcript and grading. |
| τ-bench | Research paper, 2024 | Advanced | Uses the pass^k metric to test whether an agent repeats the same result. According to the abstract, even strong models then solved under 50% of tasks, and under 25% across eight repetitions in the retail scenario. As of 2024. |
| SWE-bench | Benchmark paper, 2023 | Advanced | 2,294 real software tasks from GitHub; shows how agents are measured on real tasks rather than demos. |
| ReAct | Research paper, 2022 | Advanced | The idea of interleaving reasoning steps and actions, the basis of many agent loops. |
| OWASP: Excessive Agency | Security standard | Intermediate | What happens when an agent has too many permissions or too much autonomy; fits the section on write access. |
| Stripe: Idempotent requests | API documentation | Intermediate | A concrete example of handling duplicate calls. |
What a run like this costs is worked through in What an AI agent actually costs. How you hold the benefit against a baseline and quality limits is in How to actually measure AI agent ROI. When the agent pays, the questions are approvals, fees and duplicate payments: When AI Agents Pay: Approvals, Fees and Preventing Duplicate Payments. Keys and spending limits: AI Agent Wallets: Protect Keys and Enforce Spending Limits.
Sources:
- Building effective agents — workflow and agent architectures; provider perspective.
- Demystifying evals for AI agents — repeatable evaluations; provider perspective.
- Stripe: Idempotent requests — a specific API example, not a universal guarantee.
- The diagnostic table and probability example are original teaching aids.
Continue reading