Skip to main content

LLM Reliability Analyzer

CI Coverage Tests Python Version Type Checked License Local-First

Production-grade, local-first root-cause diagnosis and reliability engineering engine for LLM, RAG, and AI Agent systems.


1. The Core Problem

Traditional software systems fail deterministically:

Error -> Stack Trace -> Source File & Line -> Fix

LLM, RAG, and Agent systems fail probabilistically across multi-step retrieval, prompt injection, reasoning loops, tool invocation, and token streaming:

User Query ──▶ Retrieval ──▶ Chunking & Rerank ──▶ Context Assembly ──▶ LLM Generation ──▶ Tool Execution ──▶ Output

When an AI system returns an incorrect, slow, or hallucinated response, developers are left with a vague symptom: "The AI gave a bad answer."

LLM Reliability Analyzer converts vague symptoms into evidence-backed diagnostic reports:

Execution Trace ──▶ Normalization ──▶ Multi-Domain Analysis ──▶ Root Cause Hypotheses ──▶ Actionable Fixes ──▶ Verification

2. Key Capabilities

  • 🔍 Multi-Domain Root Cause Diagnosis: Deterministically diagnoses RAG failures, context bloat/deficits, answer hallucinations, agent infinite loops, tool execution errors, schema violations, and LLM provider timeouts.
  • 📊 Evidence-Backed Confidence Scoring: Every diagnosis produces ranked Hypothesis candidates with mathematical confidence scores and explicit metric comparison tables.
  • 🛠️ Prioritized Developer Remediation: Actionable recommendations (P1, P2, P3) with concrete parameter adjustments and drop-in code snippets.
  • 🔄 Counterfactual Fix Verification: Simulates top-k adjustments, score cutoffs, and agent guardrails to verify fixes before production rollout.
  • 📈 Multi-Run Comparative Regression Engine: Evaluates baseline vs candidate batch executions for failure rate shifts, latency drift (p50, p90, p95, p99), and newly introduced failure categories.
  • 🧩 Structural Failure Clustering & Fingerprinting: Generates normalized SHA-256 failure signatures to group recurring production errors.
  • 📜 Custom Diagnostic Rules & Policy Engine: Define SLA thresholds and strict grounding gates via YAML, JSON, or Python.
  • ⚡ Live Tracing SDK & Provider Hooks: Zero-overhead async/thread-safe function decorators (@trace, @trace_llm, @trace_tool, @trace_retrieval) and OpenAI / Anthropic client wrappers.
  • ⏱️ Streaming & Token Latency Profiler: High-precision Time-To-First-Token (TTFT), tokens per second (TPS), inter-token distributions, and generation stall detection ($> 500\text{ ms}$).
  • 🌐 Standalone Interactive HTML Dashboards: 100% offline, zero-CDN single-file interactive HTML reports with visual waterfall execution timelines, span modal inspectors, and theme toggles.
  • 🌐 OpenTelemetry & LangSmith Ingestion: Transparently ingests standard OTLP JSON, OpenInference, OpenLLMetry, Arize Phoenix, and LangSmith run trees.
  • 💰 100% Local-First (₹0 / $0 Cloud Cost): Pure Python standard library and Pydantic v2 execution. No OpenAI/Anthropic/Gemini API keys or paid cloud connections required.

3. High-Level Architecture

                  LLM APPLICATION
                        │
          ┌─────────────┴─────────────┐
          ▼                           ▼
   Live Tracing &              External Traces
 Streaming Profiler          (OTel / LangSmith / etc.)
 (Decorators / Wrappers)              │
          │                   ┌───────┴────────┐
          │                   │ OTel Importer  │
          │                   └───────┬────────┘
          └─────────────┬─────────────┘
                        │
                        ▼
             ┌──────────────────────┐
             │ Normalization Layer  │
             └──────────┬───────────┘
                        │
                        ▼
             ┌──────────────────────┐
             │   Analysis Engine    │ (RAG, Grounding, Agent, LLM)
             └──────────┬───────────┘
                        │
          ┌─────────────┼─────────────┐
          ▼             ▼             ▼
       RAG Analyzer  Agent Analyzer  Grounding Analyzer
          │             │             │
          └─────────────┼─────────────┘
                        ▼
             ┌──────────────────────┐
             │  Root Cause Engine   │ (DiagnosticEngine)
             └──────────┬───────────┘
                        │
                        ▼
             ┌──────────────────────┐
             │    Recommendation    │ (RecommendationEngine)
             │        Engine        │
             └──────────┬───────────┘
                        │
                        ▼
             ┌──────────────────────┐
             │     Verification     │ (VerificationEngine & RegressionEngine)
             │     Rerun Engine     │
             └──────────┬───────────┘
                        │
                        ▼
             ┌──────────────────────┐
             │ Policy & Benchmark   │ (PolicyEngine & BenchmarkRunner)
             └──────────┬───────────┘
                        │
                 ┌──────┴───────┐
                 ▼              ▼
           Terminal CLI    HTML Reports

4. Example Output

Running llm-reliability diagnose trace.json --format html --output report.html on a trace where an agent got stuck calling the same tool repeatedly produces a self-contained, offline HTML dashboard:

