Skip to content

Replay Platform

The Replay Platform is Layerrs observability layer. Every request that passes through the system leaves a complete trace, not just the request and response, but the full routing decision, the candidates that were considered, the scores they received, and the rationale for the choice.

FilePurpose
replay/comparator.tsCompares two traces side-by-side
replay/analysis.tsAnalyses trace patterns and trends
replay/types.tsCore replay types
storage/replay.tsPersistence layer for traces
explainability/explainer.tsBuilds human-readable explanations
src/features/replay/DecisionBreakdownPanel.tsxUI for decision breakdown
src/features/replay/OrchestrationReplayStudio.tsxReplay studio interface
src/traces/TracesPage.tsxMain traces listing page

Every trace contains:

  • Request: Full prompt, metadata, detected workload
  • Routing decision: Chosen provider, model, strategy
  • Candidate list: All providers considered, with scores
  • Fallback chain: Ordered list of fallbacks
  • Execution: Latency, token usage, actual cost
  • Outcome: Quality score, user feedback (if any)
  • Explanation: Structured rationale for the decision

compareTraces takes two trace IDs and produces:

  • Score delta: How the two decisions differed in quality/cost
  • Adaptive promotion: Whether the cheaper option was good enough to promote
  • Numeric direction: Whether the system trended toward better or worse
  • Reason count: Breakdown of why differences occurred

The DecisionBreakdownPanel renders a step-by-step explanation:

  1. What was detected about the workload
  2. Which strategy was chosen and why
  3. How each candidate was scored
  4. Why the winner was picked
  5. What the fallback chain looked like
  6. How much was saved (or spent extra) vs baseline

The OrchestrationReplayStudio lets you:

  • Replay any historical request with a different strategy
  • Compare outcomes across strategies
  • See what would have happened with a different provider
  • Export replay data for external analysis

storage/replay.ts handles:

  • listRecentTraces: Recent traces with filtering
  • analyzeRecentTraces: Aggregate analysis over a time window
  • TTL-based cleanup for old traces
  • Export to external observability systems