Test-Driven AI Agent Definition (TDAD): Compiling Tool-Using Agents from Behavioral Specifications
Organizations: Fiverr Labs
Abstract
We present Test-Driven AI Agent Definition (TDAD), a methodology that treats agent prompts as compiled artifacts: engineers provide behavioral specifications, a coding agent converts them into executable tests, and a second coding agent iteratively refines the prompt until tests pass. Deploying tool-using LLM agents in production requires measurable behavioral compliance that current development practices cannot provide. Small prompt changes cause silent regressions, tool misuse goes undetected, and policy violations emerge only after deployment. To mitigate specification gaming, TDAD introduces three mechanisms: (1) visible/hidden test splits that withhold evaluation tests during compilation, (2) semantic mutation testing via a post-compilation agent that generates plausible faulty prompt variants, with the harness measuring whether the test suite detects them, and (3) spec evolution scenarios that quantify regression safety when requirements change. We evaluate TDAD on SpecSuite-Core, a benchmark of four deeply-specified agents spanning policy compliance, grounded analytics, runbook adherence, and deterministic enforcement. Across 24 independent trials, TDAD achieves 92% v1 compilation success with 97% mean hidden pass rate; evolved specifications compile at 58%, with most failed runs passing all visible tests except 1-2, and show 86-100% mutation scores, 78% v2 hidden pass rate, and 97% regression safety scores. The implementation is available as an open benchmark at https://github.com/f-labs-io/tdad-paper-code.
Figures & tables
| Metric | Definition | Purpose |
| VPR | Visible Pass Rate | Compilation |
| HPR | Hidden Pass Rate | Generalization |
| MS | Mutation Score | Test quality |
| SURS | Spec Update Regr. | Regression safety |
| RPR † | Reliability Pass Rate | Stochasticity |
| † Three trials provide variance estimates; formal RPR ( =10–50 | ||
| Spec | Key Challenges |
|---|---|
| SupportOps | Auth before action, PII refusal, plan eligibility, escalation triggers |
| DataInsights | SQL grounding, numeric precision, ambiguity detection, cost-aware queries |
| IncidentRunbook | Evidence-first ordering, severity routing, runbook compliance |
| ExpenseGuard | Spending caps, FX conversion, receipt requirements, manager approval |
| Spec | Nodes | V1 Vis. | V1 Hid. | V2 Vis. | V2 Hid. | Mut. |
|---|---|---|---|---|---|---|
| SupportOps | 12 | 47 | 45 | 53 | 43 | 7 |
| DataInsights | 10 | 34 | 42 | 53 | 43 | 6 |
| IncidentRunbook | 14 | 39 | 42 | 42 | 45 | 7 |
| ExpenseGuard | 11 | 47 | 45 | 46 | 42 | 7 |
| Median test counts across 3 trials; varies 10–30% due to stochastic generation. | ||||||
| Compile | HPR (%) | MS (%) | SURS | ||||
| Spec | V1 | V2 | V1 | V2 | V1 | V2 | (%) |
| SupportOps | 3/3 | 2/3 | 97.6 2.3 | 62.5 16.1 | 100 | 100 | 94.2 5.1 |
| DataInsights | 3/3 | 2/3 | 96.6 4.1 | 88.3 3.7 | 94.4 9.6 | 100 | 98.7 1.9 |
| IncidentRunbook | 2/3 | 2/3 | 95.2 0.3 | 80.3 13.1 | 85.7 | 100 | 97.3 3.7 |
| ExpenseGuard | 3/3 | 1/3 | 99.2 1.3 | 81.8 † | 100 | 100 † | 100 † |
| Aggregate | 11/12 | 7/12 | 97.3 2.6 | 77.7 13.9 | 95.9 7.1 | 100 | 97.2 3.5 |
| Cost ($) | Iterations | |||
| Spec | V1 | V2 | V1 | V2 |
| SupportOps | 2.19 1.06 | 2.02 0.25 | 3.3 0.6 | 2.5 0.7 |
| DataInsights | 2.59 1.38 | 2.12 0.93 | 3.3 0.6 | 2.5 0.7 |
| IncidentRunbook | 1.55 0.12 | 4.23 3.21 | 2.5 0.7 | 3.5 2.1 |
| ExpenseGuard | 2.68 0.83 | 2.91 † | 3.3 1.2 | 3.0 † |
| Average | 2.32 0.96 | 2.81 1.71 | 3.1 0.8 | 2.9 1.1 |
Appendix figures & tables1 asset
Supplementary material from the paper’s appendix.
Appendix
| Spec | Mutation | V1 | V2 |
|---|---|---|---|
| SupportOps | SKIP_AUTH_GATE | K | K |
| LEAK_PII_DIRECT_REQ | K | K | |
| SKIP_CONFIRM_CANCEL | K | K | |
| ALWAYS_CREATE_TICKET | K | K | |
| DataInsights | ANSWER_WITHOUT_SQL | K | K |
| HALLUCINATE_NUMBERS | S ∗ | K |
Tool-Using Agents
Tool-using agents plan and act through external tools, APIs, software interfaces, and environments to complete tasks beyond language generation.
See all 277 papers