Skip to main content
Glama

Log Trace

log_trace

Save an agent's input, output, tool calls, spans, cost, latency, and token usage to SQLite, then use the returned trace_id to evaluate, query, or delete that stored execution.

Instructions

Store one agent execution — input, output, tool calls, spans, cost, latency, token usage — and get the trace_id every later call keys on.

What it does. Writes one trace row to local SQLite and mints a fresh trace_id; nothing is deduplicated, so resubmitting the same payload stores a second trace. Only agent_name is required. Store what you have: tool_calls so the trajectory rules can later judge what the agent did, cost_usd and token_usage so the cost rules can, input and output so everything else can. When IRIS_OTEL_ENDPOINT is set the trace is also exported to that collector, best-effort and asynchronous; the local write never waits on it. Traces are immutable: there is no update path. In stdio mode nothing authenticates the caller; over HTTP a Bearer token is required only when an API key is configured.

When not to use it. For a transient log line (use your logger). To score an output: log first, then call evaluate_output with the trace_id, which also lets it reuse the stored tool_calls. To change a stored trace: delete_trace and log again.

Returns. JSON with trace_id (the stored trace id, 32 hex — pass it to evaluate_output, get_traces or delete_trace); status (always "stored" on success).

Errors. IRIS_STORAGE_ERROR when the database cannot be written. An unknown argument or a malformed span or tool_calls entry is refused before the handler runs, naming the valid keys. Every failure returns {"error":{"code","message","recovery":[]}} with isError true; follow recovery before retrying.

Siblings. evaluate_output — score the stored output; get_traces — query what was logged; delete_trace — remove one trace.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
inputNoAgent input text — the user prompt or upstream input that produced this output
spansNoDetailed execution spans (hierarchical span tree with timings, attributes, events); a span without start_time takes the trace timestamp
outputNoAgent output text — what the agent produced (pass to evaluate_output for scoring)
cost_usdNoTotal cost in USD — overrides per-span aggregation when provided (treated as authoritative)
metadataNoOpaque key-value tags (e.g. {requestId, userId, env}) — queryable in dashboard, not via get_traces filters
frameworkNoAgent framework identifier (e.g., langchain, autogen, custom)
timestampNoTrace timestamp (ISO 8601); defaults to now() when omitted
agent_nameYesAgent name — used for filtering in get_traces (e.g., "customer-support-bot")
latency_msNoTotal execution time in milliseconds (end-to-end agent latency)
tool_callsNoTool calls made during execution, in order, each { tool_name, input?, output?, latency_ms?, error? } — what the trajectory rules judge; evaluate_output reuses them when given this trace_id
token_usageNoToken usage breakdown (prompt/completion/total — used for cost analysis)

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
statusYesalways "stored" on success
trace_idYesthe stored trace id, 32 hex — pass it to evaluate_output, get_traces or delete_trace

Schema Changelog

Changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. Changed3 schema fields changedv0.9.0
    • changedInput schema / properties / spans / description
      Previous value: -"Detailed execution spans (hierarchical span tree with timings, attributes, events)"New value: +"Detailed execution spans (hierarchical span tree with timings, attributes, events); a span without start_time takes the trace timestamp"
    • changedInput schema / properties / tool_calls / description
      Previous value: -"Tool calls made during execution (per-call latency, errors, input/output)"New value: +"Tool calls made during execution, in order, each { tool_name, input?, output?, latency_ms?, error? } — what the trajectory rules judge; evaluate_output reuses them when given this trace_id"
    • changedOutput schema / (root)
      Previous value: -nullNew value: +{
      +  "$schema": "http://json-schema.org/draft-07/schema#",
      +  "additionalProperties": {},
      +  "properties": {
      +    "status": {
      +      "const": "stored",
      +      "description": "always \"stored\" on success",
      +      "type": "string"
      +    },
      +    "trace_id": {
      +      "description": "the stored trace id, 32 hex — pass it to evaluate_output, get_traces or delete_trace",
      +      "type": "string"
      +    }
      +  },
      +  "required": [
      +    "trace_id",
      +    "status"
      +  ],
      +  "type": "object"
      +}
  2. Changed2 schema fields changedv0.8.0
    • addedInput schema / additionalProperties
      Added value: +false
    • addedInput schema / properties / tool_calls / items / additionalProperties
      Added value: +false
  3. Changed8 schema fields changedv0.4.6
    • removedInput schema / additionalProperties
      Removed value: -false
    • addedInput schema / properties / metadata / propertyNames
      Added value: +{
      +  "type": "string"
      +}
    • removedInput schema / properties / spans / items / additionalProperties
      Removed value: -false
    • addedInput schema / properties / spans / items / properties / attributes / propertyNames
      Added value: +{
      +  "type": "string"
      +}
    • removedInput schema / properties / spans / items / properties / events / items / additionalProperties
      Removed value: -false
    • addedInput schema / properties / spans / items / properties / events / items / properties / attributes / propertyNames
      Added value: +{
      +  "type": "string"
      +}
    • removedInput schema / properties / token_usage / additionalProperties
      Removed value: -false
    • removedInput schema / properties / tool_calls / items / additionalProperties
      Removed value: -false
  4. Changed11 schema fields changedv0.1.10
    • changedInput schema / properties / agent_name / description
      Previous value: -"Name of the agent"New value: +"Agent name — used for filtering in get_traces (e.g., \"customer-support-bot\")"
    • changedInput schema / properties / cost_usd / description
      Previous value: -"Total cost in USD"New value: +"Total cost in USD — overrides per-span aggregation when provided (treated as authoritative)"
    • changedInput schema / properties / framework / description
      Previous value: -"Agent framework name"New value: +"Agent framework identifier (e.g., langchain, autogen, custom)"
    • changedInput schema / properties / input / description
      Previous value: -"Agent input text"New value: +"Agent input text — the user prompt or upstream input that produced this output"
    • changedInput schema / properties / latency_ms / description
      Previous value: -"Total execution time in milliseconds"New value: +"Total execution time in milliseconds (end-to-end agent latency)"
    • changedInput schema / properties / metadata / description
      Previous value: -"Arbitrary metadata"New value: +"Opaque key-value tags (e.g. {requestId, userId, env}) — queryable in dashboard, not via get_traces filters"
    • changedInput schema / properties / output / description
      Previous value: -"Agent output text"New value: +"Agent output text — what the agent produced (pass to evaluate_output for scoring)"
    • changedInput schema / properties / spans / description
      Previous value: -"Detailed execution spans"New value: +"Detailed execution spans (hierarchical span tree with timings, attributes, events)"
    • changedInput schema / properties / timestamp / description
      Previous value: -"Trace timestamp (ISO 8601)"New value: +"Trace timestamp (ISO 8601); defaults to now() when omitted"
    • changedInput schema / properties / token_usage / description
      Previous value: -"Token usage breakdown"New value: +"Token usage breakdown (prompt/completion/total — used for cost analysis)"
    • changedInput schema / properties / tool_calls / description
      Previous value: -"Tool calls made during execution"New value: +"Tool calls made during execution (per-call latency, errors, input/output)"
  5. Addedv0.1.8
  6. Removedv0.1.7
  7. First observed

TDQS

A4.6/5.0
Behavior5/5

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

Annotations only indicate readOnlyHint=false, openWorldHint=false, idempotentHint=false, destructiveHint=false. The description goes far beyond those hints: it discloses that traces are immutable with no update path, that resubmission stores a second trace (no deduplication), that the local write never waits on the best-effort async OTel export, and that authentication is optional in stdio mode but requires a Bearer token over HTTP when an API key is configured. It also explains error behavior and return shape. No contradiction with annotations; the description carries the full burden and succeeds.

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?

The description is long but every section earns its place and is heavily front-loaded: the first sentence states the core action and the returned key. The 'What it does', 'When not to use it', 'Returns', 'Errors', and 'Siblings' labels give it scannable structure. It is verbose, but the density of decision-relevant information justifies the length. Loses one point for minor redundancy (e.g., restating evaluate_output reuse in both the What and param description).

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?

Given an output schema exists (describing the return JSON), 11 parameters with 100% schema coverage, and a rich nested schema, the description is complete. It covers the operation's side effects (immutable write, second trace on resubmit), error contract, authentication nuance, and sibling routing. An agent has everything needed to decide when to call log_trace and what to expect.

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%, so the schema already documents all 11 parameters in detail (e.g., agent_name is used for filtering in get_traces, cost_usd overrides per-span aggregation, metadata is queryable in dashboard but not via get_traces filters). The description adds cross-parameter context (tool_calls for trajectory rules, cost_usd/token_usage for cost rules, input/output for everything else), but much of that is already in the field descriptions. Baseline 3 is appropriate: the description complements rather than compensates.

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 a precise verb-object pair, 'Store one agent execution', and enumerates exactly what a trace captures (input, output, tool calls, spans, cost, latency, token usage) and what it returns (trace_id). It clearly distinguishes log_trace from siblings like evaluate_output and get_traces by naming them and their purposes. This is a specific, actionable statement of what the tool does.

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?

The 'When not to use it' section explicitly routes the agent: use a logger for transient log lines, call evaluate_output after logging to score, and use delete_trace then log again to modify a stored trace. It also gives a conditional alternative (IRIS_OTEL_ENDPOINT export behavior). This is exemplary guidance for selecting log_trace versus alternatives.

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

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/iris-eval/mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server