CI
Gate every pull request on replayed trajectory tests with no secrets, and run a live suite with pass thresholds before deploys.
Two tiers work well for agents:
- Golden, on every pull request. A small, fast set replayed from committed fixtures. No API keys, no model calls, deterministic. It gates the merge.
- Full, before deploys or nightly. A larger suite in
livemode withrunsandpass_threshold, so nondeterminism becomes a pass rate you can gate on. It costs money, so it does not run on every pull request.
Why CI does not call models in-process
In CI, the default mode is replay. A run counts as CI when CI is set to anything but false or 0 (any case),
or, when CI is unset or empty, when a CI system's own variable is set: JENKINS_URL or BUILD_ID (Jenkins),
TF_BUILD (Azure Pipelines), CODEBUILD_BUILD_ID (AWS CodeBuild), TEAMCITY_VERSION (TeamCity), BUILDKITE,
GITHUB_ACTIONS, GITLAB_CI, CIRCLECI, TRAVIS, BITBUCKET_BUILD_NUMBER, DRONE, APPVEYOR, SEMAPHORE,
BITRISE_IO, CF_BUILD_ID (Codefresh), HARNESS_BUILD_ID or CONTINUOUS_INTEGRATION. An explicit CI=false wins
over all of them.
Detection is a safety net, not a contract: a CI system not on that list looks like a laptop, where the default is
auto and a missing fixture records live. Pass --mode replay (or set VIEWPORT_EVALS_MODE=replay, or run
pytest --viewport-mode replay) in every pull request job anyway, belt and braces, so the gate never depends on
which variables the runner happens to set.
In replay, a missing or stale fixture, a request the recording cannot answer, or a judge verdict that is not cached
each fail the case as an error. Replay also fails closed: a connection with no
recording to a host not in replay.allow_hosts, from the agent through fetch, node:http, a raw socket, httpx,
requests or boto3, from a thread or timer with no scope, or from a worker thread, is refused and errors the case
with evals.replay_blocked, even if the agent swallows the error. Child processes get a blackhole proxy, which
stops clients that honor proxy variables, and Node children also preload the socket guard, so their fetch is
refused too; counting a child's refusals is best effort. The report counts refusals as blocked, so a live call made through any
of those paths cannot hide behind "recorded 0".
That makes a pull request run with no secrets and no model spend for everything the agent does in-process. It is
not a sandbox: a child process that ignores proxy variables, or code outside the run, is not covered (see
what is enforced). Keep provider keys out of the pull request
job's environment as well, so nothing can authenticate even if it gets out. Record locally (auto records only
what is missing, --rerecord refreshes everything) and commit the fixtures with the change.
Two things to set up once:
- Gateways and other providers. OpenAI, Anthropic, Gemini, Azure, Bedrock, Vertex AI, OpenRouter, Portkey, Groq,
Mistral, Together, Fireworks, DeepSeek, xAI and Cerebras are recorded out of the box, and a client wrapped with
wrap()registers its own base URL. For anything else (a LiteLLM proxy, a private endpoint), add its host toreplay.hostsbefore recording. Python records throughhttpxclients only; aboto3orrequestsmodel call is blocked in replay rather than recorded. - Your own services. Loopback is blocked like any other host. List tool servers and local databases a case may
reach in
replay.allow_hosts, or fake them.
A mode committed to the config cannot turn CI into a run that calls models. In CI, a config auto, record
or live is ignored with a warning and the run uses replay. The nightly tier opts in explicitly with
--mode live (or VIEWPORT_EVALS_MODE=live, or ci_override / ciOverride: true next to the config's mode), and
gets one warning saying model calls can reach the network.
Exit codes
| Code | Meaning |
|---|---|
| 0 | every case passed, was skipped, or failed as expected (xfail) |
| 1 | some case failed, errored, or passed unexpectedly (xpass) |
| 2 | usage or spec error: a bad flag, an invalid case file, a config error |
A workflow
This GitHub Actions workflow runs the golden tier on pull requests and the full tier on main:
# Two-tier agent evals in GitHub Actions.
# golden: small, fast, replayed from fixtures. Runs on every PR, no API keys, gates merge.
# full: large suite, live model calls with pass thresholds. Gates deploys.
# Copy to .github/workflows/agent-evals.yml and adjust paths.
name: agent-evals
on:
pull_request:
push:
branches: [main]
workflow_dispatch:
jobs:
golden:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with: { node-version: 22, cache: npm }
- run: npm ci
# Replay mode: deterministic, offline, seconds. Exit code 1 fails the check.
- name: Golden evals (replay)
run: >
npx @viewportai/evals run "evals/**/*.yaml" --mode replay --tag golden
--reporter pretty
--reporter junit=reports/evals-junit.xml
--reporter markdown=reports/evals.md
- name: Comment on the PR
if: always()
env:
GH_TOKEN: ${{ github.token }}
run: gh pr comment ${{ github.event.pull_request.number }} --body-file reports/evals.md --edit-last --create-if-none
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
if: always()
with: { name: evals-golden, path: reports/ }
full:
# Live calls cost money: run on main and before deploys, not on every PR.
if: github.event_name != 'pull_request'
runs-on: ubuntu-latest
environment: evals
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with: { node-version: 22, cache: npm }
- run: npm ci
- name: Full suite (live)
env:
ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
run: >
npx @viewportai/evals run "evals/**/*.yaml"
--mode live --concurrency 8
--reporter pretty
--reporter json=reports/evals.json
--reporter junit=reports/evals-junit.xml
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
if: always()
with: { name: evals-full, path: reports/ }
# A deploy job can then depend on the full suite:
# deploy:
# needs: full
# ...
For a Python project, the golden step is:
- uses: astral-sh/setup-uv@1db35dd8eee11c5894872e0b383ae6c406cf738d # v10.4.0
- run: uv sync
- run: uv run viewport-evals run --mode replay --tag golden --reporter junit=reports/evals-junit.xml
# or, with the pytest plugin: uv run pytest -m golden --viewport-mode replayviewport-evals init writes a starter workflow for your language next to an example case.
Reporters in CI
githubwrites annotations on the failing case's line and a step summary. It is on by default whenGITHUB_ACTIONS=true.junit=pathfeeds test result views in most CI systems.markdown=pathwrites a summary sized for a pull request comment.json=pathwrites theevals/report/v1report, identical in both languages, for your own tooling.
Pass --reporter more than once to combine them. Details: reporters.
Gating on real regressions
On a live suite, --repeat 2 re-runs each failure twice and separates flaky failures (some re-run passed; they do not
fail the job) from regressions (none did). Add --model a,b to the nightly job to keep a cheaper model qualified
next to the one you ship; see model matrix and flakes. Add --reporter langfuse (or
another exporter) to send the scores to your observability platform; an export failure never fails the
job unless you pass --strict-export.
Results directories are off under CI. Pass --results and upload .viewport/evals/runs as an artifact to
inspect a CI run locally with viewport-evals ui.
Selecting cases
Tag golden cases (tags: [golden]) and select them with --tag golden (CLI) or -m golden (pytest). Use
--exclude-tag, --grep on id or description, and --bail to stop starting cases after the first failure.
--concurrency sets the case pool (default 4).