AI agent retries and idempotency: how to stop duplicate tool calls
AI agent retries can send the same email twice or create two tickets. How idempotency keys, call IDs and tool design make agent tool calls safe to retry.
AI automation vs RPA vs Zapier-style workflow tools is a question about inputs, not hype. How to match each to the process, where they combine, and the mistakes that make automation brittle.
A team with a slow manual process usually hears three pitches at once: buy an RPA licence, wire it up in a workflow tool, or build an AI agent. The AI automation vs RPA question gets argued as if one must win. In practice they solve different problems, and the expensive mistake is using the wrong one for a step, not picking the wrong brand.
RPA (robotic process automation) records or scripts what a person does on screen: open this app, copy this field, paste it there. It is deterministic. Given the same input it does the same thing, which is its strength and its weakness.
Workflow tools (Zapier, Make, n8n and similar) connect apps through their APIs: when X happens here, do Y there, with some branching. They are also deterministic, but they work with data, not screens, so they tend to break less often than screen-scraping.
AI automation puts a model in the loop to read unstructured input and decide or generate something: classify an email, extract fields from a PDF, draft a reply, pick the next step. Its output is probabilistic, so it needs checks that the other two do not.
| Workflow tool | RPA | AI automation | |
|---|---|---|---|
| Best input | Structured data via API | Structured data on a screen | Emails, documents, free text |
| Behaviour | Deterministic | Deterministic | Probabilistic |
| Typical failure | Missing integration, bad mapping | UI change breaks the script | Wrong answer that looks right |
| Handles variation | Poorly | Poorly | Well |
| Cost per run | Very low | Low | Higher (model calls) |
| Audit trail | Run history | Run logs | Needs deliberate logging |
| Fix when it breaks | Edit the flow | Re-record the script | Change prompt, add eval case |
The "typical failure" row is the one to read twice. Deterministic tools fail loudly: the run errors and someone gets an alert. AI fails quietly, returning a plausible wrong answer. That is why AI steps need the controls covered in our posts on human-in-the-loop approval and LLM output guardrails.
Use the simpler tool when all of these hold:
Adding a model to a step that a lookup table could do makes it slower, costlier and less predictable. If a rule can be written down, write it down. RPA specifically earns its place where the only way into a system is its screen, such as a legacy desktop app with no API. Even then, treat it as a bridge: scripts that depend on a UI break when the UI changes.
AI pays off where a person currently reads something before acting: triaging a shared inbox, pulling terms out of supplier contracts, categorising support requests, summarising a case before handoff. The human cost there is interpretation, and that is exactly what a model removes.
Two checks before you commit:
Most processes that work in production are hybrids, with the model confined to the step that needs interpretation:
Keeping execution deterministic means the model never touches a system directly. That also makes retries safe if you design for idempotency, as described in AI agent retries and idempotency. For the structured-output step, see LLM structured output in production.
A fixed pipeline with one model call is not an agent, and often should not be one. Agents, where the model chooses its own tools and sequence, add cost and failure modes. Reach for one only when the path genuinely cannot be known in advance. The buyer's framework for agents vs chatbots and the post on why AI agents fail in production explain the trade-off.
Take one process and write out its steps. For each step, mark the input as structured or unstructured, and the action as reversible or not. Then:
Then estimate the saving honestly, including model costs, review time and maintenance. Our guide to an AI automation ROI you can defend walks through that arithmetic.
If you have a process in mind and are unsure which layers it needs, see how we approach AI automation or send a short brief and we will tell you which steps need AI and which do not.
Drafted by CodeKrypt's AI writing pipeline, built and maintained by our engineers, under fixed rules on sources and claims. How we write
AI agent retries can send the same email twice or create two tickets. How idempotency keys, call IDs and tool design make agent tool calls safe to retry.
MCP vs function calling is not either/or: function calling is how a model asks for a tool, MCP is how tools are packaged and served. When each fits, and what each means for security and maintenance.
Human-in-the-loop AI agents need approval gates only where actions are costly or irreversible. How to decide which actions to gate, which review pattern fits, and how to avoid approval fatigue.