Overview

7 Building robust agents with evaluation and feedback

Building reliable agentic systems depends on treating evaluation and feedback as core design elements rather than afterthoughts. The chapter explains that robust agents are shaped through multiple kinds of checks, including red teaming, benchmarks, human review, automated evaluators, grounding, and critic-style agents. It also emphasizes that feedback can come from users, other agents, or internal self-assessment, and that these mechanisms should be considered early and applied throughout development, not just at deployment.

A major theme is test-driven agent development, which adapts test-first software practices to agents by defining benchmarks before refining prompts and tools. The process starts with expected and incorrect outputs, then runs repeated tests because LLM behavior is variable, and then makes minimal changes to improve results while preserving simplicity and performance. The chapter shows how this works for a retrieval-augmented knowledge agent, first with deterministic string matching, then with clearer tool design and stronger instructions, and later with a separate evaluation agent that can judge more natural responses using typed pass/fail output and feedback.

The chapter then expands into grounding, critic, and rubric-based evaluation patterns for more complex outputs. Grounding agents verify that answers stay tied to source context and can act as guardrails that block or reject ungrounded responses, while critic agents assess generated content against rubric criteria and drive regeneration until standards are met. Finally, the chapter introduces Phoenix as an observability and evaluation platform for tracing agent behavior, attaching metadata and sessions, running experiments, and adding annotations, reinforcing the broader message that production agents should always be monitored, evaluated, and improved through feedback loops.

highlights the external agent evaluation and feedback systems for a single user-facing agent. In the figure a generative agent may face evaluation from a critic for general output feedback or a grounding agent for context specific feedback and evalution.
highlights the human process of developing agents using TDAD. Where we first think of goals and benchmarks, then test, develop the prompt, refactor, and then repeat the process.
Architecture of a simple RAG Knowledge Agent. The goal of the agent is to answer questions from a benchmark by searching its knowledge base and returning answers. A simple evaluator LLM evaluates the answer based on the expected and wrong answers from the benchmark test. The accurary of the RAG agent can be determined by the percentage of correct answers answered from the benchmark.
Three forms of agents for evaluating agent output: grunding, critic, and evaluation. The grounding is specific to evaluating RAG agent output. The critic agent is designed to critique generated content, and the evaluation agent is used for more complex output.
RAG knowledge agent coupled with a grounding agent. Both agents are provided with the same context. The RAG agent generates an answer from the context, and the grounding agent verifies that the answer is grounded by reviewing the same context.
Arize Phoenix deployment patterns and use case methods of tracing, tracking and evaluating agents.
Arize Phoenix projects dashboard showing an agent workflow, agent and LLM activity.
Viewing the metadata column and filtering traces by an attribute.
The process to add spans to a dataset for later experimentation and evaluation.
Viewing datasets and then clicking Run Experiment to view the generated code you can copy to a Python file to generate an experiment or evaluation.
demonstrates how to create a new Annotation in Phoenix.
demonstrates how to apply an annotation to an LLM response within an agent workflow, agent, and LLM response spans.

