Handle errors in code
The SDKs raise a typed error on any non-2xx response, withstatus_code / statusCode and the parsed body.
Session failures
A settled session reports two signals onstatus, the session object, and changes, so your code can branch without parsing prose.
Outcomes
A session can endcompleted and still not do what you asked. outcome is the agent’s own assessment, reported with its final answer:
outcome is a self-assessment, not verified ground truth: validate the answer itself for high-stakes flows. It is null when the agent ended without reporting one.
Error codes
When a session endsfailed or timed_out, it carries an error_code and an error message matching it:
error_codeisnullunless the status isfailedortimed_out.- New codes may appear: treat unknown values like
internal. - Branch on
error_code, logerror.
HTTP status codes
Client error codes
Quota errors (429)
A session429 says which limit was hit in detail[].type, and whose slots ran out in detail[].scope:
Quota error (429)
In the local runtime, its session cap answers
capacity with scope platform.
Server error codes
Error envelope
Every error response carries the same envelope: amessage that summarizes the problem, and a detail array with one entry per problem. For 422 validation errors, each detail entry keeps the failing field’s path and reason, and message flattens them into one line:
Validation error (422)
401) may carry only a message.
Vault, browser profile and session file endpoints are the exception: apart from 422 validation errors, most of their errors carry a single detail string and no message:
Vault not found (404)