[KongchangAI]
· 3 min read· 1,900 words

Write Evals Before Shipping LLM Features, Not After the Bug Reports

Write Evals Before Shipping LLM Features, Not After the Bug Reports

Structured evaluation systems must be established before deploying LLM features to production, or you will face undetectable silent regressions.

The article argues for writing Evals before shipping LLM features, rather than reactively patching after bugs appear. The author points out that "vibes-based" quality assurance relying on manual Playground checks creates a false sense of security, because the probabilistic nature of LLMs means minor prompt changes can trigger silent regressions across edge inputs. The solution is a three-layer evaluation pyramid: fast deterministic assertions (millisecond-level, zero-cost), LLM-as-a-Judge model grading (covering qualitative dimensions like tone and relevance), and production shadow routing (validating candidate versions with real traffic). Supporting requirements include building high-fidelity Golden datasets from gateway logs, implementing guardrails and Token budget control at the gateway layer, and embedding evals into CI/CD as merge gates.

AI applications running in production without a structured evaluation system often develop Silent Regressions within weeks of deployment, gradually eroding the reliability of downstream systems. When engineers modify system prompts, switch model checkpoints, or adjust tool schemas, traditional unit tests simply cannot catch semantic degradation or subtle format drift.

The core argument of this article is clear: Write Evals before shipping LLM features, not after the first bug report comes in.

LLM Feature Evaluation

Why "Vibes-Based" Quality Assurance Fails

Vibes-based QA refers to engineers manually typing five to ten sample prompts into a Web Playground, glancing at the outputs, and deciding "looks good to me" before deploying. This approach gives teams a false sense of security while exposing production endpoints to a large number of unhandled edge cases.

The probabilistic nature of LLMs makes them fundamentally different from deterministic software. A prompt change that appears to improve complex reasoning capabilities may silently break JSON parsing on twenty other inputs. Stanford's Center for Research on Foundation Models has demonstrated through its HELM framework that model performance across dimensions like accuracy, robustness, and calibration fluctuates dramatically with minor prompt variations.

The manual Playground check process looks like: prompt v1.1 → 5 ad-hoc tests → "looks good" → deploy → production regression. The automated pre-release evaluation process looks like: prompt v1.1 → CI evaluation harness (200 test cases) → assertions + grader scores → pass gate → deploy.

Without pre-release evals, debugging is entirely reactive. Customer complaints trigger hasty prompt modifications, which introduce new regressions elsewhere in the application lifecycle. Breaking this cycle requires treating model prompts, context retrieval logic, and tool declarations with the same testing rigor as backend code.

HELM Framework (Holistic Evaluation of Language Models) is a comprehensive language model evaluation benchmark system proposed by Stanford's Center for Research on Foundation Models in 2022. Its core contribution lies in breaking past the limitation of measuring models with a single accuracy metric, instead decomposing evaluation into seven dimensions: accuracy, calibration, robustness, fairness, bias, toxicity, and efficiency, and conducting cross-model comparisons across dozens of standardized scenarios. One of HELM's key findings is that performance variation within the same model across different prompt templates often exceeds the average variation between different models. This conclusion directly supports the article's core argument—minor prompt changes are sufficient to trigger significant downstream behavioral shifts, making manual spot-checks with a handful of examples inadequate as a release criterion; automated evaluation sets covering multiple dimensions and scenarios are essential.

What It Means to Write Evals Before Release

Writing evals before release means treating prompts and model behavior as an explicit engineering contract, backed by verifiable test suites and automated deployment gates. An eval consists of three core components: input prompts, execution environment, and evaluation criteria (Rubric), the latter producing deterministic or quantified scores.

Anthropic in its AI Agent evaluation guide categorizes evals into two types: Capability Evals and Regression Evals. Capability evals examine whether an Agent or model can complete novel complex tasks, with initial pass rates typically low; regression evals ensure that previously validated behaviors remain intact through continuous iteration.

To achieve effective pre-release evaluation, engineering organizations must establish specific acceptance thresholds across multiple operational dimensions before merging PRs:

