Errors
This page covers the errors both HTTP APIs return and the Evals CLI’s exit codes.
Where the APIs differ
| Evals API | Agent API | |
|---|---|---|
| Body | { "error": "<message>", "code": "<code>", "details": [...] } | { "type": "error", "error": { "type": "<type>", "message": "<message>" }, "request_id": "<id>" } |
| Branch on | The status and code | The status and error.type |
429 body | Its own shape, shown on Limits | The same shape as every other error, with error.type rate_limit_error |
| Status codes | Evals API status codes | Agent API status codes |
Evals API error format
| Field | Type | Meaning |
|---|---|---|
error | string | A message for people. Don’t parse it; its wording can change. |
code | string | A stable code for programs, when the error has one. |
details | array | On 400, one entry per parameter that failed, with its path and a message. |
Code
A 429 body has its own shape, shown on Limits; rely on its status and Retry-After.
Evals API status codes
| Status | code | When | What to do |
|---|---|---|---|
400 | (none) | A parameter fails its schema. | Fix the parameters details names. |
400 | SEARCH_NOT_TOKENIZABLE | A trace search has no word the index can match, such as only punctuation. | Search for words or numbers. |
400 | (none) | On GET /runs/{runId}/tasks or GET /runs/{runId}/tasks/{taskId}, the cellId, cursor or taskId isn’t part of this run, or the run is from before per-task records were kept. | Use values from this run’s own responses. |
400 | INVALID_CURSOR | A trace cursor is malformed or no longer valid, for example after your deployment was upgraded. | Start again without cursor. |
401 | (none) | The request has no task API key, or the key is unknown, revoked or expired. | Send a valid key. See API keys. |
403 | TASK_CAPABILITY_MISSING | The key lacks evals:read, or evals:write for an endpoint that changes data. | Create a key with Read evals, and Change evals for writes. |
403 | (none) | The key is limited to specific agents, and the endpoint isn’t a trace read, /feedback/enabled or /feedback/schemas. | Use a key that isn’t limited to agents. |
403 | (none) | The key’s owner lacks the access the endpoint needs. | Ask an admin for Evals access. |
403 | (none) | A list was read without workspaceScope, and the key’s owner has Evals access in more than one workspace but isn’t an organization admin. The message begins with the words Name a workspace. | Send workspaceScope, as in the quickstart. |
404 | (none) | The resource doesn’t exist in your organization. The response is the same whether it doesn’t exist or belongs to another organization. | Check the ID. |
405 | (none) | The path doesn’t take this method. The Allow header lists the methods. | Use a method from Allow. |
400 | idempotency_key_empty | An Idempotency-Key header was sent empty. | Send a key you chose, such as a UUID, or leave the header out. |
409 | idempotency_in_progress | A request with the same Idempotency-Key is still running. | Retry after it finishes. |
413 | (none) | A request body is larger than 1 MiB. | Send a smaller body. |
415 | (none) | A request body isn’t sent as Content-Type: application/json. | Send JSON. |
422 | idempotency_key_reused | The Idempotency-Key was already used on a different request. | Use a new key for a new request. |
429 | (none) | The key exceeded the rate limit, on a deployment that enforces it. | Wait for the seconds in Retry-After, then retry. See Limits. |
500 | QUERY_FAILED | A trace query failed. | Retry with backoff. |
500 | (none) | An unexpected server error. | Retry with backoff. |
503 | (none) | A filter (workflow, error message) couldn’t be applied. | Retry with backoff. |
503 | CLICKHOUSE_UNAVAILABLE | This deployment has no trace store configured, so trace data can’t be read. | Don’t retry; ask your administrator. |
503 | TRACE_READ_SOURCE_UNRESOLVED | The server is still locating this request’s trace data. It clears on its own. | Retry with backoff; if it persists, contact your administrator. |
Codes are case-sensitive; compare them exactly as shown.
A 401 body:
Code
A 403 body for a missing capability:
Code
A 404 body:
Code
Evals API retries
Retry only 429, 500 and 503, but not a 503 with code CLICKHOUSE_UNAVAILABLE, which doesn’t clear on its own. For 429, wait for the Retry-After seconds. For 500 and 503, back off exponentially, for example after 1, 2, 4 and 8 seconds, then stop and report the error. Retrying a GET is always safe. A request that creates something or starts a run is safe to retry only with the same Idempotency-Key header: the retry gets the first answer back instead of running again. Without one, and for other writes, check whether the first attempt succeeded before you send it again. The same goes for a CLI command that changes data.
Agent API error format
Every error returns an HTTP status code and a JSON body with this shape:
Code
Agent API status codes
| Status | error.type | Cause and fix |
|---|---|---|
| 400 | invalid_request_error | A field, header or query parameter is missing or invalid. The message names it. Fix the request before you retry. |
| 401 | authentication_error | The request has no key, or its key is unknown, revoked or expired, or the key’s owner left the organization. Send a valid key, or create a new one. |
| 402 | billing_error | Your deployment requires a paid plan or credits before a session’s output can be downloaded. Add a plan or credits in the app, then retry. |
| 403 | permission_error | The key lacks a capability, can’t run the agent or doesn’t act for the session’s owner. A service account key also gets 403 for user.tool_confirmation and for deleting a file it didn’t upload. Use a key that has the capability and acts for the session’s owner. For user.tool_confirmation, use a personal key. |
| 404 | not_found_error | The resource doesn’t exist, this key can’t read it, or the path isn’t part of this API. Check the ID, the path and the key’s Agent scope. |
| 409 | invalid_request_error | The request conflicts with the session’s or the skill’s current state: another client answered the tool call first or the session is stopping or moving, a session delete arrived during a turn, or a skill with that name exists. List the session’s events before you send again. |
| 413 | request_too_large | An uploaded file is over your deployment’s upload limit, a skill upload is over 32 MiB, or another request body is over 10 MiB. Send a smaller file or body. |
| 429 | rate_limit_error | The key hit one of three limits: open streams on the server instance that answered (24 by default), uploads in progress on that instance, or a rate limit your deployment enforces. Close a stream, or wait for the time given in Retry-After. |
| 500 | api_error | An unexpected error occurred. Quote request_id when you contact support. A session delete that returns 500 deleted nothing, so retry it. A session request with more than 50 attached files also returns 500, which is a known defect. Attach 50 or fewer. |
| 503 | api_error | The session’s history is still being indexed. Wait a few seconds, then retry the request. |
A 409 has one of these causes. Its error.type is invalid_request_error, not Anthropic’s conflict_error, so
check the status code.
| Cause | What to do |
|---|---|
| The session’s state changed before the request arrived: another client answered the tool call first, or the session is stopping or moving to another computer. | List the session’s events, then send again only if the request still applies. |
| A session delete arrived while a turn was running. | Wait for the turn to end, or interrupt it. |
| A skill with that name exists. | Upload a new version of that skill, or give the new skill another name. |
Agent API headers
| Header | Result |
|---|---|
| An unknown query parameter | 400 |
Idempotency-Key | 400 |
anthropic-workspace-id | Served: it names the workspace the request runs in, and returns 404 when the key’s owner doesn’t work there. See Headers. |
x-context-owner-user-id, x-context-owner-user-email | Work only on Create a session, and return 400 anywhere else. |
x-request-id | Every response carries it, with the same value as request_id. Send your own (1 to 256 printable ASCII characters) to set it. Quote it when you contact support. |
| Any other unknown header | Ignored. |
Agent API session errors
Errors inside a running session arrive as events on the stream, not as HTTP status codes. While a session retries, it emits session.error with
retry_status.type: "retrying" and keeps running. When the retries run out, it emits session.error with "exhausted",
then goes idle with stop_reason.type: "retries_exhausted". Send a new message to try again. The event’s error.type says
what failed: a rate limit, an overloaded or failed model call, billing, or an unknown cause. See
Session errors.
A session can also wait without an error, when a service account key starts it on an agent with an Ask tool (see Session ownership).
Sending events isn’t idempotent. If a send times out or the connection drops, the server might already have the
events. List the session’s events before you send again. Turn off SDK retries so the SDK doesn’t resend for you
(max_retries=0 in Python, maxRetries: 0 in TypeScript, MaxRetries = 0 in .NET).
Evals CLI exit codes
On failure the CLI prints Error: <message> on standard error.
| Exit code | Meaning |
|---|---|
0 | Success. For benchmark run watch, the run completed, though some tasks may have scored poorly or errored. |
1 | Failure: a server error (5xx), a rate limit (429), a request too large (413), a network error, or a response the CLI can’t read. A missing environment variable also exits 1, as does benchmark run stop when the runner can’t be reached. Retrying can help, except after a 413 (send less data) or a missing environment variable. For a command that changes data, first check whether the first attempt succeeded. |
2 | Refused: a bad flag, a bad local file, a --pick path that names nothing, or the server answered 400, 401, 403, 404, 409, 412 or 422. benchmark run watch also exits 2 on an unknown or forbidden run, after three tries. Fix the command before retrying. |
3 | benchmark run watch: someone stopped the run. |
4 | benchmark run watch: the run failed. As with every ending, the final run status is on standard output. |
5 | benchmark run stop: the run had already ended, so nothing was stopped. Treat it as success in scripts that only need the run stopped. |
130 | benchmark run watch: you pressed Ctrl-C. The watcher stopped; the run goes on. |
2 means refused for the datasets, benchmark, criteria, monitors, file, models, feedback and evaluation commands; elsewhere any failure is 1. In scripts, treat any non-zero exit as failure.