agents_traces_stats
Aggregated trace statistics for one agent over the last N days — total runs, success rate, avg duration, error breakdown, top tools used, runs-per-day histogram, and what the agent spent.
spend totals the agent's LLM usage over the same window: llm_calls, tokens_input, tokens_output, cost_usd, and own_key_cost_usd (the slice paid with the workspace's own vendor key, included in cost_usd rather than added to it). It covers usage recorded since per-agent attribution shipped, so it reads 0 for older runs; null means the lookup could not run.
Use this when you want a bird's-eye view of an agent's health before diving into individual traces with agents.traces_list / agents.trace_get. Scoped to the target agent (exact match, no substring bleed). days is capped at 30 — matches the ClickHouse request_traces TTL.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| days | No | Rolling window in days (1–30). | |
| agent_id | Yes | Agent ID to compute stats for (must belong to your workspace). | |
| in_workspace | No | Run this one call in this workspace id instead of the session's. Nothing is stored; other sessions are not affected. |