Summary

  • Robust agents require evaluation and feedback baked in from the start—tie the Learn step of Sense-Plan-Act-Learn to external evaluators, a feedback store, and (optionally) a monitoring/alerting feedback agent.
  • Use a mix of methods: red-team testing for safety breaks, benchmark testing for goal attainment, human feedback (thumbs/comments) with verification to reduce bias, and automated evaluators (grounding/critic/evaluation agents) where appropriate.
  • Test-Driven Agent Development (TDAD) flips the process: define benchmarks (incl. wrong examples), expect initial failures, run each test multiple times for consistency, then make the minimum prompt/tool/model changes needed to pass—retest and refactor iteratively.
  • When benchmarks conflict, decide explicitly: accept partial pass targets, split into specialized agents (plus triage), or refactor the agent’s instructions from first principles.
  • Prefer tool guidance in the tool’s name/docstring over prompt clutter—rename tools and write clear docstrings; keep prompts lean and role-focused.
  • Add evaluation agents to score complex, natural-language outputs with typed results (e.g., pass/fail + feedback), avoiding brittle string matching and enabling programmatic gating.
  • Grounding agents are essential for RAG—verify answers are supported by provided context/citations; on failure, regenerate, block with a static response, or pass grounded feedback forward.
  • Guardrails operationalize grounding—wrap agents with output guardrails that trip on ungrounded answers and surface feedback/flags for policy (retry, block, or annotate).
  • Rubrics turn subjective quality into criteria and scales—use them with critic agents for high-variance generation (images, reports, graphs); loop generation ↔ critique until a passing score or attempt limit.
  • Because LLMs are stochastic, benchmark for stability—not just accuracy—by rerunning tests and watching variance, latency, and token use.
  • Observability is non-negotiable: OpenAI Traces show every tool call and LLM turn; Arize Phoenix (OpenTelemetry) adds projects, sessions, metrics, costs, experiments, and evaluators.
  • Instrument Phoenix cleanly—set the collector endpoint, replace default processors, register a tracer, and wrap runs with named traces; attach sessions and metadata for filtering and cohort analysis.
  • Build datasets from spans, run experiments/evaluators, and use annotations to capture structured human feedback—feed these signals back into prompts, tools, and policies.
  • Production rule: never promote agents without active evaluation/feedback loops—benchmarks, grounding/guardrails, critics with rubrics, tracing, and monitored KPIs (latency, cost, quality) working together.

FAQ

What is the main purpose of evaluation and feedback in agent systems?It is to make agentic systems more robust, reliable, safe, and debuggable. Evaluation and feedback help detect failures, reduce hallucinations, and improve agent behavior before and during production use.
What kinds of evaluation methods are commonly used for agents?Common methods include red team testing, benchmark testing, human feedback, grounding agents, and evaluation or critic agents. These can be used together to assess correctness, safety, consistency, and usefulness.
What is the difference between internal and external evaluation loops?Internal evaluation happens inside the agent’s Sense-Plan-Act-Learn loop, especially during the Learn step. External evaluation comes from tests, humans, critic agents, grounding agents, or stored feedback systems that review the agent’s output from the outside.
Why does the chapter recommend test-driven agent development (TDAD)?TDAD applies test-first thinking to agents. You define goals and benchmarks first, then build the smallest prompt and tool set needed to pass them, retest, and refactor until the agent performs reliably.
What is the basic TDAD workflow for building an agent?The workflow is: think about goals and benchmarks, test the agent, update prompts or tools minimally, then rerun the benchmarks and refactor as needed. The goal is to keep the system lean while improving correctness and consistency.
Why should agent benchmark tests often be run multiple times?Because LLM-based agents are variable and may not behave consistently on every run. The chapter recommends rerunning passing tests, often three times or more, to confirm the result is stable.
When should you use a grounding agent?You should use a grounding agent when the response must be supported by retrieved context, especially in RAG systems. Its job is to verify that the answer is actually grounded in the source material and not invented.
What is the role of an evaluation or critic agent?An evaluation or critic agent provides an additional layer of judgment about an agent’s output, reasoning, or generated content. It is especially useful for complex or fuzzy outputs, such as natural language responses or image generation results evaluated against a rubric.
Why are rubrics important for evaluating agent output?Rubrics provide structured criteria and scoring standards, which make evaluation more consistent and informative than a simple pass/fail. They help explain what was good or bad about the output and guide iterative improvement.
What does Phoenix add to evaluation and feedback workflows?Phoenix provides tracing, metrics, session tracking, metadata filtering, experiments, and annotation support. It helps teams inspect agent behavior, diagnose bugs, evaluate runs, and connect real traces back into development and feedback loops.

pro $24.99 per month

  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose one free eBook per month to keep
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime

lite $19.99 per month

  • access to all Manning books, including MEAPs!

team

5, 10 or 20 seats+ for your team - learn more


choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • AI Agents in Action, Second Edition ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • AI Agents in Action, Second Edition ebook for free
choose your plan

team

monthly
annual
$49.99
$499.99
only $41.67 per month
  • five seats for your team
  • access to all Manning books, MEAPs, liveVideos, liveProjects, and audiobooks!
  • choose another free product every time you renew
  • choose twelve free products per year
  • exclusive 50% discount on all purchases
  • renews monthly, pause or cancel renewal anytime
  • renews annually, pause or cancel renewal anytime
  • AI Agents in Action, Second Edition ebook for free