Developer docs · Browse & search
OPERATE

Errors and retries

What each error means, what the client retries for you, and keys that survive your own restarts.

When things go wrong

Everything thrown is a JwtsonError with code, status and requestId, and a message written for people.

ErrorMeans
ValidationErrorThe request is wrong. details lists the fields, and the message includes them
AuthenticationErrorThe token is missing or expired
PermissionErrorThe token doesn't hold the grant this needs
NotFoundErrorIt doesn't exist, or you can't see it
ConflictErrorSomeone changed it first
RateLimitErrorToo many requests, even after retrying. retryAfterMs says how long to wait
ServerError, ConnectionErrorStill failing after retrying
ConfigurationErrorSetup is missing something. The message says what to pass
RunFailedError, RunCanceledError, RunTimedOutErrorThe run ended without an answer. failure has the reason. RunTimedOutError is a RunFailedError whose reason is time_limit_exceeded
WaitTimeoutErrortimeoutMs passed. The run itself keeps going

Retries

A read that fails in passing is sent again, and so is a write, because every write carries an idempotency key and the API won't apply one twice. A refusal is never retried. Set maxRetries to change the number of tries, or 0 to turn this off.

The key lives for one call. If your own process can restart and repeat the call, pass your own: agent.start(input, { idempotencyKey: order.id }). Every change to a run takes one too: run.cancel(), run.resume(), run.say(), wait.answer() and approval.approve().

To stop a run only as you saw it, give its revision: run.cancel({ revision, idempotencyKey }), with the detail.revision you read when you decided. If it moved on, you get a ConflictError and nothing changes. Without one, cancel() stops it as it is now.

From the @jwtson/sdk README, as the code stands.