Raxol.AgentClientProtocol.Schema.UsageUpdate (Raxol Agent Client Protocol v0.1.0)

Copy Markdown View Source

Payload for the SessionUpdate usage_update variant: a context-window and cost update for a session -- tokens currently in context (used), the total context window size (size), and an optional cumulative session cost.

Not present in f1729; ported straight from the pinned v1.19.0 oracle schema (priv/schema-oracle/v1/schema.json, $defs/UsageUpdate), no upstream attribution. used/size are required non-negative integers per the oracle (no x-deserialize-default-on-error on either); cost is optional and decode-lenient, defaulting to nil on an absent or unparseable value.

Summary

Functions

Total: never raises. A missing/non-non-negative-integer used or size is the only failure mode (both required); an absent or unparseable optional cost defaults to nil rather than failing the whole object.

Types

t()

@type t() :: %Raxol.AgentClientProtocol.Schema.UsageUpdate{
  _meta: map(),
  cost: Raxol.AgentClientProtocol.Schema.Cost.t() | nil,
  size: non_neg_integer(),
  used: non_neg_integer()
}

Functions

from_json(map)

@spec from_json(term()) :: {:ok, t()} | {:error, term()}

Total: never raises. A missing/non-non-negative-integer used or size is the only failure mode (both required); an absent or unparseable optional cost defaults to nil rather than failing the whole object.

new(used, size)

@spec new(non_neg_integer(), non_neg_integer()) :: t()

new(used, size, cost)

to_json(u)

@spec to_json(t()) :: map()