Automated Data Agent Evaluation: A Three-Layer Framework and Implementation Guide
Evaluating data agents requires more than matching outputs against expected text. This article presents a three-layer framework covering atomic capabilities, end-to-end task trajectories, and business value. It explains how to combine execution-result comparison, deterministic checks, calibrated model judges, and production feedback to build an automated evaluation pipeline with actionable failure attribution and release gates.
1. Why Data Agents Are Harder to Evaluate Than Traditional Software
Traditional software testing often assumes deterministic inputs and outputs, making equality assertions a practical way to determine whether a test passes. Data agents—including data warehouse development assistants, conversational business intelligence agents, and deep analysis agents—challenge that approach:
- The output space is open-ended. A single business question may have several semantically equivalent SQL queries, chart options, or ways to express a conclusion. Exact text matching is rarely meaningful.
- There is no single correct path. An agent may scan detailed records or use an aggregate table, execute one query or break the task into several steps. Different paths can produce the same valid result.
- Correctness depends on business semantics. A metric such as “active users last month” may be defined in a metrics platform. Without that definition, a model can generate a syntactically valid but incorrect answer.
- Errors have asymmetric consequences. An obviously fabricated statement may be easy to spot. An incorrect number, unit, or time window can quietly enter a decision-making process and cause much greater damage.
Data agent evaluation therefore needs more than a pass/fail test runner. It requires a layered system that measures quality, automates scoring, and turns evaluation results into regression gates.
2. Define What to Evaluate: Four Dimensions and Failure Attribution
Before building the framework, break evaluation goals into measurable dimensions. Otherwise, scores will not remain comparable across iterations.
Quality
- Factuality: Does the answer follow the provided context and evidence, without hallucination?
- Usefulness: Does it actually advance the task, rather than merely provide truthful but unhelpful information?
- Harmfulness: Does it involve sensitive content or encourage inappropriate behavior?
Performance
Measure time to first token, end-to-end completion time, and throughput separately. First-token latency strongly affects perceived responsiveness, while end-to-end duration matters more for task-oriented agents.Cost
Track token consumption, tool calls, retrieval rounds, and retries. Agent costs can grow approximately linearly—or even faster—with the number of steps. Cost optimization without measurement is guesswork.Security and permissions
Check whether the agent accesses unauthorized data, touches sensitive fields, performs write operations, or causes irreversible side effects.
The attribution principle: Every metric must support drill-down by problem category, task step, and underlying capability. A report containing only an overall score has little engineering value because it cannot guide improvements.
3. The Three-Layer Evaluation Framework
| Layer | Evaluation target | Core questions | Main methods | Outputs |
|---|---|---|---|---|
| L1: Atomic capabilities | Individual sub-capabilities | Was this step correct? | Rule checks, execution-result comparison, model judging | Capability radar charts, weakness identification |
| L2: Task trajectories | End-to-end tasks and tool-call traces | Was the task completed? Was the process reasonable? | Reference trajectories, key-step assertions, structured judging | Task success rate, failure attribution distribution |
| L3: Business value | Real production traffic and business outcomes | Did users actually benefit? | Controlled rollouts, human spot checks, feedback loops | Adoption rate, business metrics, regression gates |
These layers complement rather than replace one another. Together, they form a funnel from fast to slow, inexpensive to costly, and offline to online: L1 supports regression checks on a seconds-scale, L2 provides attribution on a minutes-scale, and L3 validates value over days.
L1: Break the Agent into Independently Scorable Capabilities
A data agent can be decomposed into capabilities such as:
- Schema and table retrieval
- Field interpretation and metric-definition understanding
- Natural-language-to-query conversion
- Chart and conclusion generation from query results
- Clarification of ambiguous requests
- Exception and empty-result handling
The most important design choice at this layer is to use execution-result equivalence rather than query-text equivalence as the primary criterion.
Execute both the reference solution and the candidate solution against an isolated sandbox dataset, then compare their result sets:
- For unordered results, sort by primary key before comparison.
- Apply relative tolerances to numeric columns.
- Allow different column orders while requiring the same set of columns.
- Accept equivalent aggregate formulations, such as
SUMand an equivalent combination usingCASE WHEN.
# Example atomic-capability test caseid: L1-metric-0031capability: metric_semanticsquestion: Count new customers in the East China region last quarterdataset: sandbox_db_v7reference_result: { region: East China, quarter: 2025Q3, new_users: 184320 }judge:primary: result_set_equivalence # Primary criterion: execution-result equivalencetolerance: { numeric_rel: 0.001 }secondary: [syntax_valid, cost_budget]cost_budget: { max_steps: 3, max_tokens: 12000 }
Do not delegate checks to a model when deterministic rules can handle them. Syntax validity, prohibited write operations, unauthorized table scans, and budget violations should all be checked with rules. This is cheaper and more stable.
L2: Evaluate Both the Outcome and the Process
Task-level evaluation focuses on whether the task was completed, whether the process was reasonable, and whether the agent could recover from errors.
- Task completion: Prefer verifiable final-state assertions, such as equivalent result sets, key metrics within expected ranges, and the presence of required fields. Use structured model judging only when necessary.
- Trajectory quality: Do not require an exact match with a reference trajectory. Instead, extract assertions for key steps: Did the agent retrieve tables first? Did it ask for clarification when a metric definition was unclear? Did it explain an empty result rather than fabricate an answer?
- Error recovery: Deliberately inject ambiguous conditions, missing fields, or incorrect metric definitions, then observe whether the agent converges through multiple rounds of correction.
- Stability: Sample the same test case repeatedly and report
pass@kand result variance. High variance makes production behavior unpredictable, even when average performance meets the target.
Failure attribution requires a fixed taxonomy. Useful categories include intent misunderstanding, retrieval failure, metric-definition errors, query-generation errors, execution or environment errors, and presentation errors.
The distribution of failures is often more useful for iteration than the overall score.
L3: Calibrate Offline Evaluation Against Production Outcomes
Offline scores matter only when they correlate with production performance.
Practical methods include:
- Comparing versions through small-traffic controlled rollouts
- Conducting human spot checks stratified by scenario
- Collecting explicit feedback, such as adoption, copying, follow-up questions, and corrections
- Collecting implicit feedback, such as retries, abandonment, and escalation to a human
- Comparing business metrics, including the share of self-service data queries, demand for manual data retrieval, and analysis turnaround time
Regularly feed real production questions back into the offline test suite to maintain a closed feedback loop.
4. Engineering Techniques for Automated Scoring
1. Build Test Cases and Prevent Contamination
Cluster real questions from production logs and stratify them by difficulty: single-table queries, multi-table joins, metric-definition dependencies, ambiguity, and temporal reasoning.
Deduplicate semantically similar cases, check for answer leakage, and rotate the suite regularly to reduce overfitting to a fixed benchmark.
2. Use Rules First, with Model Judging as a Fallback
A weighted scoring approach can combine different signals while retaining raw component scores for drill-down:
def score(case, pred):s = {}s["result"] = 1.0 if result_equiv(pred, case.reference_result, case.tolerance) else 0.0s["rule"] = rule_checks(pred) # Syntax, permissions, and cost; 0–1s["judge"] = rubric_judge(pred, case.rubric) # Usefulness and presentation; 0–1total = 0.6 * s["result"] + 0.2 * s["rule"] + 0.2 * s["judge"]return total, s
3. Calibrate Model Judges
Before using a model judge, calibrate it against human-labeled examples.
Measure agreement with human reviewers and check for:
- Position bias: Reorder responses and judge them again.
- Length bias: Determine whether the judge favors longer answers.
- Self-preference: Check whether it favors outputs from the same model family or source.
If calibration does not meet the required standard, judge scores should remain advisory and must not determine release gates.
4. Control Evaluation Noise
Fix sampling parameters, run repeated samples, and report confidence intervals. Use statistical significance rather than assuming that a small score increase necessarily represents an improvement.
5. Build the Pipeline and Release Gates
Run the full L1 suite on every commit, scheduled stratified samples at L2, and version-specific controlled rollouts at L3.
A maintainable evaluation pipeline uses common cloud infrastructure components:
- Object storage for test cases and reports
- Message queues for task distribution
- Container platforms for sandbox execution
- Logging services for trace collection
- Monitoring and alerting for dashboards and anomaly notifications
Baidu AI Cloud can provide infrastructure support for these categories. The goal is to make the evaluation pipeline itself operationally manageable.
5. Common Pitfalls and a Three-Stage Implementation Roadmap
Common pitfalls include:
- Relying only on text similarity
- Allowing model judges to drift without recalibration
- Letting the test suite become outdated
- Evaluating only final outcomes, not the process
- Ignoring cost and latency
- Producing scores without failure attribution
A practical rollout can proceed in three stages.
Stage 1: Establish the Foundation
Build several hundred high-quality seed cases, implement L1 automation, and set up an execution sandbox. First make result correctness suitable for regression testing.
Stage 2: Add Trajectory Evaluation and Attribution
Build L2 trajectory evaluation and a failure attribution taxonomy. Complete judge calibration and introduce variance tracking and pass@k.
Stage 3: Connect Evaluation to Production
Integrate production feedback and controlled rollout experiments. Turn evaluation scores into release gates and close the loop between production issues, offline test cases, and version regression testing.
Evaluation is not merely the final check before release. It is foundational infrastructure for turning data agents into dependable products. The value of this three-layer framework is that each iteration’s impact becomes measurable, explainable, and accountable—making evaluation a source of faster iteration rather than just another cost.
