ExAgent.Jobs.Job (ExAgent v3.0.0)

View Source

A job snapshot returned by either Jobs backend. Both report id, name, status, bounded result text and an optional error diagnostic. :backend identifies where the snapshot came from.

Stability — Stable.

Volatile Jobs include started_at and, on completion, finished_at. Durable Jobs include the persisted notification state ("pending", "sending", "admitted", "unconfirmed", "disabled" or "abandoned"). A durable job can expose a typed quota refusal or deadline in :diagnostic and bounded text for display in :error. A ready job with a certified quota wait has a UTC :retry_at timestamp. A pending job with an open timer reports its next wake or its earlier expiry in :retry_at. Terminal reports include qualified :usage when available. :usage_status is :unknown with no measured counts, :partial with known subtotals or :complete with full input and output coverage. A numeric :cost_cents is an estimate with :cost_status of :known. A partial subtotal, when available, stays under usage.accounting["cost"]. The other backend's fields are nil.

Summary

Types

A committed refusal has a :type of "rate_limited", "rate_limiter_migration_required", "usage_limit_exceeded", "accounting_unavailable" or "deadline_exceeded". A rate or spend includes the requested wait in milliseconds or a wait category. A certified initial spend refusal with an unknown wait is ready to recheck at :retry_at. An unknown provider-quota wait retains the claim for recovery. A job that lost its execution lease reports "continuation_lease_expired" when its claim becomes recoverable.

t()

Types

diagnostic()

@type diagnostic() ::
  %{
    type: String.t(),
    wait_ms: non_neg_integer() | :infinity | :queue_full | :unknown
  }
  | %{
      type: String.t(),
      limit: String.t(),
      wait_ms: pos_integer() | :infinity | :unknown
    }
  | %{type: String.t(), dimension: String.t(), cause: String.t()}
  | %{type: String.t(), version: 1}
  | %{type: String.t()}
  | %{type: String.t()}

A committed refusal has a :type of "rate_limited", "rate_limiter_migration_required", "usage_limit_exceeded", "accounting_unavailable" or "deadline_exceeded". A rate or spend includes the requested wait in milliseconds or a wait category. A certified initial spend refusal with an unknown wait is ready to recheck at :retry_at. An unknown provider-quota wait retains the claim for recovery. A job that lost its execution lease reports "continuation_lease_expired" when its claim becomes recoverable.

durable_status()

@type durable_status() ::
  :queued
  | :starting
  | :running
  | :pending
  | :approved
  | :ready
  | :blocked
  | :recovery_required
  | :expiry_due
  | :succeeded
  | :failed
  | :denied
  | :expired
  | :cancelled

status()

@type status() :: volatile_status() | durable_status()

t()

@type t() :: %ExAgent.Jobs.Job{
  backend: :volatile | :durable,
  cost_cents: number() | nil,
  cost_status: :known | :unknown,
  diagnostic: diagnostic() | nil,
  error: String.t() | nil,
  finished_at: DateTime.t() | nil,
  id: String.t(),
  name: String.t(),
  notification: String.t() | nil,
  result: String.t() | nil,
  retry_at: DateTime.t() | nil,
  started_at: DateTime.t() | nil,
  status: status(),
  usage: ExAgent.Message.Usage.t() | nil,
  usage_status: :complete | :partial | :unknown
}

volatile_status()

@type volatile_status() :: :running | :succeeded | :failed | :timeout | :cancelled