Skip to main content

Module usage

Module usage 

Source
Expand description

Token, cost, and session-usage types shared across the workspace.

These are wire types. Agent crates produce them and protocol crates serialize them, so they live here as the lowest common dependency. Keep this module small: behavior belongs with the agents that produce the values.

Structs§

ContextUsage
One agent’s context window after its most recent LLM call.
ModelIdentity
Provider, model id, and catalog pricing of the model serving a call. All fields are None for dynamic or local models the catalog does not know.
ModelPricing
Provider/model prices sourced from models.dev, denominated in USD per million tokens.
SessionUsageEvent
One provider usage sample, its estimated cost, and the totals after it.
SessionUsageTotals
Running token totals and cost estimate across every call an agent has seen.
TokenUsage
Token counts for a single LLM call or an aggregate of calls. Providers fill in only the dimensions they report; the rest stay None.
Tokens
A count of tokens. Sums saturate instead of wrapping.
UsageCost
Estimated USD cost of one call, split by token pool.
UsageSource
The agent a usage sample belongs to and where it sits in the sub-agent tree. A freshly created source has no parent; the agent that receives a sub-agent’s usage fills in parent_agent_id and task_id.
Usd
A monetary amount denominated in US dollars.

Enums§

LlmCallPurpose
What an LLM call was issued for.