9. Gate it in CI
Everything so far ran on one machine. The point of a gate is that it runs on every
pull request and a change that makes the agent worse cannot merge. This tutorial
puts the TinyLM run in GitHub Actions, shows what changes for a real model, and
explains check.sh, which keeps these tutorials honest.
The workflow
Section titled “The workflow”examples/tinylm/github-actions.yml is
a complete workflow. Copy it to .github/workflows/agent-eval.yml and the
examples/tinylm files to evals/. The steps that matter:
steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: {python-version: '3.12'} - name: Sandbox prerequisites run: sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0 - run: pip install 'evalsi==0.3.1' 'evalsi-harness==0.3.1' - run: evalsi doctor --require agent - name: Start TinyLM run: | python3 tinylm.py --port 8765 2> tinylm.log & for _ in $(seq 50); do curl -sf http://127.0.0.1:8765/healthz && break; sleep 0.1; done - name: Run the agent gate run: evalsi run -f run.yaml --output results.json - name: Build the report if: always() run: evalsi report results.json -o report.md - name: Show the report in the job summary if: always() run: cat report.md >> "$GITHUB_STEP_SUMMARY"- The
sysctlline is required onubuntu-latest(24.04), which restricts the user namespaces the sandbox needs. Without itdoctor --require agentfails, and the run would exit 1 rather than quietly running with less isolation. doctor --require agentfails fast, with a readable reason, before any work.- Pin the versions. A gate that silently upgrades its own evaluators is not a stable gate.
if: always()keeps the report when the gate fails, which is when you need it, and puts the metrics on the pull request’s checks page.
Exit 3 (a gate failed) and exit 1 (the run broke) both fail the job. Read the job summary to tell which; the report says “gates” for the first and lists errors for the second.
Swapping in a real model
Section titled “Swapping in a real model”The spec’s target is the only part that names TinyLM. For a model behind an
OpenAI-compatible endpoint (OpenAI, vLLM, a gateway):
target: connector: openai-compatible model: your-model-name # whatever your endpoint serves base_url: https://api.openai.com/v1 api_key_env: AGENT_MODEL_KEY # the variable that holds the keyor for Claude:
target: connector: anthropic model: claude-sonnet-5-5 api_key_env: AGENT_MODEL_KEYand in the workflow, drop the TinyLM step and pass the key from a repository secret to the run step only:
- name: Run the agent gate env: {AGENT_MODEL_KEY: '${{ secrets.AGENT_MODEL_KEY }}'} run: evalsi run -f run.yaml --output results.jsonWith a real model, add what tutorial 4 taught: trials: 3, a pass^3 gate, an
error-rate gate, and a budget (budget: {usd: 0.50, wall_clock: 5m}) so a bad
prompt cannot spend without limit. Keep the TinyLM job too: it is free, fast and
deterministic, so when it fails, something in your environment, checker or
evaluators changed, not the model.
The maintained action
Section titled “The maintained action”The repository root has an action.yml that wraps the same
steps (install, run once, summary, exit code) for published 0.3.0 and later. See
guided setup for its inputs,
including advisory baseline comparison. It does not start a model for you, so for
TinyLM the plain workflow above is simpler.
check.sh: keeping the tutorials true
Section titled “check.sh: keeping the tutorials true”examples/tinylm/check.sh runs every scenario in
these tutorials, from a temporary copy of the directory, with its own TinyLM, and
checks each exit code:
bash examples/tinylm/check.shok exit 0 tinylm-good fixes all three tasksok exit 3 tinylm-lazy claims success and does nothingok exit 3 tinylm-partial fixes one bug per taskok exit 3 tinylm-looper hits max_stepsok exit 3 tinylm-hallucinator calls a tool that does not existok exit 0 tinylm-clumsy recovers from malformed argumentsok exit 0 tinylm-sneaky passes a gate that ignores policyok exit 3 tinylm-flaky fails pass^3ok exit 3 injected faults: one trial runs out of stepsok exit 0 tinylm-good ignores a prompt injectionok exit 3 tinylm-gullible follows itok exit 0 tinylm-pusher stops when a push is deniedok exit 3 tinylm-stubborn retries the pushok exit 0 tinylm-support makes exactly the expected tool callsok exit 3 tinylm-reckless refunds without lookingok exit 0 record a session logok exit 0 replay it with the model stoppedok exit 1 a live run with the model stopped is an error, not a failed gateIt takes about 40 seconds. The repository’s own CI runs it against the source tree on every change (the “Every TinyLM tutorial scenario exits as documented” step), so if an evaluator, the harness or a default changes in a way that would make one of these tutorials wrong, the build says so.
The same pattern works for your own agent: a handful of deliberately broken stand-ins, each with the exit code it must produce. If the broken agent ever passes, your evaluation has a hole, and you find out before a real regression slips through it.
Where to go next
Section titled “Where to go next”- Agent runs: every harness option, environment field and grader, and the benchmark importers (SWE-bench, τ-bench, Terminal-Bench, BFCL).
- Bring your own agent: A2A, MCP, HTTP, OpenAI Responses, ACP, or a CLI such as Claude Code or Codex inside the sandbox.
- Trace sources: score production traces with the same evaluators.
- Fine-tuning: the same evaluators as RL rewards.
- Onboarding study: what went well and badly the first time.