Evaluation DimensionPrimary Risk MitigatedEvaluation MechanismCI Latency Impact
Output Syntax & SchemaDownstream JSON/XML parsing crashesExact match, Pydantic/Zod Schema< 5ms
Domain CorrectnessFactual errors, outdated information, hallucinated citationsDeterministic queries, semantic embedding distance10-50ms
Instruction FollowingIgnoring system constraints or format rulesModel-based scoring (LLM-as-a-judge)500-2000ms
Tool Execution SafetyMalformed parameters, unauthorized API callsSchema validators, static parameter assertions< 10ms
Toxic Content & PolicyPII leakage, policy violations, unsafe textGateway guardrails, regex pattern scanning5-20ms

Rubric in the context of LLM evaluation refers to an explicit, actionable written definition of "what constitutes an acceptable output." A well-designed Rubric typically includes scoring dimensions (such as factual accuracy, format compliance, tone consistency), judgment criteria for each dimension (binary pass/fail or graded scale), and specific positive and negative examples. Anthropic emphasizes in its evaluation guide that strictly limiting scoring criteria to binary judgments can significantly improve the alignment between LLM-as-a-judge and expert human judgment, because graded scales tend to introduce scorer subjectivity drift and model self-scoring bias. Rubric quality directly determines the signal-to-noise ratio of regression evals: overly lenient criteria let real degradations slip through, while overly strict criteria generate excessive false positives that slow down CI cadence.

Three-Layer Evaluation Pyramid Architecture

Attempting to evaluate every PR with expensive model calls will paralyze the CI pipeline. The sensible approach is implementing a three-layer evaluation pyramid:

Layer 1: Fast Deterministic Assertions

This layer executes locally without sending requests to external models. It validates non-negotiable structural requirements: whether responses are valid JSON conforming to Schema, whether regex patterns match required fields, whether outputs strictly exclude forbidden substrings or unmasked Tokens, and whether output Token length stays within application limits. Because runtime is measured in milliseconds and inference cost is zero, they can run on every commit and PR.

Layer 2: Model-Graded Evaluation (LLM-as-a-Judge)

When testing qualitative dimensions like tone, semantic relevance, or summary completeness, pure code assertions fall short. This layer uses a highly capable model to evaluate the primary model's generations against structured scoring criteria. Academic research shows that when scoring criteria are strictly limited to binary pass/fail standards, automated graders can provide scalable, reproducible scores that correlate highly with expert human judgment.

Layer 3: Production Shadow Routing

Offline evaluation cannot fully reproduce the entropy of real user inputs. The third layer asynchronously replicates a small fraction of production requests to candidate prompts or models, measuring latency, Schema reliability, and error rates without affecting end users.

How to Build High-Fidelity Golden Datasets

The reliability of an evaluation suite depends on the dataset it evaluates. Synthetic test cases conceived by engineers during initial development rarely reflect the linguistic diversity, typos, prompt injections, and complex phrasing found in real user queries.

Key steps for building high-fidelity Golden datasets:

  1. Log real requests: Export raw prompt and completion payloads in structured form to centralized storage via an AI gateway.
  2. Filter by anomaly characteristics: Isolate sessions with high user latency, multiple retries, explicit negative feedback, or client-side JSON decoding failures.
  3. Anonymize and desensitize: Remove PII using automated regex and data access desensitization before storing in the test repository.
  4. Curate benchmark slices: Build 50-200 diverse golden samples categorized by task, covering edge-case tool calls, adversarial prompt injections, and multilingual prompts.

Once the dataset is established, every user-reported production bug should be directly converted into a permanent new test fixture in the Golden dataset, preventing that specific failure mode from recurring.

Gateway-Layer Guardrails and Budget Control

Pre-release evals validate expected functional quality, but production guardrails provide indispensable defense against real-time anomalies. Even thoroughly evaluated prompts can produce unexpected behavior when faced with unconventional inputs.

At the gateway layer, teams define strict runtime safety parameters that intercept problematic requests before they consume downstream resources or expose harmful content to users. By assigning fine-grained virtual keys to specific services, teams can configure automatic rate limiting and Token budgets. If an unoptimized prompt causes a spike in Token consumption during integration testing, the gateway enforces budget thresholds before runaway costs accumulate.

CI/CD Release Gate Pipeline

Operationalizing pre-release evals into standard PR workflows: merges must be blocked when any core regression check fails or model-graded quality falls below statistical baselines.

Running tests through a locally orchestrated gateway in CI ensures all requests benefit from semantic caching, dramatically accelerating repeated test suite execution while preventing identical evaluation runs from consuming unnecessary API quota.

Evaluation Architecture Comparison

Evaluation MethodExecution LatencyCost per 100 RunsDeterminismBest Use Case
Exact string match/regex< 1ms$0.00100% deterministicID validation, output format, Token masking
Pydantic/JSON Schema2-10ms$0.00100% deterministicStructured entity extraction, tool call signatures
Semantic embedding distance20-80ms$0.001High (>99%)Factual similarity, document retrieval scoring
Small model grader400-900ms$0.02Moderate (90-95%)Coherence, conversational tone, simple classification
Frontier model grader1-3s$0.40High at temperature 0.0Complex reasoning, multi-step Agent planning, coding accuracy
Human expert reviewHours to days> $50.00VariableEdge case calibration, new scoring criteria development

Combining these layers into an automated sequence provides comprehensive coverage without exhausting engineering budgets.

Key Takeaways

Deploying highly reliable AI products requires abandoning ad-hoc Playground checks in favor of structured, repeatable testing. By establishing layered evaluation pipelines—combining instant Schema validation with model-graded regression suites—engineering organizations can detect behavioral regressions before code reaches production infrastructure. Leveraging enterprise-grade AI gateways provides the operational foundation for this workflow, enabling centralized request capture, synthetic response simulation, and strict runtime guardrails.

Background Supplement

LLM-as-a-Judge refers to using a more capable language model as an automated scorer to rate another model's (typically the model under test) output against a preset Rubric. Its advantages include strong scalability, costs far below human review, and judgment capabilities for open-ended generation tasks (such as tone, coherence, summary completeness) that pure code assertions cannot cover. However, the method has known biases: position bias (tendency to prefer earlier responses), length bias (preferring longer outputs), and self-preference (preferring responses similar to its own style). Mitigation strategies include randomizing comparison order, setting temperature to zero for reproducibility, using multi-grader voting, and constraining scoring criteria to verifiable specific conditions rather than abstract holistic impressions.

Shadow Routing is a zero-user-perception traffic replication technique. The gateway asynchronously duplicates a copy of real requests entering production and sends them to candidate models or candidate prompts, recording and evaluating responses from the candidate path without returning them to users—users always receive the primary path's response. The value lies in this: no matter how offline Golden datasets are constructed, they cannot fully cover the linguistic diversity and long-tail edge cases in real traffic, while shadow routing can continuously collect performance data of candidate versions under real distributions without bearing online risk. Two practical considerations: first, control the replication traffic ratio to avoid cost overruns; second, focus evaluation metrics on quantifiable signals like latency, Schema compliance rate, and error rate, rather than subjective quality assessments.

One-line Summary

Structured evaluation systems must be established before deploying LLM features to production, or you will face undetectable silent regressions.

Paragraph Summary

The article argues for writing Evals before shipping LLM features, rather than reactively patching after bugs appear. The author points out that "vibes-based" quality assurance relying on manual Playground checks creates a false sense of security, because the probabilistic nature of LLMs means minor prompt changes can trigger silent regressions across a wide range of edge inputs. The solution is a three-layer evaluation pyramid: fast deterministic assertions (millisecond-level, zero-cost), LLM-as-a-Judge model grading (covering qualitative dimensions like tone and relevance), and production shadow routing (validating candidate versions with real traffic). Supporting requirements include building high-fidelity Golden datasets from gateway logs, implementing guardrails and Token budget control at the gateway layer, and embedding evals into CI/CD as merge gates, achieving comprehensive coverage at controllable cost.

#LLM evaluation#Evals before release#silent regression#LLM-as-a-Judge#Golden dataset#CI/CD release gate#AI gateway guardrails#shadow routing#HELM framework#production LLM quality assurance
Share:

Related articles