WardrikEvents.Runs (wardrik_events v0.1.0-rc.1)

Copy Markdown

A view of an agent's runs, and the totals across them.

{runs, _cursor} = WardrikEvents.view(MyApp.Events, "acme/triage", WardrikEvents.Runs)

WardrikEvents.Runs.runs(runs)
#=> [%{id: "0af7...", status: :completed, model: "anthropic:claude-haiku-4-5", ...}]

WardrikEvents.Runs.totals(runs)
#=> %{runs: 12, failed: 1, tool_calls: 40, input_tokens: 51_200, output_tokens: 8_300, cost_micro_usd: 91_000, last_at: "..."}

Each run counts its tool calls, tokens and cost, including those of its subagents. See run/0.

Summary

Functions

Returns how long run took in milliseconds, or nil while it runs.

Returns the runs, newest first.

Returns the totals across every run.

Types

run()

@type run() :: %{
  id: String.t(),
  status: :running | :completed | :failed | :cancelled | :waiting,
  started_at: String.t(),
  finished_at: String.t() | nil,
  source: String.t() | nil,
  model: String.t() | nil,
  tool_calls: non_neg_integer(),
  tool_errors: non_neg_integer(),
  input_tokens: non_neg_integer(),
  output_tokens: non_neg_integer(),
  cost_micro_usd: non_neg_integer(),
  error: String.t() | nil
}

t()

@type t() :: %WardrikEvents.Runs{
  order: [String.t()],
  runs: %{required(String.t()) => run()},
  senders: map()
}

Functions

duration_ms(arg1)

@spec duration_ms(run()) :: non_neg_integer() | nil

Returns how long run took in milliseconds, or nil while it runs.

runs(runs)

@spec runs(t()) :: [run()]

Returns the runs, newest first.

totals(state)

@spec totals(t()) :: map()

Returns the totals across every run.

Has :runs, :failed, :tool_calls, :input_tokens, :output_tokens, :cost_micro_usd, and :last_at, when the newest run started.