Skip to main content
Glama

Get LLM Expensive Traces

get_llm_expensive_traces
Read-onlyIdempotent

Identify traces with highest LLM token usage to reduce costs and spot inefficient prompts. Filter by time, service, or model for targeted analysis.

Instructions

Find traces with highest LLM token usage.

Useful for cost optimization and identifying inefficient prompts.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
limitNoMaximum number of traces to return (default: 10)
end_timeNoEnd time in ISO 8601 format
min_tokensNoMinimum token count threshold (only return traces above this)
start_timeNoStart time in ISO 8601 format (e.g., 2024-01-01T00:00:00Z)
service_nameNoFilter by service name
gen_ai_request_modelNoFilter by requested model name (e.g., "gpt-4")
gen_ai_response_modelNoFilter by actual model used (e.g., "gpt-4-0613")

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed7 schema fields changedv0.11.0
    • addedInput schema / properties / end_time / description
      Added value: +"End time in ISO 8601 format"
    • addedInput schema / properties / gen_ai_request_model / description
      Added value: +"Filter by requested model name (e.g., \"gpt-4\")"
    • addedInput schema / properties / gen_ai_response_model / description
      Added value: +"Filter by actual model used (e.g., \"gpt-4-0613\")"
    • addedInput schema / properties / limit / description
      Added value: +"Maximum number of traces to return (default: 10)"
    • addedInput schema / properties / min_tokens / description
      Added value: +"Minimum token count threshold (only return traces above this)"
    • addedInput schema / properties / service_name / description
      Added value: +"Filter by service name"
    • addedInput schema / properties / start_time / description
      Added value: +"Start time in ISO 8601 format (e.g., 2024-01-01T00:00:00Z)"
  2. First observedv0.1.0

TDQS

A4.2/5.0
Behavior4/5

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

Annotations already declare readOnly, idempotent, and non-destructive behavior, so the description's main job is to clarify semantics. It does that by specifying that 'expensive' means token usage rather than monetary cost, and it implies descending ordering by token count. It doesn't discuss pagination or limits, but the output schema and parameter defaults cover much of that.

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

Conciseness5/5

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

The description is two short sentences with the core operation front-loaded and the use case immediately after. There is no filler, repetition of schema details, or irrelevant context.

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

Completeness4/5

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

With an output schema present and annotations covering safety and idempotency, the description plus structured data give an agent what it needs to call the tool correctly. It adds the essential ranking-by-token-usage context and intended use cases; minor details like default limit are already captured in the schema.

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

Parameters3/5

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

Schema description coverage is 100%, and every parameter already has type, default, and filter semantics documented. The description itself adds no parameter-level information, so it provides no value beyond the schema, which makes the baseline 3 appropriate.

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?

The description opens with 'Find traces with highest LLM token usage,' which names a specific verb, resource, and ranking criterion. This clearly distinguishes the tool from latency-oriented siblings like get_llm_slow_traces and from generic trace/search tools.

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

Usage Guidelines4/5

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

The description explicitly says it is 'Useful for cost optimization and identifying inefficient prompts,' giving clear intended usage contexts. It does not explicitly name alternatives or exclusion conditions, but the use case guidance is strong enough for an agent to decide when to invoke this tool.

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