Regression gates for agents: fixtures vs live models
Split fast deterministic tests from optional live-model checks, set thresholds for variable results and triage regressions with CI evidence.
By Invicly Tech, , in Google ADK with Python for AI Agents. About 11 minutes to read.
In short
A regression gate is a CI check that stops a change from merging if agent behaviour gets worse. Split it in two: fast fixture tests with a scripted fake model and stubbed tools run on every commit and must pass every time, while live-model evaluations run on a schedule or before release, are repeated several times and pass when they meet a threshold. Keep the evidence from each run so a failing case can be triaged instead of retried until it goes green.
Explained simply
A regression is something that used to work and now does not. A regression gate is a check in your CI pipeline that refuses to merge a change if it breaks something. For agents this is tricky, because the real model does not give the same answer twice.
The fix is two lanes. The fast lane runs on every commit with a fake, scripted model and stub tools. It checks the plumbing: tools are wired, arguments parsed, users kept apart, refusals given. It is free, takes seconds and must pass every time.
The slow lane runs the real model, maybe every night or before a release. Because answers vary, each case runs several times and passes if it succeeds often enough, for example 9 times out of 10. It costs money and needs a key, so it runs where secrets are safe.
When a check fails, do not just press retry. Read the saved trace, decide whether the agent, the test or the model changed, and keep the evidence so the next person can see what happened.
Press Play on a diagram to walk through it one step at a time.
- 1Commit pushed
Pull request opens
- 2Fixture lane
Fake model, stub tools, pytest -m 'not live'
- 3Merge gate
Must pass 100 percent, runs in seconds
- 4Live lane
Nightly or pre-release, real model, repeated runs
- 5Threshold check
For example 9 of 10 runs pass per case
- 6Evidence kept
Results JSON, traces, model and ADK version
- 1Reproduce
Run only the failing case, detailed results
- 2Classify
Tool, args, answer, timeout or test
- 3Diff
Code, prompt, ADK version, model
- 4Act
Fix, correct expectation, or pin model
- 5Record
Commit note and saved results
In depth
What belongs in the fixture lane
The fixture lane tests everything that does not depend on model judgment. Tool functions are plain Python, so test them directly with pytest: normalising IDs, refusing other users' tickets, returning a clear error on timeout. Then test the agent loop with the scripted fake model from earlier modules, a BaseLlm subclass that returns fixed tool calls and answers. Run AgentEvaluator over a small fixture eval set pointed at an agent module whose root_agent uses that fake, and the trajectory scores become deterministic.
This lane needs no key, no network and no Google Cloud project, so it can run on pull requests from anyone. Keep it under a minute. If a fixture test is flaky, that is a bug in the test or the code, never in the model.
- Tool unit tests: plain pytest, parametrised
- Agent loop with ScriptedLlm: trajectory and state checks
- No secrets, no network, under a minute
- Must pass 100 percent to merge
Live checks and thresholds for variable results
Live checks answer a different question: is the real model still good enough with our prompt and tools? Run them on a schedule and before each release, not on every push. Model output varies, so a single run tells you little. Run each case several times, record which runs pass, and gate on the pass rate.
Set thresholds from evidence. Run the current release 10 times, note each case's pass rate and average score, and set the gate a little below that baseline. A case that passed 10 of 10 and now passes 6 of 10 is a regression; a case that has always wobbled between 7 and 9 needs a better test or a fixed bug, not a lower bar. For LLM-judged criteria, also sample the judge more than once with num_samples, because judges vary too.
- Every commit and pull request
- Fake model, stub tools
- Deterministic, pass 100 percent
- No secrets, no cost
- Nightly and before release
- Real pinned model
- Repeated runs, pass-rate threshold
- Uses a secret and a budget
Separating the lanes in pytest and CI
Mark live tests with a custom pytest marker, register it in pyproject.toml so pytest does not warn, and run pytest -m "not live" in the pull-request job. A second workflow triggered by a schedule runs pytest -m live with the model key from the CI secret store. Never give pull-request jobs from forks access to that secret.
Use pytest.mark.parametrize to run tool tests over many inputs from one function, and to repeat a live case several times when you count the pass rate yourself. AgentEvaluator.evaluate is async, so install pytest-asyncio and mark those tests with pytest.mark.asyncio. Pin google-adk to the release you tested, for example 2.15.1, and pin the model name, so a change in results is traceable to a change in your repository.
- pytest -m "not live" on pull requests
- pytest -m live on a schedule with the key
- Register markers under [tool.pytest.ini_options]
- Pin google-adk and the model name
Triaging a failing case
Treat a failure as evidence, not noise. First, reproduce: run only that case, for example adk eval agent_dir set.evalset.json:case_id with print_detailed_results. Second, classify the failure: wrong tool, wrong arguments, right tools with a wrong answer, a timeout or budget stop, or a wrong expectation in the test. Third, compare with the last passing run: what changed in code, prompt, ADK version or model?
Then act. A code or prompt bug gets fixed and keeps its case. A wrong expectation gets corrected in a reviewed change, with the reason written in the commit. A model change that drops quality is documented and either mitigated in the prompt or blocked by keeping the previous model pinned. Do not delete a failing case to make the gate green.
Learn it in 5 short steps
About 30m each. Track them with a timer in your plan.
- 1Run fixture tests on every commit~30m
- 2Schedule live-model checks~30m
- 3Set thresholds for variability~30m
- 4Triage a failing case~30m
- 5Keep CI evidence~30m
Key points
- Fixture tests prove plumbing: tool wiring, argument parsing, state scope and refusals, with no key and no cost.
- Live checks prove quality, but model output varies, so repeat each case and pass on a rate, not a single run.
- Use a pytest marker such as live to separate the lanes and keep secrets out of pull-request jobs.
- Pin google-adk and the model version so a change in results points to your change, not an upgrade.
- Triage a failure by reading the saved trace: was it the tool choice, the arguments, the answer or a timeout?
Key terms
Tap a card to flip it. 0/5 known
Examples
import pytest
from google.adk.evaluation.agent_evaluator import AgentEvaluator
@pytest.mark.asyncio
async def test_fixture_trajectories():
await AgentEvaluator.evaluate(
agent_module="tests.fixture_agent",
eval_dataset_file_path_or_dir="tests/eval/fixture/",
)
@pytest.mark.live
@pytest.mark.asyncio
async def test_live_quality():
await AgentEvaluator.evaluate(agent_module="support_agent",
eval_dataset_file_path_or_dir="tests/eval/live/")Same evaluator, two lanes; tests/fixture_agent wraps the scripted fake model. CI runs pytest -m "not live" on every commit.
Two GitHub Actions jobs for two lanes
Step 1: the pull-request workflow installs pinned requirements and runs the fixture lane; it has no secrets. Step 2: a separate workflow runs nightly on a cron schedule and on manual dispatch, reads GOOGLE_API_KEY from repository secrets and runs the live lane. Step 3: both upload the results folder as an artifact so failures can be inspected later. Expected evidence: a green fixture job on every pull request and a nightly report with pass rates per case.
on:
schedule: [{cron: "0 3 * * *"}]
workflow_dispatch: {}
jobs:
live-eval:
runs-on: ubuntu-latest
env:
GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with: {python-version: "3.12"}
- run: pip install -r requirements.lock && pytest -m live --junitxml=results/live.xml
- uses: actions/upload-artifact@v4
with: {name: live-eval, path: results/}Counting a pass rate for one live case
AgentEvaluator raises an assertion error when a case misses its thresholds. To gate on a rate, run the case several times yourself and count passes. Step 1: parametrise nothing; loop inside one test so the rate is computed in one place. Step 2: catch AssertionError per run. Step 3: assert the rate is at or above the baseline you measured, such as 0.8. Expected evidence: a clear failure message that shows the observed rate.
import pytest
from google.adk.evaluation.agent_evaluator import AgentEvaluator
@pytest.mark.live
@pytest.mark.asyncio
async def test_status_case_pass_rate():
runs, need, passed = 5, 0.8, 0
for _ in range(runs):
try:
await AgentEvaluator.evaluate(agent_module="support_agent",
eval_dataset_file_path_or_dir="tests/eval/live/status.test.json")
passed += 1
except AssertionError:
pass
assert passed / runs >= need, f"pass rate {passed}/{runs}"Quick reference
- Fixture lane: fake model, stub tools, every commit, must pass 100 percent
- Live lane: real pinned model, scheduled, repeated runs, pass-rate threshold
- pytest -m "not live" for pull requests; pytest -m live on a schedule
- Set thresholds slightly below a measured baseline, not by guessing
- Never expose the model key to pull requests from forks
- Keep results, traces, commit, ADK version and model name for each run
- Never delete a failing case to turn the gate green
Common mistakes
- Re-running a failed live check until it passes, which hides real regressions.
- Putting the model API key into the pull-request job so forks and untrusted code can read it.
- Setting a live threshold of 100 percent on an LLM judge, which makes the gate fail randomly.
Quick quiz
Pick an answer to see if you're right and why.
Practice exercises
Try each one yourself first. Use the hint if you get stuck, then compare with the solution.
- Exercise 1easy
Register a live pytest marker and show the two commands for the two lanes.
- Exercise 2medium
Write a parametrised fixture test for a ticket tool: valid IDs, lower-case IDs and another user's ticket.
- Exercise 3hard
Write a triage note template for a failing live case that a teammate could act on without asking you.
Check yourself
Answer in your head, reveal, then be honest with yourself.
Feel confident about this topic?
Frequently asked questions
- Can I run ADK evaluation without a model key?
- Yes, if the agent under test uses a fake model built on BaseLlm and the criteria are deterministic, such as trajectory and word overlap. LLM-judged criteria always need model access.
- How often should live checks run?
- Nightly and before each release is a common start. Run more often only if the budget allows, and cap the number of cases and repeats.
- What if the model provider changes behaviour without a version change?
- Use pinned model versions where the provider offers them, and the nightly lane will show the drift. Record it and decide whether to adjust the prompt or the expectations.
- Is it fine to retry a flaky live test automatically?
- Only as part of a declared pass-rate rule, such as 4 of 5. Silent retries until green hide regressions.