← Prompting & System Design
04 · Prompting & System Design · Topic 03

What is Failure Handling?

Failure handling defines what an AI system should do when the expected result is not produced.

What is it?

Failure handling is the plan for what an AI system does when a request, tool call, or output fails.

Possible responses include retrying, using a fallback, asking for missing information, returning an error, requesting human review, or stopping safely.

Think of it like...

Think of it like an emergency plan.

A building does not assume that nothing will go wrong. It defines what people should do when power fails or a route is blocked. AI systems also need clear paths for failure.

How it works

1 · DetectFind the failureCheck errors, timeouts, schema, and evidence.
2 · ClassifyUnderstand the causeSeparate transient, input, tool, and safety failures.
3 · ChooseSelect a responseRetry, fallback, ask, review, or stop.
4 · RecoverTake the safe pathContinue only when the result is usable.
5 · RecordLearn from the eventLog the failure and improve the system.

Real-world examples

Business example · Invalid JSON

Input: a request for structured data

System: receives an invalid response and retries or returns a validation error

Output: valid data or a controlled failure

AI product example · Tool outage

Input: a request that needs an external API

System: detects a timeout and uses a fallback or asks the user to try later

Output: a clear status instead of a fabricated result

What it is NOT

Failure Handling ≠ Retry Only

Failure handling: includes retry, fallback, review, and safe stop.

Retry: only one possible response.

Failure Handling ≠ Error Message

Failure handling: defines the system's next action.

Error message: communicates that something went wrong.

Failure Handling ≠ Ignoring Errors

Failure handling: makes uncertainty visible.

Ignoring errors: lets the system continue without a safe result.

Remember this

A reliable AI system defines what to do when the expected result is missing or invalid.

Independent explainer

Video

visual explainer
↑