Welcome.AI
    Skip to content
    Article

    ADK Semantic Metrics Improve NL2SQL Agent Evaluation Reliability

    As NL2SQL agents move toward production, exact query matching and word-overlap scores can obscure whether they got the answer right. Learn how SQL-aware evaluation in ADK can better distinguish real errors from harmless variations.

    cloud.google.com•December 1, 2026•3 min read

    Key Facts

    • Exact-SQL matching can reject correct queries; ADK’s `ignore_args: true` avoids penalizing valid SQL variations.
    • SQL aliases, column order, and row order create false failures, making naive benchmarks unreliable for production decisions.
    • A deterministic semantic evaluator compares normalized results at zero LLM-token cost, improving evaluation efficiency.
    • Allowing extra columns rewards useful context, but requires rubric checks to ensure additions genuinely help users.
    • A three-layer ADK suite—tool trajectory, semantic results, and response quality—balances reliability with flexible agent behavior.

    Summary

    Google’s Agent Development Kit (ADK) can help teams build natural-language-to-SQL agents connected to warehouses such as BigQuery, but standard evaluation metrics may misjudge whether those agents return correct answers. A custom, SQL-aware evaluation approach can distinguish genuine errors from harmless differences in query wording, result formatting, or useful extra context—a practical requirement as data agents move toward production use.

    The problem is a mismatch between rigid benchmarks and SQL’s flexibility. ADK’s built-in tool_trajectory_avg_score can require an exact match on tool arguments, including the SQL string, while response_match_score measures word overlap using ROUGE-1. Both can penalize an agent that reaches the right result through a different query or presents the answer more clearly.

    The article recommends a three-layer evaluation system. First, use ADK’s trajectory metric to check that the agent calls the right tools in the right order, with match_type set to IN_ORDER and ignore_args set to true. This tests the workflow without treating every SQL variation as a failure.

    Second, add a deterministic custom metric that compares result sets semantically. Third, use ADK’s rubric_based_final_response_quality_v1 to assess whether extra context is useful and whether the agent’s natural-language explanation matches its data. The combination separates tool use, data correctness, and answer quality rather than relying on one score to cover all three.

    Five common SQL differences can distort conventional tests. An agent may alias an obscure database column with a readable name, return columns in a different order, or produce rows in a different sequence. It may also return numerically equivalent values with different types or precision, such as 99.5 instead of 99.50, or include relevant context columns beyond those in the reference result.

    A custom evaluator can address these cases by normalizing values, matching columns by their contents rather than their names, and comparing rows without assuming a fixed order. The proposed method converts numeric values to rounded floats, dates and timestamps to ISO-8601 strings, and trims whitespace. It uses frequency counts to identify equivalent columns, then checks one-to-one column mappings and compares projected rows as unordered tuples.

    The design also allows teams to decide whether extra columns should pass. With allow_superset enabled, the evaluator requires the predicted result to contain at least the gold-standard columns, then ignores additional columns during the data-equivalence check. A separate rubric can judge whether those additions help the user. The article cautions that schemas with leading-zero codes or large integer IDs stored as strings need special handling to avoid unsafe numeric conversion.

    For business leaders, the approach points to a broader shift in AI quality assurance: evaluating data agents requires tests that reflect the meaning of their outputs, not just their exact form. Deterministic comparison also avoids LLM token costs for the core result-set check, while realistic, multi-row fixtures help reduce the risk that a flawed query passes by coincidence.

    As organizations expand agents from query generation into autonomous data work, evaluation design will become part of the control system, not a final benchmark. Teams that define which differences are acceptable—and which requests require strict ordering, exact columns, or specific formats—will be better positioned to scale agents without confusing flexibility with correctness.

    Entities Mentioned

    Products

    BigQuery

    Technologies

    Natural Language to SQL (NL2SQL)
    SQL
    Python
    ROUGE-1
    ISO-8601
    collections.Counter

    People

    Rupjit Chakraborty

    Organizations

    Google
    Agent Development Kit (ADK)
    GitHub

    Key Concepts

    Custom semantic SQL evaluation
    Three-layer evaluation combining tool trajectory, deterministic result equivalence, and rubric-based response quality
    False negatives from exact SQL string matching and naive table diffs
    Column aliasing, column permutations, and unordered rows
    Numeric type and precision normalization
    Allowing helpful extra context columns
    One-to-one column mapping and order-invariant row hashing
    Registering and running custom metrics in ADK

    Definitions

    NL2SQL data agent
    An autonomous agent that translates natural-language requests into SQL and can inspect schemas, validate queries, and return answers from live data.
    Exact String Match
    An evaluation method that compares raw SQL text or other strings exactly, rejecting semantically equivalent queries with different syntax.
    Naive Table Diff
    A result comparison that checks table cells by column header and row position, potentially failing when columns or rows are reordered or extra columns are present.
    Deterministic semantic equivalence
    A custom evaluation approach that normalizes gold and predicted result sets and checks whether their data is equivalent without using LLM tokens.
    Rubric-Based evaluation
    An LLM-as-a-Judge evaluation that uses a rubric to assess whether extra context is helpful and whether the natural-language summary matches the returned data.

    Use Cases

    • →Evaluate whether an NL2SQL agent returns equivalent results despite using different column aliases.
    • →Compare result sets when selected columns appear in a different order.
    • →Ignore row-order differences when a query does not require sorting, while enforcing order for ranked requests.
    • →Treat mathematically equivalent numeric values with different types or precision as matches.
    • →Accept relevant extra context columns in an agent's result.
    • →Run a three-layer evaluation suite for an ADK data agent from the command line.

    Frequently Asked Questions

    Why are ADK's built-in evaluation metrics insufficient for NL2SQL agents?

    Metrics such as tool_trajectory_avg_score can require exact tool arguments, including identical raw SQL, while response_match_score measures word overlap with ROUGE-1. These checks can penalize valid SQL variations and useful answers, so SQL-specific semantic evaluation is needed.

    What are the three evaluation layers recommended for an ADK NL2SQL agent?

    Use tool trajectory evaluation to verify the right database tools are called in sequence, with argument matching disabled where appropriate. Add a deterministic custom metric for result-set equivalence and a rubric-based LLM judge to assess extra context and the natural-language summary.

    How does the custom metric handle aliases, column order, and row order?

    It aligns columns by normalized value counts rather than column names, then checks valid one-to-one column mappings. It compares projected rows as unordered tuple counters, so column aliases, column permutations, and arbitrary row ordering do not cause false failures.

    How does the evaluator handle numeric precision and data types?

    It normalizes integers, floats, Decimal values, and numeric strings to rounded floats, and converts dates and timestamps to ISO-8601 strings. Columns containing leading-zero codes or large integer IDs stored as strings should remain strings to avoid changing their values.

    How do you register and run the custom SQL metric in ADK?

    Implement the evaluator and wrapper in a Python module, then register semantic_sql_result_match in eval_config.json alongside the trajectory and rubric-based criteria. Define test cases and gold tool responses in an evaluation set, then run the suite with the ADK eval CLI command.

    Where AI Leaders Stay Informed

    The latest AI intelligence, case studies, and research — delivered to your inbox every week.

    Free to read. Unsubscribe anytime.