Overview
Every agent exposes a single read-onlyagent.usage property. It returns an AggregatedUsage view derived from the centralized usage registry on each access, scoped to this agent’s agent_usage_id.
Sub-pipeline model calls — memory summarization, reliability validator/editor, culture, policy, and sub-agents invoked as tools — automatically inherit the agent’s scope and roll into agent.usage without any manual propagation.
When printing is enabled (print_do / print_do_async), an Agent Metrics panel is displayed after each task so you can see the updated totals.
Accessing Agent Metrics
Readagent.usage on any Agent instance. It always returns an AggregatedUsage — zero-valued before the first run, populated thereafter.
Token Metrics
Request & Tool Metrics
Timing Metrics
Cost Metrics
Aggregation Metadata
Example
Printed Panel
When you useprint_do or print_do_async, the Agent Metrics panel displays after each task:
Scope & Propagation
- Across tasks — Every call to
do/print_do/do_async/print_do_asyncrecords entries against the agent’s scope. Readingagent.usagere-aggregates them, so the figures always reflect the latest state. - Sub-pipeline rollup — Memory summarization, reliability validator/editor, culture, policy, and sub-agent calls inherit the parent’s scope via context variables and roll into
agent.usageautomatically. - Retry idempotency — The registry is keyed by
entry_id. Retried requests replace their prior entry instead of double-counting. - Independent agents — Each
Agentinstance has its ownagent_usage_id. Two different agents never share usage. - JSON snapshot — Call
agent.usage.to_dict()for a flat dict suitable for logs and dashboards.
Legacy Migration
Legacy surfaces have been removed in favour of
agent.usage:Related Documentation
- Usage Registry — Architecture, scope tags, persistence
- Task Metrics — Per-task scoped view
- Chat Metrics — Per-session scoped view
- Team Metrics — Per-team scoped view

