MingaAgent.TurnUsage (Minga v0.1.0)

Copy Markdown View Source

Token usage data for a single agent turn.

Tracks input/output token counts, cache statistics, and estimated cost. Constructed by the provider after each turn completes, then accumulated into the session's total via add/2.

Summary

Types

t()

Per-turn token usage.

Functions

Adds two usage records together, combining all counters.

Formats the usage as a short summary string for display.

Creates a new empty usage record.

Creates a usage record from the given values.

Types

t()

@type t() :: %MingaAgent.TurnUsage{
  cache_read: non_neg_integer(),
  cache_write: non_neg_integer(),
  cost: float(),
  input: non_neg_integer(),
  output: non_neg_integer()
}

Per-turn token usage.

Functions

add(total, turn)

@spec add(t(), t()) :: t()

Adds two usage records together, combining all counters.

Used to accumulate per-turn usage into a session total.

format_short(u)

@spec format_short(t()) :: String.t()

Formats the usage as a short summary string for display.

new()

@spec new() :: t()

Creates a new empty usage record.

new(input, output, cache_read, cache_write, cost)

Creates a usage record from the given values.