01Problem
A wrong final answer does not say where it came from. The figure the user needed may be missing from the candidate set, sitting below the rerank cutoff, or present in the prompt and then contradicted. Engineers stare at logs across retrieval, ranking, context, tools, and the model, then change a prompt and hope it was the right layer.
02Approach
Capture a structured trace, redact secrets, grade the answer against a labelled check, and assign a failure category only from the spans that are present. Then replay the same case with changed settings, on your own pipeline or on a demo engine, and compare two configs across a dataset.
- Ingest real traces over HTTP, OpenTelemetry (OTLP/JSON, GenAI semantic conventions), a zero-dependency Python SDK, or a LangChain / LangGraph callback. Each trace is validated, redacted, diagnosed, and stored.
- Deterministic diagnosis. Operational stops (tool error, agent loop, timeout) come first. Otherwise a retrieval problem outranks a generation problem, unless the expected figure is already in the prompt.
- A grader that is not fooled by a rejection. Contains and numeric checks fail when the answer mentions the figure only to reject it (“not $4.86B but $4.12B”).
- Replay and compare. A replay is graded against the case’s labels, not the pipeline’s self-report.
03Key decision
Keep the trace, the metric, and the failure guess in separate piles. Operational failures outrank retrieval, retrieval outranks generation, and if the evidence is thin the diagnosis is insufficient evidence. A scope with no ingest or read token configured answers 503; it never opens up.
04Architecture
- Sources: Python SDK, LangChain callback, OTLP, HTTP, or paste
- Validate and redact secrets and personal data on ingest
- Store in Postgres (or embedded PGLite in development)
- Deterministic diagnosis into one of ten failure categories
- Grader: contains, numeric, regex, or judge
- Trace, dataset, and compare UI
- Replay on your pipeline or the demo engine, back through ingest
The core lives in src/lib/tracelens/: schema, redaction, diagnosis, grading, OTLP mapping, ingest, and the demo engine. Failure categories: retrieval miss, ranking failure, context assembly, unsupported generation, tool failure, timeout, agent loop, wrongful refusal, insufficient evidence, and no failure.
05Results
The built-in demo is Northline Industrials, a finance assistant over a small filing corpus. Its seeded incident: the assistant answers $4.12 billion for FY2025 revenue because a stale FY2024-only metadata filter never let the FY2025 10-K into the candidate set. The audited figure is $4.86 billion. TraceLens classifies it as a retrieval miss, and the fix is confirmed only by replaying the same labelled case after the filter changes.
The incident, the timings, and the rerank bonus are all simulated and labelled as such in the app. Results on real pipelines: to come.