ToolSQL: A Tool-Assisted Agent for SQL Verification and Refinement
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 verification 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 questions more effectively. We also introduce SpiderMismatch, a new dataset specifically constructed to reflect the condition mismatch problems encountered in real-world scenarios. Empirical studies demonstrate the effectiveness of our proposed model on Spider and Spider-Realistic datasets in few-shot settings and confirm that our model outperforms baseline methods on SpiderMismatch.
Authors
- Richong Zhang (ORCID: https://orcid.org/0000-0002-1207-0300)
- Zhijie Nie (ORCID: https://orcid.org/0009-0004-3933-0522)
- Jaein Kim (ORCID: https://orcid.org/0000-0002-7965-9523)
- Z. L. Wang (ORCID: https://orcid.org/0009-0002-1524-043X)
Institutions
- Beihang University (CN)
Publication Details
- Published
- 2025-08-03
- DOI
- https://doi.org/10.1145/3711896.3737159
- Citations
- 2
- Primary Topic
- Scientific Computing and Data Management
- Type
- article
- Field-Weighted Citation Impact
- 8.34
Funders
- National Natural Science Foundation of China
- Fundamental Research Funds for the Central Universities