Skip to main content

ducto.metrics module

Pure data structures for agent usage telemetry.

Consumed by PricingEngine.calculate() to produce a CostBreakdown.

class ducto.metrics.ToolCall(, name: str)

Bases: BaseModel

A single tool invocation recorded during an agent step.

model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

name : str

class ducto.metrics.UsageMetrics(*, model: str | None = None, input_tokens: int = 0, output_tokens: int = 0, cache_read_tokens: int = 0, cache_write_tokens: int = 0, tool_calls: list[ToolCall] = , search_queries: int = 0, search_results: int = 0, web_search_calls: int = 0, code_exec_calls: int = 0, fixed_job: str | None = None)

Bases: BaseModel

Raw usage counters collected across one or more agent steps.

All integer fields default to 0 so callers can partially populate the struct and rely on sensible zero-values.

cache_read_tokens : int

cache_write_tokens : int

code_exec_calls : int

fixed_job : str | None

input_tokens : int

model : str | None

model_config = {}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

output_tokens : int

search_queries : int

search_results : int

tool_calls : list[ToolCall]

web_search_calls : int