@@ -38,7 +38,11 @@ export class Runs extends APIResource {
3838
3939 /**
4040 * Cancel an agent run that is currently queued or in progress. Once cancelled, the
41- * run will transition to a failed state.
41+ * run will transition to a cancelled state.
42+ *
43+ * Not all runs can be cancelled. Runs that are in a terminal state (SUCCEEDED,
44+ * FAILED, ERROR, BLOCKED, CANCELLED) return 400. Runs in PENDING state return 409
45+ * (retry after a moment). Self-hosted, local, and GitHub Action runs return 422.
4246 *
4347 * @example
4448 * ```ts
@@ -271,6 +275,10 @@ export interface RunItem {
271275 */
272276 started_at ?: string | null ;
273277
278+ /**
279+ * Status message for a run. For terminal error states, includes structured error
280+ * code and retryability info from the platform error catalog.
281+ */
274282 status_message ?: RunItem . StatusMessage ;
275283}
276284
@@ -337,11 +345,68 @@ export namespace RunItem {
337345 schedule_name : string ;
338346 }
339347
348+ /**
349+ * Status message for a run. For terminal error states, includes structured error
350+ * code and retryability info from the platform error catalog.
351+ */
340352 export interface StatusMessage {
341353 /**
342354 * Human-readable status message
343355 */
344- message ?: string ;
356+ message : string ;
357+
358+ /**
359+ * Machine-readable error code identifying the problem type. Used in the `type` URI
360+ * of Error responses and in the `error_code` field of RunStatusMessage.
361+ *
362+ * User errors (run transitions to FAILED):
363+ *
364+ * - `insufficient_credits` — Team has no remaining add-on credits
365+ * - `feature_not_available` — Required feature not enabled for user's plan
366+ * - `external_authentication_required` — User hasn't authorized a required
367+ * external service
368+ * - `not_authorized` — Principal lacks permission for the requested operation
369+ * - `invalid_request` — Request is malformed or contains invalid parameters
370+ * - `resource_not_found` — Referenced resource does not exist
371+ * - `budget_exceeded` — Spending budget limit has been reached
372+ * - `integration_disabled` — Integration is disabled and must be enabled
373+ * - `integration_not_configured` — Integration setup is incomplete
374+ * - `operation_not_supported` — Requested operation not supported for this
375+ * resource/state
376+ * - `environment_setup_failed` — Client-side environment setup failed
377+ * - `content_policy_violation` — Prompt or setup commands violated content policy
378+ * - `conflict` — Request conflicts with the current state of the resource
379+ *
380+ * Warp errors (run transitions to ERROR):
381+ *
382+ * - `authentication_required` — Request lacks valid authentication credentials
383+ * - `resource_unavailable` — Transient infrastructure issue (retryable)
384+ * - `internal_error` — Unexpected server-side error (retryable)
385+ */
386+ error_code ?:
387+ | 'insufficient_credits'
388+ | 'feature_not_available'
389+ | 'external_authentication_required'
390+ | 'not_authorized'
391+ | 'invalid_request'
392+ | 'resource_not_found'
393+ | 'budget_exceeded'
394+ | 'integration_disabled'
395+ | 'integration_not_configured'
396+ | 'operation_not_supported'
397+ | 'environment_setup_failed'
398+ | 'content_policy_violation'
399+ | 'conflict'
400+ | 'authentication_required'
401+ | 'resource_unavailable'
402+ | 'internal_error' ;
403+
404+ /**
405+ * Whether the error is transient and the client may retry by submitting a new run.
406+ * Only present on terminal error states. When false, retrying without addressing
407+ * the underlying cause will not succeed.
408+ */
409+ retryable ?: boolean ;
345410 }
346411}
347412
0 commit comments