Test-driven agent development (TDAD) starts by deciding what a good agent run looks like, then building toward it. Like test-driven development, it puts expectations before implementation. For agents, those expectations may be benchmarks or rubrics rather than ordinary unit tests. section 7.2
Work in a small loop:
- Set goals and input benchmarks. Record expected responses and known-bad responses. section 7.2
- Run the smallest agent against them. Expect early failures; add only the instructions or tools needed to address them. section 7.2.2 section 7.6
- Retest and refactor. Run passing benchmarks repeatedly: one successful LLM response does not establish consistent behavior. section 7.2.2 section 7.6
Start with a knowledge question
A simple RAG agent is asked, “Nebula Forge engine spins what?” Its benchmark expects “antimatter” and marks “fusion” as wrong. The agent searches a small knowledge base and answers from what it finds; an evaluator checks the answer. The first version has only a role instruction, so failures show what capability to add next. section 7.2.1 section 7.2.2
Figure 7.3 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 incorrect answers from the benchmark test. The accuracy of the RAG agent can be determined by the percentage of benchmark questions it answers correctly.
The diagram traces one benchmark question through knowledge-base search, the agent’s answer, and evaluation against expected and incorrect answers. section 7.2.1
Test the run, not just its final wording. Tool choice, grounding, steps, latency, cost, and failure behavior can matter even when an answer looks correct. Simple string matching is a starting point; evaluation agents can assess complex answers against criteria and return feedback. If benchmarks conflict, choose a partial-pass target, split responsibilities, or rethink the instructions rather than endlessly adding prompt text. section 7.2 section 7.6
