# Tool-Assisted Agent on SQL Inspection and Refinement in Real-World Scenarios

Source: [Tool-Assisted Agent on SQL Inspection and Refinement in Real-World Scenarios](<https://www.sota2.com/research/paper/68fa74a21e209131cea62d02>)

Collection index: [llms.txt](<https://www.sota2.com/research/llms.txt>)

Data updated: 2025-10-26T03:14:35.342Z

Authors: Zhongyuan Wang, Richong Zhang, Zhijie Nie, Jaein Kim

Published: 2024-08-30T03:38:37.000Z

## Abstract

Recent Text-to-SQL methods leverage large language models (LLMs) by incorporating feedback from the database management system. While these methods effectively address execution errors in SQL queries, they struggle with database mismatches -- errors that do not trigger execution exceptions. Database mismatches include issues such as condition mismatches and stricter constraint mismatches, both of which are more prevalent in real-world scenarios. To address these challenges, we propose a tool-assisted agent framework for SQL inspection and refinement, equipping the LLM-based agent with two specialized tools: a retriever and a detector, designed to diagnose and correct SQL queries with database mismatches. These tools enhance the capability of LLMs to handle real-world queries more effectively. We also introduce Spider-Mismatch, a new dataset specifically constructed to reflect the condition mismatch problems encountered in real-world scenarios. Experimental results demonstrate that our method achieves the highest performance on the averaged results of the Spider and Spider-Realistic datasets in few-shot settings, and it significantly outperforms baseline methods on the more realistic dataset, Spider-Mismatch.

## Recorded benchmark results

A research result applies to its stated dataset, split, metric and evaluation configuration. Compare like-for-like settings, preserve the metric's unit and direction, and distinguish paper-reported results from independent reproduction. The best result recorded here is not a claim of exhaustive, current global coverage.

- [Text-to-SQL on Spider (test)](<https://www.sota2.com/research/sota/text-to-sql-on-spider-test.md>): Text-to-SQL; Spider (test); Execution Accuracy: 85.6.

## Original sources and implementation

[Original paper](<https://arxiv.org/abs/2408.16991>)

[PDF](<https://arxiv.org/pdf/2408.16991.pdf>)
