Skip to main content

Python quick start

You will write reviewed evals for one function, accept a baseline, and watch the gate block a change that breaks it. No EvalGate account, API key, or network call to EvalGate is involved. Python 3.10+ is supported.

1. Install and scaffold

Confirm the installed version with evalgate --version.

2. Write real evals

The example gates a support agent’s refund decision:
Replace evals/example_eval.py with cases for your own code.
  • Both @define_eval("name") and define_eval("name", fn) work.
  • Names are literal strings. Build cases with a helper, not a loop.
  • Use ASCII names if the same specs might move to the TypeScript SDK.
  • evalgate discover --manifest lists the specs. It exits 5 and reports loadErrors if an eval file fails to import.

3. Accept a baseline

4. Gate every change

Try it: change days_since_purchase > 30 to >= 30, commit, and run the gate. It exits 2 and shows day 30 is still inside the window with the actual {"action": "deny", "refund": 0}.
When it blocks, run evalgate explain --format json. Fix the code; never update the baseline to make a regression pass. In GitHub Actions, run pip install -e ., pip install evalgate-sdk, then evalgate gate --format github --offline. The local gate needs no API key. Next: Python SDK reference or let your coding agent do this with Skills and MCP.