Multi-Agent Architecture with RAG and Dynamic Context Windows for Text-to-SQL Optimization

Willgnner Ferreira Santos, Paulo Victor dos Santos, Marcella Scoczynski Ribeiro Martins, Larissa Freire Lekakis, Frederico Lemes Rosa, Bruno Matheus Costa, Miguel Alves Pereira Filho, Isabella Alves Montalvão


Abstract
Natural language interfaces supported by LLMs have been used to translate user questions into SQL queries, but sending the complete database schema in each prompt entails high token consumption and computational cost, especially in corporate databases with hundreds of tables. This work presents a multi-agent Text-to-SQL architecture with dynamic context windows, which combines RAG and metadata dictionaries to select, at query time, only the relevant tables and columns. In a case study with Firebird enterprise databases, the approach reduces by an average of 84.4% the number of processed tokens, resulting in more efficient queries without loss of quality, thereby contributing to the democratization of access to corporate databases.
Anthology ID:
2026.propor-1.100
Volume:
Proceedings of the 17th International Conference on Computational Processing of Portuguese (PROPOR 2026) - Vol. 1
Month:
April
Year:
2026
Address:
Salvador, Brazil
Editors:
Marlo Souza, Iria de-Dios-Flores, Diana Santos, Larissa Freitas, Jackson Wilke da Cruz Souza, Eugénio Ribeiro
Venue:
PROPOR
SIG:
Publisher:
Association for Computational Linguistics
Note:
Pages:
988–993
Language:
URL:
https://preview.aclanthology.org/ingest-dnd/2026.propor-1.100/
DOI:
Bibkey:
Cite (ACL):
Willgnner Ferreira Santos, Paulo Victor dos Santos, Marcella Scoczynski Ribeiro Martins, Larissa Freire Lekakis, Frederico Lemes Rosa, Bruno Matheus Costa, Miguel Alves Pereira Filho, and Isabella Alves Montalvão. 2026. Multi-Agent Architecture with RAG and Dynamic Context Windows for Text-to-SQL Optimization. In Proceedings of the 17th International Conference on Computational Processing of Portuguese (PROPOR 2026) - Vol. 1, pages 988–993, Salvador, Brazil. Association for Computational Linguistics.
Cite (Informal):
Multi-Agent Architecture with RAG and Dynamic Context Windows for Text-to-SQL Optimization (Santos et al., PROPOR 2026)
Copy Citation:
PDF:
https://preview.aclanthology.org/ingest-dnd/2026.propor-1.100.pdf