Skip to content

Exit codes

CodeNameMeaningCommon causes
0SuccessCommand completed
1GenericUnmapped failureServer returned 500 with an unrecognised code; CLI internal panic recovery
2UsageBad input / failed pre-flightMissing required flag, malformed JSON spec, workflow validation rule violation, --key / --value cardinality mismatch, invalid HTTP header value from env, HTTP 400
3AuthNot logged in OR token expired and refresh failedATHENA_API_TOKEN empty, no credentials.toml, server refresh endpoint returned 401, HTTP 401
4NotFoundResource doesn’t existSlug/ID doesn’t match any agent, workspace, or group; HTTP 404
5ConflictOptimistic-lock failure or duplicateDraft expected_updated_at doesn’t match server; named draft with that name already exists; HTTP 409
6RateLimitedToo many requestsPer-workspace concurrency cap hit; HTTP 429 (check Retry-After)
7UnreachableNetwork or transport failureDNS failure, TLS error, SSE chunk decode error, SSE buffer exceeded 64 KiB, HTTP 503
8PaymentRequiredWorkspace credits exhaustedagent run rejected at preflight; HTTP 402
9ExecutionFailedWorkflow ran but exited with failurestatus: failed, stream_lost (connection closed without terminal event), any node returned a non-recoverable error
10ExecutionCancelledCaller cancelled, or server-side cancel arrivedPOST /executions/<id>/cancel, HITL rejection
11ExecutionTimeoutPer-execution deadline exceededServer’s max-duration cap hit
12ExecutionSuspendedHITL approval pendingWorkflow paused on an approval node
13ForbiddenAuthenticated but no permissionMember trying admin-only mutations; agent disabled for non-admins; HTTP 403

Why 401 ≠ 403

401 Auth and 403 Forbidden mean different things and need different handling. Scripts should distinguish:

  • 3 → re-authenticate (athena login or set ATHENA_API_TOKEN)
  • 13 → permission problem; ask a workspace admin

Picking the right code in scripts

#!/usr/bin/env bash
set -e
athena agent run my-agent --input @./payload.json
case $? in
0) echo "ok" ;;
3) echo "need to log in"; exit 1 ;;
6) echo "rate-limited, retrying in 30s"; sleep 30; exec "$0" ;;
9|11) echo "execution failed/timed out — check trace_id" ;;
*) echo "unknown failure"; exit 1 ;;
esac