For the complete documentation index, see llms.txt. This page is also available as Markdown.

Traces and spans

Traces and spans in Stratix — the unit of "what did my AI actually do."

A trace is the record of an AI call (or a chain of calls). A span is one logical unit of work inside that trace.

Why they matter

Single-output evaluation isn't enough for agents. You need to see every tool call, every retrieval, every nested LLM call to understand what actually happened. Traces are the data structure that makes that visible.

Shape

{
 "id": "trace-123",
 "name": "answer-question",
 "inputs": {"prompt": "..."},
 "outputs": {"response": "..."},
 "started_at": "...",
 "duration_ms": 1234,
 "spans": [
 {
 "name": "retrieval",
 "kind": "tool",
 "inputs": {...},
 "outputs": {...},
 "duration_ms": 200
 },
 {
 "name": "llm-call",
 "kind": "llm",
 "model": "claude-opus-4-7",
 "inputs": {...},
 "outputs": {...},
 "duration_ms": 850
 }
 ]
}

Span kinds

  • llm — a call to an LLM

  • tool — a tool invocation (retrieval, API call, function call)

  • retrieval — a vector or keyword retrieval

  • chain — a logical group of nested calls

  • other — anything else

Trace evaluation

A trace evaluation runs a scoring config (scorers + judges) over a trace set. See Trace evaluations.

Best practices

  • Capture the whole chain. A trace with only the top-level call is easier to grade than one with all spans, but you can't root-cause failures.

  • Annotate spans. Add tags (e.g., production, ab-test-v2) to make filtering tractable later.

  • Capture latency and cost per span. They're free to ingest; they're invaluable for diagnosis.

Span-level evaluation

Some scorers and judges are configured per-span — you can ask a deterministic rule "did any span call the destructive API outside the allowed scope?" This is what makes deterministic rules powerful for agents.

Formal schema

The trace payload is specified by a JSON Schema artifact. Validate client-side before posting.

Where to next

Last updated

Was this helpful?