The Code/X ArchiveView on X
Google Cloud Tech

@GoogleCloudTech

6 ways to test AI agents with eval engineering

Every software engineer knows how to write deterministic tests (assert add(2, 2) == 4). But traditional unit tests break down the moment an agent takes actions on our behalf.

For instance, in multi-turn workflows, every single error compounds exponentially across turns. More critically, when an agent interacts with live databases, testing only the final outcome misses the trajectory of how the outcome was reached. It is possible for the agent to return a success message even after making an unauthorized action or calling a wrong API.

Production reliability requires moving from vibe checks to Eval engineering, as in treating evaluations as automated, measurable CI/CD test suites.

By Praveen Rajasekar

Here are the 6 practical ways to build evals for production AI:

  1. Start with deterministic schema checks. Before spending tokens asking an LLM if an answer looks good, check the basics locally. Verify whether the structural constraints are valid (like the validity of the JSON), required fields are present, and whether the agent calls the right tool with the expected arguments. Use deterministic assertions like the tool_call_valid and tool_parameter_kv_match checks in Gemini Enterprise Agent Platform Gen AI evaluation service to catch syntax errors, bad types, and hallucinated tool names in milliseconds.
  2. Measure groundedness mathematically. In enterprise search and RAG pipelines, we cannot guarantee zero hallucination, but we can systematically lower their occurrence and mitigate. Check whether the factual claims trace directly back to the retrieved source documents. Using tools like the Check Grounding API and rag_context_recall on the Gemini Enterprise Agent Platform gives you an objective attribution score between 0 and 1. If a generated response scores below a strict threshold (like 0.9), don't leave it to chance, treat it as an assertion failure and reject the output before it ever reaches a user.
  3. Inspect the execution trajectory of multi-turns. It is important to test an agent’s tool calling path along with the output. Using trajectory metrics like trajectory_in_order_match in Gemini Enterprise Agent Platform Gen AI evaluation service, you can assert that tools were executed in the right dependency order. Ask yourself: Did it query the user profile before initiating the refund? Did it validate permissions before modifying state? We should penalize unnecessary tool calls and circular loops in the scoring rubrics.
  4. Build AutoRaters with strict rubrics. AutoRaters are lightweight models used as dedicated judges, to score tool use quality, fulfillment, and safety on an explicit 1–5 scale with written rationale. To get consistent results, define an explicit grading rubric using tools like Gemini Enterprise Agent Platform to run an evaluation, where every score from 1 to 5 has clear, mutually exclusive criteria and penalties for common edge cases. Most importantly, require the AutoRater to output its step-by-step reasoning before emitting the final score. This chain-of-thought requirement forces the judge to ground its evaluation in actual evidence and gives your team an instant debug trace whenever a test fails.
  5. Pairwise AutoSxS tournaments for model swaps. Run an automated head-to-head tournament. AutoSxS tests your candidate model directly against your current production baseline across hundreds of real queries. An automated judge reviews both responses side-by-side and declares a winner with written justifications. Crucially, the system swaps the order of the answers between evaluations to cancel out the model's natural tendency to pick the first response it sees. This gives the teams hard data, exact win rates and confidence margins, so we can safely optimize for cost and speed without guessing if quality took a hit.
  6. Golden regression fixtures in CI. Move the testing from manual playground spot checks into your standard CI pipeline. Build a curated golden dataset of real world user queries and past edge cases, and run them against your agent whenever code changes. Using tools like EvalTask, you can set hard guardrails. If an engineer updates a system prompt and the win rate drops or a tool call deviates from the required sequence, the PR check turns red. Adopting this eval-driven development discipline turns AI updates from a guessing game into a predictable engineering workflow. This is the exact approach that allowed the Firebase team to leap from a 31.7% to a 78.0% pass rate on complex, multi-step tasks simply by building rigorous evaluation and scaffolding around the model.

Build deterministic schema gates, score groundedness mathematically, evaluate multi-turn trajectories, and gate your deployments with automated AutoSxS.

How does your team currently test agent updates before deploying to production? Are you running automated CI evals? Let's discuss it below! 👇

928254338