NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

TRUST-SQL: Tool-Integrated Multi-Turn Reinforcement Learning for Text-to-SQL over Unknown Schemas

Ai Jian, Xiaoyun Zhang, Wanrou Du, Jingqing Ruan, Jiangbo Pei, Weipeng Zhang, Ke Zeng, Xunliang Cai · DOI

TL;DR

TRUST-SQL introduces a paradigm shift in Text-to-SQL by moving away from the "Full Schema Assumption," where models are pre-fed entire database structures. Instead, it treats the model as an autonomous agent that must actively explore unknown databases using tools, achieving massive performance gains (up to 30.6% absolute improvement) while using significantly fewer tokens than traditional methods.

What Problem Does This Paper Address?

Most current Text-to-SQL systems rely on a "Full Schema Assumption": they assume the entire database schema (tables, columns, and types) can fit into the model's prompt. In real-world enterprise environments, this is often impossible. Databases can contain hundreds of tables with thousands of columns, many of which are noisy or irrelevant.

Stuffing all this metadata into a prompt leads to two major issues:

  1. Context Limits: The schema simply won't fit.
  2. Distraction: Irrelevant metadata causes models to "hallucinate" incorrect table names or logic.

The authors propose the Unknown Schema setting, where the model starts with zero knowledge of the database and must interactively query the system to find the metadata it needs to answer a user's question.

Methods

The researchers developed TRUST-SQL (Truthful Reasoning with Unknown Schema via Tools), which uses two primary innovations:

1. The Four-Phase Protocol

To prevent the model from getting lost in long interactions, the authors enforce a structured workflow:

  • Explore: The agent queries database metadata (e.g., sqlite_master) to find relevant tables.
  • Propose: A mandatory "cognitive checkpoint" where the agent must explicitly list the tables and columns it intends to use. This forces the model to commit to verified facts.
  • Generate: The agent writes the SQL query based on the proposed schema.
  • Confirm: The agent executes the query and submits the final answer.

2. Dual-Track GRPO

Training an agent for multi-turn tasks is hard because of credit assignment: if the final SQL is wrong, was it because the agent explored the wrong tables, or because it wrote bad code?

Standard reinforcement learning (like Group Relative Policy Optimization, or GRPO) uses a single reward. The authors propose Dual-Track GRPO, which splits the learning process into two tracks:

  • Schema Track: Rewards the agent specifically for finding the "ground truth" tables and columns.
  • Full Track: Rewards the agent for the final execution accuracy. By using token-level masking, the model learns to associate exploration actions with exploration rewards, preventing "noisy" signals from interfering with its SQL-writing logic.

Datasets

The model was evaluated across five major benchmarks to test both general performance and robustness:

  • BIRD-Dev: A large-scale benchmark for complex database grounding.
  • Spider-Test: The standard for compositional generalization.
  • Spider-Variants (Syn, DK, Realistic): Challenging versions of Spider that test robustness against synonyms, domain knowledge gaps, and ambiguity.
  • Spider 2.0: A newly released, enterprise-grade benchmark with massive schemas that are intentionally too large for standard prompts.

Key Insights and Ideas

  • Verification Kills Hallucination: The "Propose" phase acts as a circuit breaker for hallucinations. By forcing the model to verify the schema before writing code, they achieved a 9.4x reduction in hallucinations compared to baseline agents.
  • Active Exploration > Passive Context: Surprisingly, TRUST-SQL often outperforms models that have the full schema pre-loaded. This suggests that the act of searching for metadata helps the model filter out "noise" that would otherwise distract it in a massive prompt.
  • Efficiency Gains: Compared to "training-free" agent pipelines (like CHESS), TRUST-SQL achieved a 500x reduction in latency and a 113x reduction in token consumption because it learns to be a precise "detective" rather than a brute-force searcher.

Key Results

  • Massive Accuracy Boosts: TRUST-SQL achieved an average absolute improvement of 30.6% for 4B-parameter models and 16.6% for 8B-parameter models over their base versions.
  • Superiority over "Cheating" Baselines: In the BIRD-Dev benchmark, TRUST-SQL (which starts with no schema) matched or beat strong baselines that were given the full schema upfront.
  • Dual-Track Success: The Dual-Track GRPO strategy provided a 9.9% relative improvement over standard GRPO, proving that separating exploration rewards from execution rewards is vital for multi-turn agents.

Limitations and Future Work

  • Dialect Constraints: The current work focuses exclusively on SQLite. Real-world enterprise systems often use PostgreSQL, MySQL, or BigQuery, which have different metadata structures.
  • Fixed Turn Budget: The model is trained with a maximum of 10-15 turns. Extremely complex databases might require dynamic turn management.
  • Inference Cost: While more efficient than other agentic frameworks, multi-turn interaction is still inherently slower and more expensive than single-turn "static" Text-to-SQL. Future work could involve "distilling" these agentic capabilities back into faster, single-turn models.

Summary updated

BibTeX
@misc{jian2026trust,
  author = {Ai Jian and Xiaoyun Zhang and Wanrou Du and Jingqing Ruan and Jiangbo Pei and Weipeng Zhang and Ke Zeng and Xunliang Cai},
  title = {{TRUST-SQL: Tool-Integrated Multi-Turn Reinforcement Learning for Text-to-SQL over Unknown Schemas}},
  year = {2026},
  eprint = {2603.16448},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2603.16448},
}

Loading related content...

Figure