Sycophant.Agent.Stats (sycophant v0.4.2)

Copy Markdown

Tracks token usage and cost across agent turns.

Summary

Functions

Creates a new empty Stats.

Records a completed turn with usage data and finish reason.

Returns the number of recorded turns.

Returns turns in chronological order.

Types

t()

@type t() :: %Sycophant.Agent.Stats{
  total_cost: float(),
  total_input_tokens: non_neg_integer(),
  total_output_tokens: non_neg_integer(),
  total_reasoning_tokens: non_neg_integer(),
  turns: [Sycophant.Agent.Stats.Turn.t()]
}

Functions

new()

@spec new() :: t()

Creates a new empty Stats.

record_turn(stats, usage, finish_reason)

@spec record_turn(t(), Sycophant.Usage.t() | nil, atom()) :: t()

Records a completed turn with usage data and finish reason.

turn_count(stats)

@spec turn_count(t()) :: non_neg_integer()

Returns the number of recorded turns.

turns(stats)

@spec turns(t()) :: [Sycophant.Agent.Stats.Turn.t()]

Returns turns in chronological order.