Testing AI Agents Best Practices
Ten practices for building a testing and eval pipeline that catches agent regressions early without drowning the team in flaky CI.
Search across all documentation pages
Ten practices for building a testing and eval pipeline that catches agent regressions early without drowning the team in flaky CI.
Use this list when you stand up agent quality gates or when demos are shipping without evidence.
| Stage | Habits | Exit criterion |
|---|---|---|
| Bootstrap | 1-3 | Tools unit-tested; versions pinned in reports |
| Measure | 4-7 | Gold pack + slices + budgets + adversarial cases |
| Automate | 8-9 | CI lanes live; judges calibrated where used |
| Operate | 10 | Incident→gold habit and regression checklist in use |
PR:
tool unit tests
scripted loop scenarios (smoke)
optional tiny gold smoke
Nightly / release candidate:
full gold set x N trials
cost + latency report
calibrated judge dimensions (optional)
safety / injection pack
On fail:
diff by case id -> fix agent OR fix fixtures with review
never raise thresholds silently to go greenDeterministic tool tests (1-2), a gold set with hard checks (4), and version-pinned regression runs before model/prompt ship (3, 10).
Start with tens of high-value cases including P0 and policy edges. Expand from incidents rather than inventing hundreds of low-signal chats.
Raise trials on live lanes, use pass-rate thresholds, stub flaky externals, and keep a pure deterministic lane that must always be green.
After hard checks exist and you have a small human-labeled calibration set. Judges are for soft quality, not for inventing ground truth.
Same layers, plus handoff and privilege scenarios. Each agent's tools still need unit tests.
After every incident, on major product policy changes, and on a calendar review (for example monthly) for duplicates and dead cases.
In versioned config next to the suite, not in a chat thread. Changes to thresholds need the same review as code.
They can accelerate harnesses and dashboards. You still own cases, thresholds, and the determinism split.
Smoke on PR, cache judgments, stub tools, sample live models, and reserve large N for nightly/release.
Regressions caught pre-prod, short time-to-detect on the few that escape, and a growing gold set tied to real failures rather than vanity metrics.
Yes in business terms: task success, P0 health, cost per success, and open safety issues - not raw token dumps.
Evals guard known intents before ship. Observability finds novel failures that should become the next gold cases.
Related: Why Testing an Agent Differs from Testing Deterministic Code
Related: Testing AI Agents Basics
Related: Unit Testing Individual Agent Tools
Related: Simulating Full Agent Loops in a Test Harness
Related: Building a Gold-Set Eval Suite for Agent Quality
Related: LLM-as-Judge: Scoring Agent Output Automatically
Related: Regression Testing an Agent After a Model or Prompt Change
Stack versions: Pins from the category manifest (verify at build): OpenRouter (~315+ models, July 2026 pricing/fees); LangGraph 1.0+; CrewAI 1.14+; Microsoft Agent Framework 1.0; Vercel AI SDK 6; Pydantic AI (latest); LlamaIndex (latest); OpenAI Agents SDK (latest + MCP); MCP (Linux Foundation governance); A2A (HTTP+SSE+JSON-RPC 2.0); Solana
@solana/web3.js+@solana/spl-token.
Reviewed by Chris St. John·Last updated Jul 16, 2026