Skip to Content
Krad ADE
Agents API

Errors and exit codes

The stable error codes of the Agents API v1 and the exit codes of the krad CLI.

Every refusal is one line:

Refusal
{"Error":{"code":"not_found","message":"..."}}

Codes are stable; messages are for people and may change. Match on code, never on message. A request that runs past its deadline is not an error: the answer is the bare string "TimedOut", and the CLI exits with 3.

Error codes

CodeMeaningCLI exit
bad_requestThe line or a field is malformed, or a name is ambiguous1
unavailableThe app stopped serving, dropped the request or the caller left2
slow_subscriberA subscriber fell 256 lines behind and was dropped2
not_foundNo such agent, session, Kraddie, automation, run, group, file or memory4
unauthorizedWrong token, or a Lead caller without the lead token5
forbiddenNot allowed for this caller: not a lead, a client, a path outside the group, memory out of reach for reading5
unsupportedNot possible here: a lead's mailbox, another environment than the one on screen, a caller with no group5
not_ownedNot one of the lead's Workers, or a session or run outside its group5
busyStill working; close with cancel_turn5
out_of_reachA Kraddie's memory this chat may not read5
unsupported_api_versionThe app serves another API version6
failedThe app tried and could not do it7
worktree_not_cleanA worktree with uncommitted or unmerged work was kept7

New codes may be added in v1. Treat an unknown code as a refusal you do not understand. See Compatibility.

CLI exit codes

ExitMeaning
0Done
1Wrong arguments
2The app cannot be reached; also a stale discovery file, a dropped slow subscriber or a missed heartbeat
3Timed out
4No such agent, session or file
5Refused for this caller
6The app speaks another API version
7The app could not do it
Branch on the exit code
krad wait 4 --timeout 900
case $? in
  0) krad read 4 --lines 60 ;;
  3) echo "still working" ;;
  2) echo "the app is not running" ;;
esac

Run outside a Krad ADE terminal with no live api.json, the CLI cannot find the app and exits with 2.

On this page