Skip to main content
Back to Community & Earn Hub

Continuous Agent Evals in CI/CD: Automated LLM-as-a-Judge Regression Gates with Deterministic Tool-Trajectory Assertions

@priya_sharma4 days ago·2 min read 1972 views
Continuous Agent Evals in CI/CD: Automated LLM-as-a-Judge Regression Gates with Deterministic Tool-Trajectory Assertions

Why "Vibe Checking" Prompts Breaks in Production

Every AI team has experienced this regression: you tweak a single paragraph in the system prompt to fix a formatting bug—and 3 days later you discover the agent stopped calling verify_permissions before issuing database updates.

Traditional unit tests (assert response == "Hello") fail on stochastic LLM outputs, while manual QA doesn't scale across 50 golden user scenarios per PR.


Two-Layer CI Eval Architecture

Production agent evals separate hard deterministic invariants (did it call the right tools in a safe order?) from soft semantic quality (was the final explanation accurate and grounded?):

text
[Pull Request Opened (prompts/ or agent/ changed)]
         │
         ▼
[Run 50 Golden Scenarios Against Mocked / Cassette Tools]
         │
         ├──► Layer 1: Deterministic Trajectory Assertions (0ms, $0)
         │     • assert "verify_user" called BEFORE "issue_refund"
         │     • assert total_tool_calls <= 6
         │     • assert no schema validation errors
         │
         └──► Layer 2: Calibrated LLM-as-a-Judge (Binary Pass/Fail Rubric)
               • Check factual grounding strictly against retrieved tool outputs
               • Block PR merge if composite pass rate drops > 2% vs main!

Python pytest + Trajectory Eval Harness

Here is a clean, CI-ready evaluation pattern you can run in GitHub Actions on every prompt change:

python
import pytest

def assert_trajectory_order(executed_tools: list[str], required_before: str, target: str):
    assert required_before in executed_tools, f"Missing prerequisite tool: {required_before}"
    assert target in executed_tools, f"Missing target tool: {target}"
    assert executed_tools.index(required_before) < executed_tools.index(target), (
        f"Security invariant violated: {target} called before {required_before}"
    )

@pytest.mark.asyncio
async def test_refund_agent_safety_and_accuracy(agent_runner, judge_client):
    trace = await agent_runner.run("Refund order #ORD-9921 for duplicate charge")

    # 1. Deterministic Trajectory Invariant (Catches silent tool-skipping regressions)
    tool_names = [step.tool_name for step in trace.tool_calls]
    assert_trajectory_order(tool_names, required_before="lookup_order", target="issue_refund")
    assert len(tool_names) <= 4, f"Agent looped excessively: {tool_names}"

    # 2. Binary LLM-as-a-Judge Grounding Check (Never use 1-5 Likert scales!)
    verdict = await judge_client.grade_binary(
        rubric="PASS only if the final answer cites exact order #ORD-9921 amount from lookup_order output without inventing policy rules.",
        tool_outputs=trace.tool_outputs,
        final_answer=trace.final_answer,
    )
    assert verdict.passed, f"Judge failed output: {verdict.reason}"

Two Golden Rules for CI Evals

  1. Use Binary (PASS / FAIL) Rubrics, Not 1–5 Scales: 1–5 ratings drift unpredictably (3.8 vs 4.1), whereas strict binary criteria produce >92% inter-judge consistency.
  2. Gate on Trajectory First: 80% of agent failures happen in tool selection and ordering, which can be asserted deterministically in Python before spending a cent on an LLM judge.
2 Comments

Discussion

@aditya_verma4 days ago

Binary PASS/FAIL rubrics instead of 1-5 scores is the best eval advice here. Every time a team uses a 1-5 score, PR authors argue over whether a 3.7 vs 3.9 regression matters—whereas a crisp binary policy check leaves zero ambiguity.

@neha_reddy4 days ago

Deterministic trajectory invariants (assert_trajectory_order) also catch subtle prompt regressions in milliseconds before even invoking an LLM judge.

Join the developer discussion

Sign in or create a free account to comment (+10 pts) and tag helpful AIStoreHub repositories.