# Error handling and retries

> Error handling and retries are the parts of an automation or AI system that detect failed steps, try them again where that is safe, and report or park the work that still fails, so problems are noticed rather than silently lost.

Also called: error handling, retry logic, exponential backoff, dead-letter queue, failure handling. Category: Delivery and quality. Source: https://aibuildindex.com/glossary/error-handling

## In the index

- Workflow automation: median $1,600, middle half $300 to $6,000, 7,018 priced briefs (https://aibuildindex.com/skills/workflow-automation)
- n8n workflow automation: median $1,200, middle half $250 to $5,200, 2,395 priced briefs (https://aibuildindex.com/cost/workflow-automation-n8n)

Every automation that talks to other systems will fail sometimes. An API times out, a model returns malformed output, a rate limit is hit, a record is missing a field. Error handling is the deliberate design of what happens next. It is the clearest difference between a demo that works on the day and a system that can run unattended for months, and it is a common gap in low-priced builds.

## How it works

Good error handling starts by sorting failures into two kinds. Temporary failures, such as a timeout or a [rate limit](https://aibuildindex.com/glossary/rate-limit), are worth retrying. Permanent failures, such as invalid data or a revoked password, will fail again however often they are retried and need a person.

Retries are usually spaced out with exponential backoff: wait one second, then two, then four, with a little randomness so many callers do not retry at once. After a set number of attempts the item is moved aside to a "dead-letter" list or [message queue](https://aibuildindex.com/glossary/message-queue) for later inspection, and an alert is sent. With language models there is a third case: the call succeeds but the output is wrong or does not match the expected format. Builds that rely on [structured output](https://aibuildindex.com/glossary/structured-output) typically validate each response and retry or flag it when validation fails.

An example: an order sync pushes orders from a shop into a warehouse system. If the warehouse API is down, the sync retries with backoff for a while; if an order has an invalid postcode, it skips the retries, logs the reason and posts the order to a review channel so someone can fix it.

## What it means for cost

Error handling adds build time that is easy to cut from a quote and expensive to add later. Questions that reveal whether it is included:

- What happens to a record when a step fails? Is it retried, logged, or lost?
- Who is alerted, and through which channel?
- Can failed items be rerun safely without creating duplicates? That depends on [idempotency](https://aibuildindex.com/glossary/idempotency).
- Is there a log or dashboard showing failures over time? See [observability](https://aibuildindex.com/glossary/observability).

A builder who answers these clearly is pricing a production system. One who does not may be pricing a prototype. Platforms such as n8n include error workflows and retry settings; live figures for those builds are on the [n8n workflow cost page](https://aibuildindex.com/cost/workflow-automation-n8n).

## Common mistakes

The most common mistake is catching an error and carrying on without telling anyone, so data quietly goes missing. The second is retrying everything indefinitely, which can hammer an external service, run up model costs and create duplicate records.

## Common questions

### How many times should a step be retried?

There is no universal number; three to five attempts with growing gaps is a common starting point for temporary errors. What matters more is that permanent errors are not retried at all and that anything still failing ends up somewhere a person will see it.

### Does error handling matter for AI model calls?

Yes, more than for most APIs. Model providers have rate limits and occasional outages, and a model can return a valid response with the wrong content or format. Validating outputs and having a fallback, such as a second model or a review queue, keeps one bad response from breaking a whole run.

## Related terms

- [Idempotency](https://aibuildindex.com/glossary/idempotency): Idempotency is the property of an operation that produces the same result whether it runs once or several times, so a retried or duplicated request does not create a second invoice, email or record.
- [Rate limit](https://aibuildindex.com/glossary/rate-limit): A rate limit is a cap set by a service on how many requests, or how much data, an application can send in a given period, which AI and software providers use to share capacity and protect their systems.
- [Observability](https://aibuildindex.com/glossary/observability): Observability is the ability to see what a live system is doing and why, through logs, traces and metrics, so that errors, slow responses, rising costs and poor AI outputs can be found and explained.
- [Message queue](https://aibuildindex.com/glossary/message-queue): A message queue is a component that holds tasks or events in order until a worker is ready to process them, so systems can hand off work without waiting, absorb spikes in volume and retry failures safely.
- [Production readiness](https://aibuildindex.com/glossary/production-readiness): Production readiness is the state of a system being safe and reliable enough for real users and real data, covering security, error handling, monitoring, testing, performance and support, not just working in a demo.
- [Workflow automation](https://aibuildindex.com/glossary/workflow-automation): Workflow automation is the use of software to carry out a repeatable business process, moving data between systems and taking actions based on triggers and rules, so that people no longer do those steps by hand.
