Skip to main content
Glama

agents_traces_stats

Read-onlyIdempotent

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

TableJSON Schema
NameRequiredDescriptionDefault
daysNoRolling window in days (1–30).
agent_idYesAgent ID to compute stats for (must belong to your workspace).
in_workspaceNoRun this one call in this workspace id instead of the session's. Nothing is stored; other sessions are not affected.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changed
    • addedInput schema / properties / in_workspace
      Added value: +{
      +  "description": "Run this one call in this workspace id instead of the session's. Nothing is stored; other sessions are not affected.",
      +  "type": "integer"
      +}
  2. Added
  3. Removed
  4. First observed

TDQS

A4.8/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Goes well beyond the readOnly/idempotent annotations by disclosing data caveats: spend reads 0 for runs predating per-agent attribution, null means the lookup could not run, the window is capped at 30 days to match the ClickHouse request_traces TTL, and matching is exact with 'no substring bleed'. These are non-obvious behaviors an agent needs.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded with the purpose and output inventory, then the spend semantics, then usage guidance. Dense and mostly waste-free, though the spend paragraph is on the longer side for a single returned field.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With no output schema, the description carries the burden of describing returns and does so by enumerating the aggregate metrics and spend fields, including the subtle own_key_cost_usd relationship. An agent has everything needed to call it and interpret the result.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3, but the description adds real meaning: the rationale for the `days` cap (ClickHouse TTL) and the exact-match scoping of `agent_id` ('no substring bleed'). It stops short of explaining `in_workspace`, but the schema already covers it.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Opens with a specific verb+resource ('Aggregated trace statistics for one agent') and enumerates the exact fields returned (runs, success rate, avg duration, error breakdown, top tools, histogram, spend). This clearly distinguishes it from the sibling trace tools that return individual records.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly says when to use it ('bird's-eye view of an agent's health') and names the alternatives it complements ('before diving into individual traces with agents.traces_list / agents.trace_get'), with the routing condition stated rather than implied.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.