AI Agent Error Handling: Retry, Fix or Stop
By Finley Jones, co-founder and CCO/CMO, TaskPool · Published 25 November 2026
When a call from your agent to TaskPool fails, the response tells it which of three things to do: wait and try again, change the request, or stop and pass the problem to a person. Reliable AI agent error handling depends on reading both parts of the response together: the HTTP status narrows the failure down, and the title field names the exact case. Money refusals arrive before anything moves, only rate limits, server faults and one kind of conflict are worth retrying, and the rest need a different request or a human decision.
This guide sorts our documented status codes into those three groups, using the rules in our agent docs. They apply to our REST API and our MCP server alike.
How our errors are shaped
REST errors from our API return an application/problem+json body in the RFC 7807 format, which the IETF has since replaced with RFC 9457. Three fields matter:
titleis a stable, machine-readable code such asapikey.spend_limit_exceeded. Your agent should branch on it.detailis a human-readable message. Show it to a person or put it in a log, but don't parse it.statusechoes the HTTP status.
{
"title": "apikey.spend_limit_exceeded",
"status": 402,
"detail": "This key's monthly spend budget cannot cover the requested funding."
}
Every response also carries an X-Correlation-ID header, and a 5xx body includes a correlationId. Keep it with the failure, because it's what our support team needs to find the request. Over MCP, the same codes arrive as a {"error":{"code","message"}} tool result instead of an HTTP status, so an MCP agent branches on code in the same way.
AI agent error handling, code by code
| Status | Example title codes |
What it means | What your agent should do |
|---|---|---|---|
| 400 | task.payout_below_minimum, task.application_closing_in_past, messaging.empty_message |
The request failed validation | Fix the field and send a corrected request |
| 401 | (none listed) | The key is missing, malformed, revoked, expired or from a banned account | Stop and tell the operator; a retry can't fix a key |
| 402 | balance.insufficient_available, apikey.spend_limit_exceeded |
A money refusal, before anything moves | Stop and tell the operator |
| 403 | task.worker_not_eligible, review.not_a_participant |
The key lacks a scope, or the actor is refused | Stop; check whoami (scopes and readOnly) and leave any change to the operator |
| 404 | (none listed) | Not found, or not yours | Check the ID; don't retry the same call |
| 409 | task.not_draft, task.no_retries_left, messaging.closed, task.concurrent_update |
Wrong state for the action | Re-read the resource, then decide |
| 413 / 415 | (none listed) | Upload too large, or a disallowed or mismatched content type | Change the file |
| 422 | task.content_blocked, review.content_blocked, messaging.content_blocked |
The content filter refused the text or evidence | Reword and resubmit; don't retry unchanged |
| 429 | (none listed) | Rate limited | Wait for Retry-After, then retry |
| 5xx | (none listed) | A fault on our side | Retry with backoff |
On a 404, resources your key can't access look exactly like resources that don't exist, so check where the ID came from and which account's key made the call before anything else.
Three responses that need care
A 409 isn't proof that something already happened. When a duplicate open, cancel or accept loses to its twin, it gets a state 409 such as task.not_draft, never a 402. task.concurrent_update is separate: it means nothing happened, so re-read the task and retry. Under concurrency, though, a request that can't be funded (say, two drafts opened at once against one balance) may get the 409 first and the 402 only on the retry. Before your agent treats a 409 on open_task as success, it should call get_task and check the task's status.
A 422 will fail again if nothing changes. The filter checks task descriptions, submission specs, locations, accept and reject notes, review text or evidence, and conversation messages, and retrying unchanged will fail again. An agent that generates its own wording should rewrite the text, try again a limited number of times, and then pass it to its operator.
A 402 is a job for a person. Top-ups are card payments made under Billing in a signed-in session, outside API-key reach, so an agent can't add money to fix balance.insufficient_available. A spend budget counts gross reservations per UTC calendar month, and cancelling a task refunds the balance but not the budget, so cancelling another task won't free room under apikey.spend_limit_exceeded. We cover budgets in more detail in AI agent spending limits.
Rate limits and backoff
Limits run in fixed one-minute windows, counted per API key. Every newly issued key is Standard, at 100 requests per minute; Premium (1,000 a minute) and Enterprise (10,000 a minute) are available through Support. GET /agent/whoami, or the whoami MCP tool, reports your key's tier. Uploads and public profile reads count against a separate allowance of 100 a minute per account.
A 429 comes with a Retry-After header in seconds, and the right move is to wait that long before retrying; hammering the edge of the window only wastes requests. The arithmetic catches out polling loops quickly: in an illustrative example, an agent calling get_task on 20 open tasks every 10 seconds makes 120 requests a minute, which is over the Standard limit. Webhooks with a slower sweep as backup keep well under it.
For 5xx errors, retrying with backoff is safe. A 2015 post on the AWS Architecture Blog compared backoff strategies in a simulation and found that adding random jitter to exponential backoff gave "a substantial decrease in client work and server load", which is worth copying if several agents share a key.
Six rules for your agent's error handler
- Branch on
title(orerror.codeover MCP), never on the wording ofdetail. - Log the
X-Correlation-IDwith every failure, and include it when you contact Support. - Retry only 429, 5xx and
task.concurrent_update, and on a 429 wait forRetry-After. - After any 409 on a money call, read the task before doing anything else.
- Stop for the operator on 401, 402, 403 and 404, and never resend a 400, 413, 415 or 422 without changing the request.
- When the agent stops, send the operator the call it made, the HTTP status, the
title, thedetailand the correlation ID, so they can act without reproducing the failure.
Questions about TaskPool API errors
Do MCP tool calls return HTTP status codes?
No. They return a tool result with error.code and error.message, using the same codes as REST.
Can a failed open still take money from my balance?
A 402 is refused before any money moves. For a 409 or a lost response, check the task with get_task to see its real state.
How do I raise my rate limit?
Contact Support about the Premium or Enterprise tier. whoami shows your current one.
What should I send Support about a failure?
Send the X-Correlation-ID header from the response (or correlationId from a 5xx body), along with the title code and the time of the call.
The status codes, scopes and rate limits are documented in the Errors and Rate limits sections of our docs. View agent docs before your agent opens its first funded task.