Diagnostic report showing an AGENT_LOOP root cause with 100% confidence, a waterfall timeline of repeated tool calls, evidence chain, and prioritized remediation

No external CDN, no server — one HTML file with the waterfall timeline, ranked hypotheses with evidence, prioritized remediation, and the full metrics table baked in.


5. Installation & Quickstart

Prerequisites

  • Python 3.10, 3.11, 3.12, or 3.13
# Install core package
pip install llm-reliability

# Or install from source with development tools
git clone https://github.com/murkbyash/llm-reliability.git
cd llm-reliability
pip install -e ".[dev]"

CLI Usage

# 1. Diagnose an execution trace file (terminal text output)
llm-reliability diagnose trace.json

# 2. Output as Markdown or JSON
llm-reliability diagnose trace.json --format markdown
llm-reliability diagnose trace.json --format json

# 3. Generate interactive offline HTML report
llm-reliability diagnose trace.json --format html --output report.html

# 4. Verify whether a fix resolved issues
llm-reliability verify before_trace.json after_trace.json

# 5. Batch comparative regression analysis
llm-reliability compare baseline_batch.json candidate_batch.json

Python SDK Quickstart

from llm_reliability import diagnose, load_trace

# Load trace from disk, dictionary, or OpenTelemetry
trace = load_trace("trace.json")

# Execute root cause diagnosis
diagnosis = diagnose(trace)

print(f"Primary Root Cause: {diagnosis.primary_category.value}")
print(f"Confidence: {diagnosis.confidence * 100:.1f}%")
print(f"Severity: {diagnosis.severity.value}")

# Inspect ranked hypotheses
for hyp in diagnosis.hypotheses:
    print(f"- [{hyp.confidence * 100:.0f}%] {hyp.title}: {hyp.description}")

# Review remediation recommendations
for rec in diagnosis.recommendations:
    print(f"[P{rec.priority}] {rec.title}: {rec.description}")

6. Live Tracing & Streaming Latency Profiling

from llm_reliability import get_tracer, trace_llm, trace_tool, StreamingProfiler, wrap_stream

tracer = get_tracer()


@trace_tool(tool_name="web_search")
def search_web(query: str) -> dict:
    return {"results": ["Sample document content"]}


@trace_llm(model="gpt-4o")
def generate_answer(prompt: str) -> str:
    return "Generated answer"


# Capture trace
with tracer.start_trace("user-session-run") as trace_ctx:
    search_web("Quantum computing")
    generate_answer("Summarize results")

# Stream profiling
profiler = StreamingProfiler(stall_threshold_ms=300.0)


def sample_stream():
    yield "Hello"
    yield " world"


wrapped = wrap_stream(
    sample_stream(), on_complete=lambda p, text: print(f"TTFT: {p.time_to_first_token_ms}ms")
)
for chunk in wrapped:
    pass

7. Diagnostic Benchmark Accuracy

Evaluated across 45 ground-truth labeled benchmark scenarios spanning 9 taxonomy categories. Note: these are synthetic traces generated (and labeled) by the tool's own SyntheticTraceGenerator — the benchmark is a regression suite confirming the rule engine correctly classifies clean, unambiguous examples of each failure type, not an evaluation against real-world production traffic. Run it yourself with make benchmark or run_benchmark().

Failure Category Precision Recall F1 Score Accuracy
RETRIEVAL_FAILURE 1.00 1.00 1.00 100.0%
CONTEXT_CONSTRUCTION_FAILURE 1.00 1.00 1.00 100.0%
GROUNDING_FAILURE 1.00 1.00 1.00 100.0%
AGENT_LOOP 1.00 1.00 1.00 100.0%
TOOL_ERROR 1.00 1.00 1.00 100.0%
SCHEMA_VIOLATION 1.00 1.00 1.00 100.0%
LLM_CALL_FAILURE 1.00 1.00 1.00 100.0%
NONE (Clean Runs) 1.00 1.00 1.00 100.0%
Overall Macro Average 1.00 1.00 1.00 100.0%

8. Documentation Guides


9. License

This project is licensed under the Apache License, Version 2.0.

Metadata

Release files for llm-reliability 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for llm-reliability 0.1.0
File Size Uploaded
llm_reliability-0.1.0.tar.gz 286.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for llm-reliability 0.1.0
File Interpreter ABI Platform
llm_reliability-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 422.4 kB

Release files / llm_reliability-0.1.0.tar.gz

Download URL llm_reliability-0.1.0.tar.gz
Size 286.0 kB
Tags Source
SHA-256 checksum
How to use checksums
685e02a9bee15ebd159676eb1744d86d39a4aaadf8d54f5fe547c8c3a643f6da
BLAKE2b-256 checksum
How to use checksums
67399da4bb64562e7c0614001bcce4d3738ca750688636aa488f6bfe26262211
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 8, 2026.

Transparency log

Release files / llm_reliability-0.1.0-py3-none-any.whl

Download URL llm_reliability-0.1.0-py3-none-any.whl
Size 136.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
64e52869cea97e965dc2924f34b090f9b04df0954168c59b39ca874d2be14b3d
BLAKE2b-256 checksum
How to use checksums
727469a9920ff2e3c7ce13723f4f3d140f3a941bf1bb5ee14c3e8f536d726e5b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 8, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page