Metrics

Token usage and timing for agent, team, and workflow runs, messages, sessions, and tool calls.

ClassUsed OnPurpose
RunMetricsRunOutput.metrics, TeamRunOutput.metricsRun-level totals with per-model breakdown
WorkflowMetricsWorkflowRunOutput.metricsPer-executor step metrics and total workflow duration
StepMetricsInside WorkflowMetrics.stepsRunMetrics for one agent or team step executor
MessageMetricsMessage.metricsPer-API-call tokens and timing
SessionMetricsAgent, team, and workflow get_session_metrics() methodsAggregated across all runs in a session
ModelMetricsInside RunMetrics.detailsPer-model aggregate by (provider, id)
ToolCallMetricsToolExecution.metricsTool execution timing

RunMetrics, MessageMetrics, SessionMetrics, and ModelMetrics inherit from BaseMetrics, which provides the shared token and cost fields.

BaseMetrics

Shared token fields inherited by RunMetrics, MessageMetrics, SessionMetrics, and ModelMetrics.

ParameterTypeDefaultDescription
input_tokensint0Tokens in the prompt/input.
output_tokensint0Tokens generated by the model.
total_tokensint0Total tokens used (input + output).
audio_input_tokensint0Audio tokens in the input.
audio_output_tokensint0Audio tokens in the output.
audio_total_tokensint0Total audio tokens.
cache_read_tokensint0Tokens served from cache.
cache_write_tokensint0Tokens written to cache.
reasoning_tokensint0Tokens used for reasoning steps.
costOptional[float]NoneCost supplied by the provider, when available; Agno does not calculate it from a pricing table.

RunMetrics

Used on RunOutput.metrics and TeamRunOutput.metrics. Includes all BaseMetrics fields plus:

ParameterTypeDefaultDescription
timerOptional[Timer]NoneInternal timer that computes duration and time_to_first_token. Excluded from to_dict().
time_to_first_tokenOptional[float]NoneTime from run start to first token (seconds). Set once per run.
durationOptional[float]NoneTotal run time (seconds).
detailsOptional[Dict[str, List[ModelMetrics]]]NonePer-model breakdown keyed by model type (e.g., "model", "output_model", "memory_model").
additional_metricsOptional[Dict[str, Any]]NoneExtra metrics (e.g., eval_duration).

details keys

The details dictionary uses model type strings as keys. Each key maps to a list of ModelMetrics objects (one per unique model (provider, id) pair).

KeyDescription
"model"Primary agent model
"output_model"Output model for structured output
"parser_model"Parser model
"memory_model"Memory model
"reasoning_model"Reasoning model
"session_summary_model"Session summary model
"learning_model"Learning model
"compression_model"Compression model
"followup_model"Followup model

Eval agent metrics are prefixed with eval_. If an eval agent uses model types "model" and "output_model", the details keys become "eval_model" and "eval_output_model".

Import the current types directly:

from agno.metrics import RunMetrics, MessageMetrics, SessionMetrics, ModelMetrics, ToolCallMetrics
from agno.workflow.types import WorkflowMetrics, StepMetrics

The old Metrics alias and agno.models.metrics module are no longer available. The listed model-type keys are built in; applications can also use custom string keys.

WorkflowMetrics

WorkflowRunOutput.metrics uses WorkflowMetrics. Each entry in steps wraps the RunMetrics produced by an agent or team step executor.

ParameterTypeDefaultDescription
stepsDict[str, StepMetrics]RequiredAgent and team executor metrics keyed by step name.
timerOptional[Timer]NoneInternal timer that computes duration. Excluded from to_dict().
durationOptional[float]NoneTotal workflow execution time (seconds).

StepMetrics

ParameterTypeDefaultDescription
step_namestrRequiredStep name.
executor_typestrRequiredExecutor type, such as "agent" or "team".
executor_namestrRequiredExecutor name.
metricsOptional[RunMetrics]NoneRun metrics for the step executor.

MessageMetrics

Used on Message.metrics. Per-API-call metrics. Includes all BaseMetrics fields plus:

ParameterTypeDefaultDescription
timerOptional[Timer]NoneInternal timer that computes duration and time_to_first_token. Excluded from to_dict().
durationOptional[float]NoneDuration of this API call (seconds).
time_to_first_tokenOptional[float]NoneTime to first token for this API call (seconds).
provider_metricsOptional[Dict[str, Any]]NoneProvider-specific metrics (e.g., Ollama timing, Cerebras timing).

SessionMetrics

Returned by agent.get_session_metrics(), team.get_session_metrics(), and workflow.get_session_metrics(). Aggregated across all runs in a session. Includes all BaseMetrics fields plus:

ParameterTypeDefaultDescription
detailsOptional[Dict[str, List[ModelMetrics]]]NonePer-model breakdown, same structure as RunMetrics.details. Tokens summed across runs.
additional_metricsOptional[Dict[str, Any]]NoneAggregated additional metrics from all runs.

ModelMetrics

Per-model aggregate stored inside RunMetrics.details[model_type]. Includes all BaseMetrics fields plus:

ParameterTypeDefaultDescription
idstr""Model ID (e.g., "gpt-4o").
providerstr""Provider name (e.g., "OpenAI Chat", "OpenAI Responses", "Anthropic").
provider_metricsOptional[Dict[str, Any]]NoneProvider-specific data for this model.

ToolCallMetrics

Used on ToolExecution.metrics. Standalone class (does not inherit BaseMetrics).

ParameterTypeDefaultDescription
timerOptional[Timer]NoneInternal timer that computes duration. Excluded from to_dict().
start_timeOptional[float]NoneUnix timestamp when the tool call started.
end_timeOptional[float]NoneUnix timestamp when the tool call ended.
durationOptional[float]NoneTool execution time (seconds).

Provider field availability

Not all providers populate all fields. A cost checkmark means the adapter can read a cost value if the response includes one; it does not guarantee that the provider returns it. This table shows which BaseMetrics fields each provider sets on MessageMetrics.

ProviderStandard tokenscache_readcache_writereasoningAudio tokenscostprovider_metrics
OpenAI Chat
OpenAI Responses
Anthropic Claudeserver_tool_use, service_tier
Google Geminitraffic_type
Groqcompletion_time, prompt_time, queue_time, total_time
Mistral
AWS Bedrock
LiteLLM
Perplexity
Azure AI Foundry
Cerebrastime_system, time_prompt
Ollamatotal_duration, load_duration, prompt_eval_duration, eval_duration
Cohere
Meta Llama
Meta Llama (OpenAI)
HuggingFace
IBM WatsonX

"Standard tokens" = input_tokens, output_tokens, total_tokens. "Audio tokens" = audio_input_tokens, audio_output_tokens.