Composable Prompt Modularization in Text-to-SQL Agents: A Practical Approach
Resumo
Text-to-SQL agents often rely on monolithic prompts that combine instructions and examples into a single block, making them difficult to maintain, less interpretable, and more prone to structural errors. To address these limitations, this work proposes a Composable Prompt Modularization approach that decomposes prompts into semantic components for question classification and Text-to-SQL generation, leveraging large language models within a modular prompting pipeline. We conduct a case study involving an intelligent assistant for the public sector. The results show that the modular architecture is a competitive alternative to monolithic prompting, achieving up to 95.39% execution accuracy and strong structural alignment, with average component-matching scores of 0.954. The findings reveal a trade-off between prompting strategies: while the monolithic prompt is slightly more efficient when fewer examples are available (Top-k = 3), the modular approach makes better use of additional context, improving execution accuracy by 0.66 percentage points at Top-k = 5 (94.74% vs. 94.08%). In the context of public transparency, where the availability of information enables citizens to interpret, validate, and audit data, the modular approach appears particularly well-suited.
Palavras-chave:
Machine Learning, AI, data management and data systems, Query languages and processing, Text mining and natural language processing
Referências
Chen, Z., Wang, C., Sun, W., Yang, G., Liu, X., Zhang, J. M., and Liu, Y. (2025). Promptware engineering: Software engineering for llm prompt development. arXiv preprint arXiv:2503.02400.
Gao, D., Wang, H., Li, Y., Sun, X., Qian, Y., Ding, B., and Zhou, J. (2024). Text-to-sql empowered by large language models: A benchmark evaluation. Proceedings of the Very Large Data Bases Endowment (PVLDB), 17(5):1132–1145.
Lan, W., Wang, Z., Chauhan, A., Zhu, H., Li, A., Guo, J., Zhang, S., Hang, C.-W., Lilien, J., Hu, Y., Pan, L., Dong, M., Wang, J., Jiang, J., Ash, S., Castelli, V., Ng, P., and Xiang, B. (2023). UNITE: A Unified Benchmark for Text-to-SQL Evaluation. [link]. arXiv:2305.16265.
Liang, J. T., Lin, M., Rao, N., and Myers, B. A. (2025). Prompts are programs too! understanding how developers build software containing prompts. Proceedings of the ACM on Software Engineering, 2(FSE):1591–1614.
Liu, M., Wang, X., Xu, J., Yi, W., and Wolfson, O. (2026). A systematic review of natural language interfaces for databases. Frontiers of Computer Science, 20.
Liu, Y., Xu, J., Zhang, L. L., Chen, Q., Feng, X., Chen, Y., Guo, Z., Yang, Y., and Cheng, P. (2025). Beyond prompt content: Enhancing llm performance via content-format integrated prompt optimization. arXiv preprint arXiv:2502.04295.
Luo, Y., Zhang, Z., Zhang, Y., Xie, Z., Wang, J., Jatowt, A., and Yang, Z. (2024). Data-scarce event argument extraction: A dynamic modular prompt tuning model based on slot transfer. In 2024 7th International Conference on Machine Learning and Natural Language Processing (MLNLP), pages 1–6. IEEE.
Mao, Y., He, J., and Chen, C. (2025). From prompts to templates: A systematic prompt template analysis for real-world llmapps. arXiv preprint arXiv:2504.02052.
Nahid, M. M. H., Rafiei, D., Zhang, W., and Zhang, Y. (2026). Rethinking schema linking: A context-aware bidirectional retrieval approach for text-to-SQL. In Findings of the Association for Computational Linguistics: EACL 2026, pages 4516–4546, Rabat, Morocco. Association for Computational Linguistics.
Petrola, L., Brayner, A., and Franco, W. (2025). Heuristic-guided text-to-sql translation with llms: Optimizing natural language interfaces for relational databases. In Simpósio Brasileiro de Banco de Dados (SBBD), pages 126–139. SBC.
Piao, S., Lee, J., and Park, S. (2026). LitE-SQL: A lightweight and efficient text-to-SQL framework with vector-based schema linking and execution-guided self-correction. In Findings of the Association for Computational Linguistics: EACL 2026, pages 3593–3608, Rabat, Morocco. Association for Computational Linguistics.
Pourreza, M. and Rafiei, D. (2023). DIN-SQL: Decomposed in-context learning of text-to-SQL with self-correction. In Advances in Neural Information Processing Systems, volume 36, pages 36339–36348. Curran Associates, Inc.
Santos, W. F., Santos, P. V. d., Martins, M. S. R., Lekakis, L. F., Rosa, F. L., Costa, B. M., Filho, M. A. P., and Montalvão, I. A. (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.
Schnabel, T. and Neville, J. (2024). Symbolic prompt program search: A structure-aware approach to efficient compile-time prompt optimization. arXiv preprint arXiv:2404.02319.
Shi, L., Tang, Z., Zhang, N., Zhang, X., and Yang, Z. (2025). A survey on employing large language models for text-to-SQL tasks. ACM Computing Surveys, 58(2):1–37.
Shinn, N., Cassano, F., Labash, B., Gopinath, A., Narasimhan, K., and Yao, S. (2023). Reflexion: Language agents with verbal reinforcement learning, 2023. URL [link], 1.
Tan, Z., Liu, X., Shu, Q., Li, X., Wan, C., Liu, D., Wan, Q., and Liao, G. (2024). Enhancing text-to-sql capabilities of large language models through tailored promptings. In Proceedings of the 2024 Joint International Conference on Computational Linguistics, Language Resources and Evaluation (LREC-COLING 2024), pages 6091–6109.
Wang, B., Ren, C., Yang, J., Liang, X., Bai, J., Chai, L., Yan, Z., Zhang, Q.-W., Yin, D., Sun, X., and Li, Z. (2025). MAC-SQL: A multi-agent collaborative framework for text-to-SQL. In Proceedings of the 31st International Conference on Computational Linguistics, pages 540–557, Abu Dhabi, UAE. Association for Computational Linguistics.
Wang, M., Liu, Y., Liang, X., Li, S., Huang, Y., Zhang, X., Shen, S., Guan, C., Wang, D., Feng, S., et al. (2024). Langgpt: Rethinking structured reusable prompt design framework for llms from the programming language. arXiv preprint arXiv:2402.16929.
Yavuz, S., Gur, I., Su, Y., and Yan, X. (2021). Text-to-sql in the wild: A naturally-occurring dataset based on stack exchange data. In Proceedings of the 3rd Workshop on Natural Language Processing for Programming (NLP4Prog), pages 77–87, Online. Association for Computational Linguistics.
Zhuo, J., Zhang, S., Fang, X., Duan, H., Lin, D., and Chen, K. (2024). Prosa: Assessing and understanding the prompt sensitivity of llms. arXiv preprint arXiv:2410.12405.
Gao, D., Wang, H., Li, Y., Sun, X., Qian, Y., Ding, B., and Zhou, J. (2024). Text-to-sql empowered by large language models: A benchmark evaluation. Proceedings of the Very Large Data Bases Endowment (PVLDB), 17(5):1132–1145.
Lan, W., Wang, Z., Chauhan, A., Zhu, H., Li, A., Guo, J., Zhang, S., Hang, C.-W., Lilien, J., Hu, Y., Pan, L., Dong, M., Wang, J., Jiang, J., Ash, S., Castelli, V., Ng, P., and Xiang, B. (2023). UNITE: A Unified Benchmark for Text-to-SQL Evaluation. [link]. arXiv:2305.16265.
Liang, J. T., Lin, M., Rao, N., and Myers, B. A. (2025). Prompts are programs too! understanding how developers build software containing prompts. Proceedings of the ACM on Software Engineering, 2(FSE):1591–1614.
Liu, M., Wang, X., Xu, J., Yi, W., and Wolfson, O. (2026). A systematic review of natural language interfaces for databases. Frontiers of Computer Science, 20.
Liu, Y., Xu, J., Zhang, L. L., Chen, Q., Feng, X., Chen, Y., Guo, Z., Yang, Y., and Cheng, P. (2025). Beyond prompt content: Enhancing llm performance via content-format integrated prompt optimization. arXiv preprint arXiv:2502.04295.
Luo, Y., Zhang, Z., Zhang, Y., Xie, Z., Wang, J., Jatowt, A., and Yang, Z. (2024). Data-scarce event argument extraction: A dynamic modular prompt tuning model based on slot transfer. In 2024 7th International Conference on Machine Learning and Natural Language Processing (MLNLP), pages 1–6. IEEE.
Mao, Y., He, J., and Chen, C. (2025). From prompts to templates: A systematic prompt template analysis for real-world llmapps. arXiv preprint arXiv:2504.02052.
Nahid, M. M. H., Rafiei, D., Zhang, W., and Zhang, Y. (2026). Rethinking schema linking: A context-aware bidirectional retrieval approach for text-to-SQL. In Findings of the Association for Computational Linguistics: EACL 2026, pages 4516–4546, Rabat, Morocco. Association for Computational Linguistics.
Petrola, L., Brayner, A., and Franco, W. (2025). Heuristic-guided text-to-sql translation with llms: Optimizing natural language interfaces for relational databases. In Simpósio Brasileiro de Banco de Dados (SBBD), pages 126–139. SBC.
Piao, S., Lee, J., and Park, S. (2026). LitE-SQL: A lightweight and efficient text-to-SQL framework with vector-based schema linking and execution-guided self-correction. In Findings of the Association for Computational Linguistics: EACL 2026, pages 3593–3608, Rabat, Morocco. Association for Computational Linguistics.
Pourreza, M. and Rafiei, D. (2023). DIN-SQL: Decomposed in-context learning of text-to-SQL with self-correction. In Advances in Neural Information Processing Systems, volume 36, pages 36339–36348. Curran Associates, Inc.
Santos, W. F., Santos, P. V. d., Martins, M. S. R., Lekakis, L. F., Rosa, F. L., Costa, B. M., Filho, M. A. P., and Montalvão, I. A. (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.
Schnabel, T. and Neville, J. (2024). Symbolic prompt program search: A structure-aware approach to efficient compile-time prompt optimization. arXiv preprint arXiv:2404.02319.
Shi, L., Tang, Z., Zhang, N., Zhang, X., and Yang, Z. (2025). A survey on employing large language models for text-to-SQL tasks. ACM Computing Surveys, 58(2):1–37.
Shinn, N., Cassano, F., Labash, B., Gopinath, A., Narasimhan, K., and Yao, S. (2023). Reflexion: Language agents with verbal reinforcement learning, 2023. URL [link], 1.
Tan, Z., Liu, X., Shu, Q., Li, X., Wan, C., Liu, D., Wan, Q., and Liao, G. (2024). Enhancing text-to-sql capabilities of large language models through tailored promptings. In Proceedings of the 2024 Joint International Conference on Computational Linguistics, Language Resources and Evaluation (LREC-COLING 2024), pages 6091–6109.
Wang, B., Ren, C., Yang, J., Liang, X., Bai, J., Chai, L., Yan, Z., Zhang, Q.-W., Yin, D., Sun, X., and Li, Z. (2025). MAC-SQL: A multi-agent collaborative framework for text-to-SQL. In Proceedings of the 31st International Conference on Computational Linguistics, pages 540–557, Abu Dhabi, UAE. Association for Computational Linguistics.
Wang, M., Liu, Y., Liang, X., Li, S., Huang, Y., Zhang, X., Shen, S., Guan, C., Wang, D., Feng, S., et al. (2024). Langgpt: Rethinking structured reusable prompt design framework for llms from the programming language. arXiv preprint arXiv:2402.16929.
Yavuz, S., Gur, I., Su, Y., and Yan, X. (2021). Text-to-sql in the wild: A naturally-occurring dataset based on stack exchange data. In Proceedings of the 3rd Workshop on Natural Language Processing for Programming (NLP4Prog), pages 77–87, Online. Association for Computational Linguistics.
Zhuo, J., Zhang, S., Fang, X., Duan, H., Lin, D., and Chen, K. (2024). Prosa: Assessing and understanding the prompt sensitivity of llms. arXiv preprint arXiv:2410.12405.
Publicado
08/09/2026
Como Citar
GONÇALVES, Daniele Carnaúba; NEVES, Bárbara S.; FERRUFINO, Paulina Irene Velasquez; COSTA, Davi Uchoa Cavalcante; VENCESLAU, Amanda; FRANCO, Wellington; MACÊDO, José Antônio; HOLANDA, Raimir.
Composable Prompt Modularization in Text-to-SQL Agents: A Practical Approach. In: SIMPÓSIO BRASILEIRO DE BANCO DE DADOS (SBBD), 41. , 2026, São Carlos/SP.
Anais [...].
Porto Alegre: Sociedade Brasileira de Computação,
2026
.
p. 687-700.
ISSN 2763-8979.
DOI: https://doi.org/10.5753/sbbd.2026.249296.
