Skip to content
Context docs
Build

Errors

This page covers the errors both HTTP APIs return and the Evals CLI’s exit codes.

Where the APIs differ

Evals APIAgent API
Body{ "error": "<message>", "code": "<code>", "details": [...] }{ "type": "error", "error": { "type": "<type>", "message": "<message>" }, "request_id": "<id>" }
Branch onThe status and codeThe status and error.type
429 bodyIts own shape, shown on LimitsThe same shape as every other error, with error.type rate_limit_error
Status codesEvals API status codesAgent API status codes

Evals API error format

FieldTypeMeaning
errorstringA message for people. Don’t parse it; its wording can change.
codestringA stable code for programs, when the error has one.
detailsarrayOn 400, one entry per parameter that failed, with its path and a message.
JSONCode
{ "error": "Invalid request", "details": [ { "path": "pageSize", "message": "Number must be less than or equal to 100" } ] }

A 429 body has its own shape, shown on Limits; rely on its status and Retry-After.

Evals API status codes

StatuscodeWhenWhat to do
400(none)A parameter fails its schema.Fix the parameters details names.
400SEARCH_NOT_TOKENIZABLEA 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.
400INVALID_CURSORA 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.
403TASK_CAPABILITY_MISSINGThe 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.
400idempotency_key_emptyAn Idempotency-Key header was sent empty.Send a key you chose, such as a UUID, or leave the header out.
409idempotency_in_progressA 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.
422idempotency_key_reusedThe 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.
500QUERY_FAILEDA 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.
503CLICKHOUSE_UNAVAILABLEThis deployment has no trace store configured, so trace data can’t be read.Don’t retry; ask your administrator.
503TRACE_READ_SOURCE_UNRESOLVEDThe 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:

JSONCode
{ "error": "Unauthorized" }

A 403 body for a missing capability:

JSONCode
{ "error": "Task API key missing required capability: evals:read", "code": "TASK_CAPABILITY_MISSING" }

A 404 body:

JSONCode
{ "error": "Resource not found in this organization" }

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:

JSONCode
{ "type": "error", "error": { "type": "permission_error", "message": "Task API key missing required capability: tasks:create" }, "request_id": "a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d" }

Agent API status codes

Statuserror.typeCause and fix
400invalid_request_errorA field, header or query parameter is missing or invalid. The message names it. Fix the request before you retry.
401authentication_errorThe 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.
402billing_errorYour 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.
403permission_errorThe 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.
404not_found_errorThe 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.
409invalid_request_errorThe 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.
413request_too_largeAn 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.
429rate_limit_errorThe 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.
500api_errorAn 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.
503api_errorThe 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.

CauseWhat 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

HeaderResult
An unknown query parameter400
Idempotency-Key400
anthropic-workspace-idServed: 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-emailWork only on Create a session, and return 400 anywhere else.
x-request-idEvery 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 headerIgnored.

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 codeMeaning
0Success. For benchmark run watch, the run completed, though some tasks may have scored poorly or errored.
1Failure: 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.
2Refused: 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.
3benchmark run watch: someone stopped the run.
4benchmark run watch: the run failed. As with every ending, the final run status is on standard output.
5benchmark run stop: the run had already ended, so nothing was stopped. Treat it as success in scripts that only need the run stopped.
130benchmark 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.