Google Cloud has published a developer guide to testing natural-language-to-SQL (NL2SQL) data agents built with its Agent Development Kit (ADK), including a custom Python metric that judges whether an agent’s query results are correct rather than whether its SQL text matches a reference.
The guide, written by Google Cloud AI engineer Rupjit Chakraborty, argues that built-in ADK criteria often misjudge SQL agents. The tool_trajectory_avg_score criterion requires an exact match on tool arguments, including the raw SQL string. The response_match_score relies on ROUGE-1 word overlap. Google Cloud said both penalise valid variations in LLM-generated queries.

A three-layer evaluation setup
Google Cloud recommends combining three checks:
- Trajectory: the built-in tool trajectory criterion, set to IN_ORDER matching with argument checking switched off, so the agent is verified as calling the right database tools without being marked down for different SQL syntax.
- Semantic equivalence: a custom ADK metric that normalises the reference result set and the agent’s result set, then compares them. Google Cloud said this costs no LLM tokens.
- Rubric-based judging: the rubric_based_final_response_quality_v1 criterion, which uses an LLM judge to confirm extra columns are useful and the written summary matches the returned data.
Five ways standard comparisons fail
The company identified five scenarios where exact string matching or cell-by-cell table comparison wrongly flags a correct answer:
- Aliases: the agent renames a cryptic column such as prod_sale_rev_fy25 to “Revenue FY2025” for readability.
- Column order: the agent selects the same columns in a different sequence.
- Row order: without an ORDER BY clause, SQL does not guarantee row order, and distributed warehouses such as BigQuery can return rows differently between runs.
- Data types and precision: values such as 99.50 and 99.5 are mathematically equal but differ as strings.
- Extra columns: the agent adds context, such as a project lead and due date, to a query that only asked for project names.
Google Cloud noted that where a user explicitly asks for a ranked list, such as “top 5 customers”, the evaluator should enforce row order for that test case.

How the custom metric works
The metric is registered through the custom_metrics field of an ADK evaluation config. It runs a six-step pipeline. It first normalises values by rounding numbers to a fixed precision, converting dates to ISO-8601 strings and trimming text whitespace. It then represents each column as a frequency counter of its values, which lets gold columns be matched to predicted columns regardless of alias.
An allow_superset parameter lets the evaluator ignore extra predicted columns. The pipeline then finds a one-to-one mapping between reference and predicted columns, and compares rows as unordered tuple counts so row order does not matter. It returns a match verdict along with the column mapping for debugging, which the ADK wrapper turns into a pass or fail result.
Google Cloud cautioned that columns holding leading-zero codes, such as zip codes, or 64-bit integer IDs stored as strings should stay as strings so they are not converted to floats. It also advised pairing the evaluator with realistic, multi-row test fixtures so a flawed query cannot pass by coincidence.
Running it
In the example configuration, the trajectory criterion has a threshold of 1.0, the semantic metric must score 1.0, and the rubric check uses gemini-2.5-flash as the judge with a threshold of 0.8. Test cases are stored in an evalset file holding the user prompt, the expected SQL tool call, the gold-standard rows and a reference answer. The full suite runs from the terminal with the adk eval command.
Google Cloud pointed developers to the ADK custom metrics documentation and evaluation samples on GitHub.
Source: Google Cloud Blog

