Google Cloud Shows How to Build a Custom ADK Metric for NL2SQL Agents
Key point
Google Cloud shows how an ADK metric can compare NL2SQL query results semantically, accepting equivalent outputs without exact SQL-string matches.
Details
- Google Cloud describes a Python custom metric for ADK-based NL2SQL agents that evaluates query results instead of requiring generated SQL text to match exactly.
- The guide says ADK’s default tool-trajectory metric can require exact tool arguments, while its response-matching metric measures word overlap; it recommends combining tool-call sequence checks, deterministic result comparison, and a rubric for the final response.
- The custom evaluator normalizes values, matches gold and predicted columns by their value distributions, then compares row frequencies to handle column aliases, column order, and unordered results; it can also allow extra predicted columns. Explicitly requested sorting still requires checking row order, and identifiers such as codes with leading zeros should remain strings.
- An ADK wrapper extracts rows from
execute_sql_queryresponses and turns matches into pass/fail results; the sample configuration sets thresholds for the tool-trajectory and custom metrics and uses a rubric to assess response accuracy and extra-column relevance.
This summary was generated automatically by AI. Check the original for the author's claims and context. Copyright belongs to the original author.
Our guide explains how the AI works. Report summary errors, attribution issues, or removal requests via Contact.