Skip to main content

Overview

Every task exposes a single read-only task.usage property. It returns an AggregatedUsage view derived from the centralized usage registry on each access, scoped to this task’s task_usage_id. For wall-clock task length, compute task.end_time - task.start_time. The figure on task.usage.duration is the sum of per-call model durations, not wall-clock. When printing is enabled (print_do / print_do_async), a Task Metrics panel is displayed after each execution.

Accessing Task Metrics

Read task.usage on any Task instance after execution. It always returns an AggregatedUsage — zero-valued before any model call, populated thereafter.

Token Metrics

Request & Tool Metrics

Timing Metrics

Cost Metrics

Aggregation Metadata

Task Identity & Wall-Clock Timing

Example

Printed Panel

When you use print_do or print_do_async, the Task Metrics panel displays after the task:

Scope & Propagation

  • Per-task isolation — Each task has its own task_usage_id. Two tasks executed by the same agent never mix their task.usage figures.
  • Agent rollup — The same entries that contribute to task.usage also contribute to agent.usage (and chat.usage / team.usage if applicable) because every entry carries multiple scope tags.
  • Sub-pipeline rollup — Reliability validator/editor, culture, policy, and sub-agent calls dispatched during this task inherit task_usage_id and roll into task.usage automatically.
  • Retry idempotency — The registry is keyed by entry_id. Retried requests replace their prior entry instead of double-counting.
  • JSON snapshot — Call task.usage.to_dict() for a flat dict suitable for logs and dashboards.

Legacy Migration

Legacy task-level properties have been removed in favour of task.usage: