Back to Blog
LLMOpsDeepEvalCI/CDTestingAI EngineeringGitHub Actions

LLMOps: Production-Grade Testing for AI Applications

How to move beyond 'vibes-based' testing with DeepEval, CI/CD tiering, and pragmatic quality gates for AI agents.

Traditional software testing is deterministic: given input X, assert output Y. LLM applications are probabilistic: the same prompt can yield varied phrasings, and evaluating whether a response is grounded in retrieved context or fabricated cannot be expressed with a simple assertEquals.

This post documents the automated evaluation pipelines we engineered for two production systems: Signale (a multi-modal WhatsApp assistant) and an AI Shopping Assistant. Both required catching prompt and retrieval regressions automatically in CI/CD without exhausting inference budgets.

Why Manual Spot-Checking Fails

Early-stage AI systems typically rely on ad-hoc manual testing: engineers tweak a system prompt, run three sample queries locally, eyeball the output, and deploy. That workflow breaks down in three predictable ways:

  1. Silent Edge-Case Regressions: Tightening a prompt constraint to fix one bug unintentionally degrades classification accuracy on previously working intents.
  2. Hallucination Drift: Changes to chunking or retrieval ranking cause the model to extrapolate beyond the retrieved database records.
  3. Context Window Degradation: Adding new tools or schema definitions dilutes attention over critical system instructions.

Unit tests cannot catch semantic drift, and running frontier-model evaluations across hundreds of scenarios on every commit is slow and expensive.

Hybrid Assertion Architecture

We combine DeepEval with a two-layer assertion strategy and CI test tiering so that fast checks run on every commit while full semantic audits run on release gates.

1. Deterministic vs. Semantic Assertions

Deterministic Assertions (Fast, Zero Token Cost) Validate structural contracts, HTTP status codes, schema adherence, and hard filter invariants on every commit:

# Executes in milliseconds with zero LLM judge calls
assert response.status_code == 200
assert "products" in response.json()
assert len(response.json()["products"]) >= 2
assert all(p["price"] <= 100 for p in response.json()["products"])

Semantic Assertions (LLM-as-a-Judge) Evaluate reasoning quality, grounding, and constraint satisfaction across multi-turn conversations:

# See: https://docs.confident-ai.com/docs/metrics-introduction
from deepeval.metrics import AnswerRelevancyMetric, FaithfulnessMetric
 
relevancy = AnswerRelevancyMetric(threshold=0.7)
faithfulness = FaithfulnessMetric(threshold=0.9)

Deterministic assertions verify that the code executed cleanly; semantic assertions verify that the response actually solved the user's request without fabricating data.

Domain-Specific Evaluation with GEval

Generic metrics like AnswerRelevancyMetric and FaithfulnessMetric are often domain-blind. In our e-commerce assistant, if a user states "I have an iPhone 14" and asks for a smartwatch, a generic relevancy metric scores a Samsung Galaxy Watch highly because it matches the keyword "smartwatch". In reality, that recommendation is a critical failure because modern Galaxy Watches are incompatible with iOS.

To encode domain invariants into the test suite, we define custom LLM judges using GEval:

from deepeval.metrics import GEval
from deepeval.test_case import LLMTestCase, LLMTestCaseParams
 
# Custom judge for Turn 2: Ecosystem Compatibility & Constraint Handling
turn_2_eval = GEval(
    name="Context Handling",
    criteria="""
    1. The agent MUST acknowledge the user's stated ecosystem constraint ("iPhone 14").
    2. Compatibility Check:
       - Primary recommendation should be Apple Watch.
       - Garmin and Fitbit are ACCEPTABLE (iOS compatible).
       - Samsung Galaxy Watch 4/5/6/7 MUST NOT be recommended without an explicit incompatibility warning.
    3. Valid Next Actions:
       a) Present iOS-compatible products immediately, OR
       b) Ask a targeted follow-up question (budget, use case) to narrow results.
    """,
    evaluation_params=[LLMTestCaseParams.INPUT, LLMTestCaseParams.ACTUAL_OUTPUT],
    model="ministral-8b-2512",
    threshold=0.7,
)
 
test_case = LLMTestCase(input="I have an iPhone 14.", actual_output=agent_response)
turn_2_eval.measure(test_case)

Using GEval solves three practical testing challenges:

  • Retrieval Noise Tolerance: Vector search often returns partially relevant candidates in the raw top-$k$ set; the judge verifies that the final synthesized answer filters out incompatible items.
  • Branching Conversational Paths: Both displaying matching products immediately and asking a clarifying budget question can be valid agent behaviors; GEval rubrics accept valid branches without brittle string matching.
  • Tone & Policy Compliance: Brand voice and safety guardrails are verified programmatically alongside functional correctness.

Selecting the Right Judge Model Tier

Running 50+ multi-turn evaluations across multiple daily deployments does not require frontier reasoning models for routine pass/fail gating. For continuous CI execution, we use Mistral's Ministral 8B:

JUDGE_MODEL = "ministral-8b-2512"  # $0.15 / 1M input & output tokens
ModelInput (per 1M)Output (per 1M)ContextRole in Pipeline
ministral-8b-2512$0.15$0.15256kEvery-deploy ci-core gate
Frontier (gpt-4o / claude-sonnet)$2.50–$3.00$10.00–$15.00128k–200kPeriodic Golden Dataset audits

Smaller judge models can occasionally be more lenient on subtle multi-hop logic errors than frontier models. We handle this by matching the judge model to the test tier: ministral-8b-2512 gates every deployment in ci-core to catch regressions quickly and cheaply, while pre-release Golden Dataset audits promote the judge to a frontier model.

Two-Tier CI/CD Execution

Running the full evaluation suite on every pull request slows feedback loops to 30+ minutes. We split the integration suite into two execution tiers:

TierDirectoryTriggerCoverageDuration
ci-coretests/integration/ci_core/Every deploymentCritical routing, code compilation, API contracts5–7 min
Full Suitetests/integration/Pre-release / ManualFull 50+ multi-turn golden scenarios~30 min

GitHub Actions Workflow

# .github/workflows/deploy-backend.yml
on:
  workflow_dispatch:
    inputs:
      skip_integration_tests:
        description: 'Skip Integration Tests (Break-Glass P0 Only)'
        default: false
        type: boolean
      run_all_integration_tests:
        description: 'Run ALL integration tests (default: ci-core only)'
        default: false
        type: boolean
 
jobs:
  run_integration_tests:
    steps:
      - name: Run Evaluation Integration Tests (DeepEval)
        run: |
          if [ "${{ inputs.run_all_integration_tests }}" == "true" ]; then
            echo "Running ALL integration tests..."
            uv run pytest tests/integration -svx
          else
            echo "Running CI-CORE integration tests only..."
            uv run pytest tests/integration/ci_core -svx
          fi

This provides three operational modes:

  1. Standard Deploy (ci-core): Fast 5-minute feedback on intent routing, sandbox code execution, and core relevancy.
  2. Release Audit (Full Suite): Comprehensive evaluation across all edge-case personas and multilingual flows before major releases.
  3. Break-Glass Override: Documented bypass reserved strictly for hotfixing production outages where downtime risk outweighs regression risk.

Networking & Database Access in CI

End-to-end RAG evaluation requires querying live vector indexes and relational catalogs (hosted on Azure Database for PostgreSQL), while GitHub-hosted runners execute from ephemeral public IPv4 addresses.

Ephemeral Firewall Scoping for Rapid PoCs

During the initial 4-week PoC phase, we used scoped, run-specific firewall rules with guaranteed teardown:

- name: Add Scoped Firewall Rule for Runner IP
  run: |
    IP_ADDR=$(curl -s ipv4.icanhazip.com)
    az postgres flexible-server firewall-rule create \
      --name ${{ env.POSTGRES_SERVER_NAME }} \
      --rule-name "ci-allow-${{ github.run_id }}" \
      --start-ip-address $IP_ADDR \
      --end-ip-address $IP_ADDR
 
- name: Run Integration Tests (DeepEval)
  run: uv run pytest tests/integration/ci_core -svx
 
- name: Remove Firewall Rule
  if: always() # Guaranteed teardown on pass, fail, or cancellation
  run: |
    az postgres flexible-server firewall-rule delete \
      --rule-name "ci-allow-${{ github.run_id }}" --yes

Using if: always() keyed to github.run_id ensures temporary runner access is revoked immediately after the test step completes, even if pytest exits with a failure.

Production Hardening: Zero-Trust VNet Architecture

For enterprise deployments and compliance-sensitive workloads, ephemeral IP whitelisting is replaced by private network topologies defined in Terraform:

PatternMechanismTarget Environment
OIDC Federated AuthGitHub Actions authenticates to Azure via short-lived OIDC tokens—zero static credentials stored in secretsBaseline for all cloud workflows
Azure Private LinkPostgreSQL binds exclusively to a private VNet endpoint with public network access disabledRegulated workloads (SOC2, ISO 27001, GDPR)
VNet-Injected RunnersManaged GitHub runners provisioned inside the Azure VNet subnet, routing traffic over the private backboneProduction CI/CD pipelines

Secrets Isolation

All provider credentials and connection strings are scoped to GitHub Environment Secrets and injected at runtime:

SecretPurpose
AZURE_CREDENTIALSIdentity federation for Azure infrastructure operations
DATABASE_URLRead-only PostgreSQL + pgvector test catalog connection
MISTRAL_API_KEYPrimary compiler and ministral-8b judge inference
AZURE_OPENAI_API_KEYVector embeddings and fallback judge evaluation

Closing the Loop: Golden Datasets from Production Traces

Static test suites only catch known failure modes. To keep evaluation coverage aligned with real user behavior, golden test cases are parameterized directly from a versioned JSON dataset:

@pytest.mark.parametrize("test_case", load_dataset("golden_dataset.json"))
def test_scenarios(test_case):
    response = run_agent(test_case["input"])
    assert_test(
        test_case,
        metrics=[faithfulness, relevancy, turn_2_eval]
    )

As production telemetry surfaces low-confidence queries or fallback triggers (via Arize Phoenix or LangSmith traces), anonymized failure traces are promoted directly into golden_dataset.json—turning every production edge case into a permanent regression gate.

Adopting Only What Solves the Bottleneck

Evaluation frameworks ship with extensive ancillary features—hosted dashboards, synthetic dataset generators, and proprietary tracing layers. We intentionally adopted only the primitives required to solve our immediate bottleneck: deterministic pytest integration (assert_test) and domain-specific rubric scoring (GEval).

Start with the smallest mechanism that enforces a hard quality gate in CI/CD, verify that it catches real prompt and retrieval regressions on every pull request, and expand tooling only when operational telemetry proves the need.


Looking to implement automated LLM evaluation gates in your CI/CD pipeline? Get in touch.

— Pedro

Founder & Principal Engineer