DualSQL: Text-to-SQL with Multi-Agent Reinforcement Learning
Summary
DualSQL proposes a multi-agent reinforcement learning framework for Text-to-SQL, using a single shared model to jointly optimize schema linking and SQL generation, achieving state-of-the-art accuracy with smaller model sizes.
View Cached Full Text
Cached at: 09/17/26, 09:08 AM
# DualSQL: Text-to-SQL with Multi-Agent Reinforcement Learning
Source: [https://arxiv.org/html/2609.18135](https://arxiv.org/html/2609.18135)
Shijie Chen††thanks:Work done during Shijie Chen’s internship at Google\.Yu GanAffiliation:Google LLCEmail:[gany@google\.com](mailto:)Yeounoh ChungAffiliation:Google LLCJiani ZhangAffiliation:Google LLCQuannan LiAffiliation:Google LLCSravan BodapatiAffiliation:Google LLCCody GreerAffiliation:Google LLCYu SuAffiliation:The Ohio State UniversityFatma OzcanAffiliation:Google LLCEmail:[fozcan@google\.com](mailto:)
###### Abstract
State\-of\-the\-art Text\-to\-SQL systems are typically multi\-agent pipelines centered around two fundamental tasks: schema linking and SQL generation\. However, existing work trains separate models for each task, failing to leverage the synergy between these interrelated tasks\. In this work, we proposeDualSQL, a new Text\-to\-SQL system consisting of two agents powered by a single model backbone\. The agents share the same model weights and agentic scaffold, enabling joint optimization through a robust multi\-agent reinforcement learning \(RL\) framework\. We design three database access tools to facilitate effective multi\-step reasoning grounded in interactions with the databases\. To improve training and avoid model collapse, we introduce a set of rollout guardrail mechanisms that stabilize multi\-agent RL training, enablingDualSQLto keep improving during training\. We also introduce a new SQL correctness metric, robust execution match \(REX\), to more accurately judge SQL correctness and assign reward signals\. Trained on only 3755 examples,DualSQL\-4B achieves an impressive 68\.0% execution accuracy on the BIRD development set, matching previous 7B models\.DualSQL\-8B further improves to 71\.1%, outperforming previous state\-of\-the\-art single\-model solutions with 32B parameters\. These results demonstrate the strength of joint multi\-agent reinforcement learning for building high\-performance Text\-to\-SQL pipelines\.
## 1Introduction
Text\-to\-SQL is a key technology for democratizing access to data analytics for non\-expert users through a natural language interface\([Li et al\., 2024a](https://arxiv.org/html/2609.18135#bib.bib1);[Luo et al\., 2025](https://arxiv.org/html/2609.18135#bib.bib2)\)\. However, this task is particularly difficult due to several challenges\. First, injecting the entire schema and sampled data from large\-scale databases into the context window of language models is prohibitively impractical due to the well\-known degradation of reasoning capabilities in long contexts[Du et al\. \(2025\)](https://arxiv.org/html/2609.18135#bib.bib42);[Chung et al\. \(2025a\)](https://arxiv.org/html/2609.18135#bib.bib43);[Ling et al\. \(2025\)](https://arxiv.org/html/2609.18135#bib.bib44)and high prefilling costs\. Second, SQL queries must be strongly grounded in the database context, requiring precise schema linking for identifying relevant tables and columns, navigating complex schema relationships for formulating correct joins, and a comprehensive understanding of database content for selecting accurate literals\([Zhang et al\., 2025a](https://arxiv.org/html/2609.18135#bib.bib40);[Su et al\., 2024](https://arxiv.org/html/2609.18135#bib.bib41)\)\. Third, the inherent semantic complexity of the Text\-to\-SQL task complicates the accurate mapping of user intent to valid SQL\. This complexity stems from the semantic gap between ambiguous natural language and rigid SQL logic, the requirement for domain knowledge, and ambiguities within the schema itself\.
State\-of\-the\-art LLM\-based systems address these challenges through a modular design built around schema linking and SQL generation\([Liu et al\., 2025c](https://arxiv.org/html/2609.18135#bib.bib17);[Pourreza and Rafiei, 2023](https://arxiv.org/html/2609.18135#bib.bib9);[Pourreza et al\., 2025a](https://arxiv.org/html/2609.18135#bib.bib10)\)\. Within each stage, various methods have been explored, including supervised fine\-tuning\([Li et al\., 2025](https://arxiv.org/html/2609.18135#bib.bib13)\), in\-context learning\([Talaei et al\., 2024](https://arxiv.org/html/2609.18135#bib.bib14);[Pourreza et al\., 2025a](https://arxiv.org/html/2609.18135#bib.bib10)\), and reinforcement learning from execution feedback\([Pourreza et al\., 2025b](https://arxiv.org/html/2609.18135#bib.bib4);[Yao et al\., 2025](https://arxiv.org/html/2609.18135#bib.bib6)\)\. However, these methods optimize the two stages in isolation, pointing to a critical gap in joint optimization of the end\-to\-end pipeline\.
We argue that, despite differing task formulations, schema linking and SQL generation share two core capabilities: semantic retrieval over complex relational schemas and reasoning grounded in database context\. Therefore, instead of building separate models, it is better to treat these tasks as dual facets of a unified agent that can operate on databases, learn shared knowledge representations, and transfer reasoning skills\.
In this work, we proposeDualSQL, a Text\-to\-SQL framework that consolidates schema linking and SQL generation into a unified agentic pipeline powered by a single, parameter\-shared open\-weight LLM\. Inspired by the iterative workflow of human database developers, we equipDualSQLwith three database access tools: metadata profiling, full\-text search, and SQL execution\. Rather than relying on rigid, pre\-defined workflows,DualSQLlearns to autonomously interact with databases, dynamically verifying and correcting its reasoning through tool\-use feedback\.
The entire system is jointly trained with a multi\-agent reinforcement learning framework, supported by an asynchronous rollout system that decouples synchronization between stages\. We find that standard stabilization techniques such as importance sampling correction[Li \(2025\)](https://arxiv.org/html/2609.18135#bib.bib38);[Liu et al\. \(2025a\)](https://arxiv.org/html/2609.18135#bib.bib36);[Zheng et al\. \(2025a\)](https://arxiv.org/html/2609.18135#bib.bib39)are insufficient to prevent structural degeneration in our multi\-agent, multi\-turn tool\-use settings\. We therefore introduce a set of agentic rollout guardrails, including strict format checking with rollout cutoff and error\-focused loss masking\. Furthermore, to provide cleaner reward signals than the standard execution accuracy \(EX\), which is overly sensitive to benign formatting variations and insensitive to duplicates, we introduce Robust Execution Match \(REX\)\. REX can be computed deterministically to efficiently assess exact execution equivalence, preventing the reinforcement of false positives during training\.
By combining this stable agentic RL framework with the unified multi\-agent formulation,DualSQLdemonstrates that open\-weight models can achieve strong Text\-to\-SQL capabilities without relying on massive parameter counts or multi\-model ensembles\. On the challenging BIRD benchmark,DualSQL\-4B achieves a competitive 68\.0% EX, whileDualSQL\-8B establishes a new state\-of\-the\-art for single\-model solutions at 71\.1% EX, rivaling systems that utilize 32B parameters\.
To summarize, our main contributions are:
- •We introduce a multi\-agent Text\-to\-SQL framework driven by a shared LLM backbone and three database access tools\.
- •We introduce comprehensive agentic rollout guardrails that successfully stabilize multi\-agent RL training, and Robust Execution Match, which provides more accurate SQL evaluation\.
- •We demonstrate that joint multi\-agent optimization significantly extends the performance ceiling of single\-model pipelines, achieving highly competitive performance with small model sizes\.
## 2Related Work
### 2\.1LLM\-based Text\-to\-SQL
Recent advancements in Text\-to\-SQL have progressed from simple prompt engineering on general\-purpose LLMs to specialized multi\-agent systems\([Biswal et al\., 2026](https://arxiv.org/html/2609.18135#bib.bib27);[Wang et al\., 2025b](https://arxiv.org/html/2609.18135#bib.bib25);[Deng et al\., 2025](https://arxiv.org/html/2609.18135#bib.bib26)\)\. Initial efforts utilized in\-context learning \(ICL\) to optimize the zero\-shot and few\-shot performance of proprietary LLMs like GPT\-4\([Gao et al\., 2023](https://arxiv.org/html/2609.18135#bib.bib19);[Pourreza and Rafiei, 2023](https://arxiv.org/html/2609.18135#bib.bib9);[Chung et al\., 2025b](https://arxiv.org/html/2609.18135#bib.bib12)\)\. Subsequent context engineering strategies\([Chung et al\., 2025b](https://arxiv.org/html/2609.18135#bib.bib12);[Shkapenyuk et al\., 2025](https://arxiv.org/html/2609.18135#bib.bib11)\)highlighted the criticality of schema linking via augmented metadata for accurate SQL generation\. Unlike ICL\-based methods, which rely on passive context engineering,DualSQLlearns to perform iterative schema linking with tool use\. To handle query complexity, the field shifted toward multi\-agent collaboration\([Wang et al\., 2025a](https://arxiv.org/html/2609.18135#bib.bib18);[Pourreza et al\., 2025a](https://arxiv.org/html/2609.18135#bib.bib10)\)for task decomposition and external tool leverage\. To reduce API dependency and improve cost\-efficiency, supervised fine\-tuned approaches emerged\([Ma et al\., 2025a](https://arxiv.org/html/2609.18135#bib.bib21)\), utilizing large\-scale synthetic datasets to align open\-source models with the Text\-to\-SQL task\([Li et al\., 2024b](https://arxiv.org/html/2609.18135#bib.bib20);[Li et al\., 2025](https://arxiv.org/html/2609.18135#bib.bib13)\)\. This paradigm was further refined by integrating RL with execution feedback to optimize reasoning chains and bridge the performance gap with larger models\([Ma et al\., 2025b](https://arxiv.org/html/2609.18135#bib.bib23);[Yao et al\., 2025](https://arxiv.org/html/2609.18135#bib.bib6);[Zhang et al\., 2025c](https://arxiv.org/html/2609.18135#bib.bib22)\)\. While the latest solutions synthesize agentic decomposition and RL\([Liu et al\., 2025b](https://arxiv.org/html/2609.18135#bib.bib24);[Xu et al\., 2025b](https://arxiv.org/html/2609.18135#bib.bib15);[Yang et al\., 2025b](https://arxiv.org/html/2609.18135#bib.bib16)\), they optimize agents for different stages separately, neglecting their synergy\.
DualSQLdiffers from existing work by \(1\) introducing the robust execution match metric for precise SQL correctness evaluation, \(2\) providing a comprehensive database manipulation toolset, and \(3\) establishing a robust multi\-agent RL framework for joint optimization of the Text\-to\-SQL pipeline\.
### 2\.2Reinforcement Learning with Verifiable Rewards
Reinforcement Learning with Verifiable Rewards \(RLVR\) has become a cornerstone for enhancing LLM reasoning in domains with verifiable outcomes, such as mathematics\([Shao et al\., 2024](https://arxiv.org/html/2609.18135#bib.bib7)\)and coding\([Guo et al\., 2025](https://arxiv.org/html/2609.18135#bib.bib28)\)\. To address inherent training instabilities, recent research has introduced optimization techniques ranging from decoupled clipping and dynamic sampling\([Yu et al\., 2025](https://arxiv.org/html/2609.18135#bib.bib29)\)to variance\-based rollout down\-sampling\([Xu et al\., 2025a](https://arxiv.org/html/2609.18135#bib.bib32)\)\. In multi\-turn agentic scenarios, methods such as entropy\-based adaptive branching\([Dong et al\., 2025](https://arxiv.org/html/2609.18135#bib.bib35)\)and void\-turn filtering\([Xue et al\., 2025](https://arxiv.org/html/2609.18135#bib.bib31)\)have been proposed to mitigate distribution shifts, while other studies have investigated the role of high\-entropy tokens\([Wang et al\., 2025c](https://arxiv.org/html/2609.18135#bib.bib34)\), the boundaries of reasoning capabilities versus sampling efficiency, and curriculum learning for autonomous agents\([Nguyen et al\., 2025](https://arxiv.org/html/2609.18135#bib.bib30);[Zheng et al\., 2025b](https://arxiv.org/html/2609.18135#bib.bib33)\)\. The complex and noisy database environments pose new challenges to agentic RL stability for text\-to\-SQL systems\. Our work contributes an efficient rollout implementation and a set of agentic rollout guardrails, which effectively enhance the efficiency and stability of multi\-agent RL, leading to better performance via prolonged exploration\.
Figure 1:The multi\-agent training framework forDualSQL\.slslandsqlsqldenote schema linking and SQL generation tasks, respectively\. The two agents are driven by the same LLM and tools\.
## 3DualSQLAgentic System
This section introduces the agentic system ofDualSQL\. We introduce a unified agentic formulation for the sub\-agents in Text\-to\-SQL systems: schema linker and SQL generator\. Each agent is powered by the same backbone LLM that is equipped with a set of database access tools, engaging in multi\-turn interactions to understand database context and reason about the question\.
### 3\.1Database Access Tools
Inspired by the iterative workflow of human database developers, we equip the agents with three database access tools\. Implementation details, including JSON serialization of tool outputs and asynchronous tool hosting, are in Appendix[A](https://arxiv.org/html/2609.18135#A1)\.
SQL Executor\.The primary interface between the agents and the database\. The agents use it for \(i\) execution feedback to verify syntactic and semantic correctness, \(ii\) entity grounding to inspect literal representations, and \(iii\) ad\-hoc schema exploration viasqlite\_masterorPRAGMA\. A content\-aware truncation policy keeps standard retrievals within context limits while preserving full schema\-query responses\.
Full Text Search\.To bridge ambiguous or abbreviated mentions in user queries to literal database content, this tool performs fuzzy matching over schema names and cell values using SQLite FTS5 inverted indices\. It returns the matched schema elements and up to five matching values per column\.
Database Profiler\.This tool retrieves offline\-prepared database metadata\. For each table and column, we use an LLM to produce a description summarizing semantic intent and to infer foreign\-key relationships that may be missing from the DDL\. We additionally pre\-compute column\-level statistics \(distinct counts, types, null ratios\)\. Offloading this analysis offline frees the agent to focus on query logic at runtime\.
### 3\.2DualSQLAgents
DualSQLfeatures a multi\-agent pipeline consisting of two agents, both of which are powered by the same backbone LLM and can engage in multi\-turn interactions with the database via the tools introduced in Section[3\.1](https://arxiv.org/html/2609.18135#S3.SS1):
Schema linker:Given the natural language questionQQand the complete database schema𝒮=\{𝒯,𝒞\}\\mathcal\{S\}=\\\{\\mathcal\{T\},\\mathcal\{C\}\\\}, where𝒯\\mathcal\{T\}and𝒞\\mathcal\{C\}are the sets of tables and columns, the schema linker identifies the relevant database schema𝒮′⊆𝒮\\mathcal\{S\}^\{\\prime\}\\subseteq\\mathcal\{S\}to reduce the distraction in large databases and ensures the subsequent SQL generator operates within a focused context window\.
SQL generator:The SQL generator generates a SQL queryy′y^\{\\prime\}based on the questionQQand the linked schema𝒮′\\mathcal\{S\}^\{\\prime\}\. By modeling schema linking and SQL generation as a joint stochastic process, we encourage the generated SQL to be grounded in the correct schema elements, reducing hallucination from irrelevant table schemas\.
Despite its simplicity, this unified design proves effective and allows us to jointly optimize the entire pipeline with our multi\-agent RL framework\.
## 4Multi\-Agent RL Framework for Optimizing Text\-to\-SQL Pipelines
The unified agent design enables joint optimization of the two agents by training a single LLM\. In this section, we introduce our multi\-agent RL recipe, including an asynchronous rollout system, rollout guardrails, reward design, and training objectives\.
### 4\.1Asynchronous Rollout System
Considering the dependency structure of the above Text\-to\-SQL pipeline and that agent trajectories vary greatly in length, we design an asynchronous rollout system which manages asynchronous rollout for parsing pipelines\. We treat schema linking and SQL generation as an integral stochastic process, which avoids synchronization between stages and improves throughput of multi\-agent rollout\.
For each batch ofBBprompts, thebatch\-level controllermanages asynchronous rollout of different prompts, each supported by the prompt\-level pipeline actor\. Theprompt\-level pipeline actorexecutes individual Text\-to\-SQL pipelines\. It flexibly supports rollout of a single task or a pipeline chaining schema linking and SQL generation\. With a group size ofGG, we sample a total of2B⋅G2B\\cdot Gtrajectories in each optimization step\. These trajectories are later grouped by task and used for joint optimization of the policy model\.
### 4\.2Agentic Rollout Guardrails
In our preliminary experiments, we observe that multi\-agent RL training is much more unstable than non\-agentic or single\-agent RL training, shown by frequent collapse in trajectory format in one or both tasks\. Existing work advocates for variants of sequence\-level importance sampling or negative sampling to calibrate the distribution mismatch between rollout and policy models, aiming to stabilize training[Liu et al\. \(2025a\)](https://arxiv.org/html/2609.18135#bib.bib36);[Li \(2025\)](https://arxiv.org/html/2609.18135#bib.bib38)\. However, we find that representative collapse patterns, such as the incorrect use of format tokens, endless loops, and incorrect tool calls, persist even with these calibration techniques\. To improve the robustness of multi\-agent RL training, we design a set ofagentic rollout guardrails, including strict format checking, rollout cutoff, and loss masking\.
Strict Format Checking\.To maintain format correctness of agentic rollouts, we design a strict format checking mechanism that enforces the following requirements:
- •In each turn, the agent should generate a non\-empty<think\></think\>block for effective reasoning\.
- •In each turn, the agent should generate either a<tool\_call\></tool\_call\>block for tool calls or a single`\`\`\`\.\.\.\`\`\``code block for returning final answers, such as a linked schema or a SQL query\.
- •If a tool call is generated, it should be formatted as a JSON string following the pre\-defined tool call format, including a valid tool name and tool arguments\. Moreover, the tools are idempotent and the same tool should not be called more than once with the exact same argument\.
- •If a code block is generated, the content after the code block should not constitute more than half of the total length in that turn\. This requirement prevents the model from collapsing into generating redundant or even endless explanations after the solution is given\.
If a trajectory violates any of the above constraints, we set the format correctness rewardRfR\_\{f\}to 0\. Otherwise,Rf=1R\_\{f\}=1\. In this way, format checking helps reduce degeneration and mode collapse during training\.
Rollout Cutoff\.Allowing rollout to proceed after format violations can lead to a reward hacking pattern, where agents learn that format errors are acceptable as long as the final answer is correct\. Moreover, the malformed actions pollute reward signals, causing the policy model to reinforce invalid actions and eventually reach an unrecoverable state\. To prevent this, we stop rollout immediately when detecting any format constraint violation, which acts as a hard filter on the exploration space, ensuring that the agent is only rewarded when strictly adhering to the format requirements\.
Loss Masking\.Penalizing an entire multi\-turn trajectory for a terminal format error introduces noise in reward signals, as it may discourage the valid reasoning steps that preceded the error\. At the same time, rewarding correct trajectories with intermediate format or tool call errors also risks reinforcing bad behaviors\. Therefore, we mask out the loss for previous turns if a trajectory ends with a turn with a format error to concentrate learning signals on format error turns\. This approach effectively teaches the agent to unlearn malformed actions before improving reasoning correctness\.
At test time, we add meaningful error messages as tool responses to the trajectory upon occasional errors, such as JSON parsing errors or argument type mismatches\. In this way, the agent can correct its tool\-use mistakes and continue reasoning\.
### 4\.3Reward Design
Schema Linking\.We design a reward function that encourages high recall\. Given the ground truth schema itemsS∗S^\{\*\}and the linked schema itemsS′S^\{\\prime\}, we compute the schema linking reward as:
Rsl=\{1ifS∗=S′0\.9−max\(0\.2−\|S∗∩S′\|\|S′\|,0\)ifS∗⊆S′0\.7−max\(0\.2−\|S∗∩S′\|\|S′\|,0\)ifT∗⊆T′0\.5⋅2\|S∗∩S′\|\|S∗\|\+\|S′\|otherwise,R\_\{sl\}=\\begin\{cases\}1&\\text\{if $S^\{\*\}$ = $S^\{\\prime\}$\}\\\\ 0\.9\-\\max\(0\.2\-\\frac\{\|S^\{\*\}\\cap S^\{\\prime\}\|\}\{\|S^\{\\prime\}\|\},0\)&\\text\{if $S^\{\*\}\\subseteq S^\{\\prime\}$\}\\\\ 0\.7\-\\max\(0\.2\-\\frac\{\|S^\{\*\}\\cap S^\{\\prime\}\|\}\{\|S^\{\\prime\}\|\},0\)&\\text\{if $T^\{\*\}\\subseteq T^\{\\prime\}$\}\\\\ 0\.5\\cdot\\frac\{2\|S^\{\*\}\\cap S^\{\\prime\}\|\}\{\|S^\{\*\}\|\+\|S^\{\\prime\}\|\}&\\text\{otherwise\}\\end\{cases\},\(1\)whereT∗T^\{\*\}andT′T^\{\\prime\}are the sets of ground truth and linked tables, respectively\.
This reward function gives full credit to perfect matches\. Then, partial credit is given for complete schema\-level and table\-level recall with a penalty for low precision\. Finally, we give partial credit based on F1 score\.
SQL Generation\.We use the correctness of the predicted SQL queryy′y^\{\\prime\}as the reward signal for SQL generation\. To avoid degeneration into single\-turn reasoning, we add a bonus for correct trajectories that use toolsRtool=1R\_\{tool\}=1\.
Rsql=\{1\+0\.1⋅RtoolifEq\(y′CLOSE,OPENy∗\)0otherwiseR\_\{sql\}=\\begin\{cases\}1\+0\.1\\cdot R\_\{tool\}&\\text\{if $Eq\(y^\{\\prime\}$,$y^\{\*\}\)$\}\\\\ 0&\\text\{otherwise\}\\end\{cases\}\(2\)wherey∗y^\{\*\}is the ground truth SQL query andEq\(⋅\)Eq\(\\cdot\)indicates whether two SQL queries are equivalent\.
The execution match \(EX\) metric, widely used in Text\-to\-SQL benchmarks like Spider and BIRD, first converts SQL query result sets into a set of literals and evaluates equivalence\. This process overlooks the important discrepancies brought by duplicated rows and row ordering, leading to false positive evaluations\. Moreover, EX also does not tolerate column order permutations, which introduces false negative signals\.
We proposerobust execution match\(REX\), a stricter metric based on data similarity, which evaluates equivalence by finding the maximum matching between the result sets of two SQL queries\. If the question does not demand row order matching, REX first sorts the result sets by high\-cardinality columns\. Then, REX tries to find a permutation of columns that leads to the maximum matching\. If a perfect matching is found, the two result sets are considered equivalent\. We decide whether a question requires row ordering matching based on the presence of theORDER BYkeyword in ground truth SQL queries\. Algorithm details are available in Appendix[E](https://arxiv.org/html/2609.18135#A5)\.
Format Reward and Length Penalty\.We use the soft overlong punishment introduced by DAPO to penalize overlong trajectories\. Additionally, the length penalty also implicitly incentivizes the agent to avoid unnecessary self\-correction steps by assigning higher marginal rewards to concise, error\-free trajectories\.
Rl=\{0\|τ\|≤Lmax−Lcache\(Lmax−Lcache−\|τ\|\)LcacheLmax−Lcache<\|τ\|≤Lmax−1,\|τ\|\>LmaxR\_\{l\}=\\begin\{cases\}0&\|\\tau\|\\leq L\_\{max\}\-L\_\{cache\}\\\\ \\frac\{\(L\_\{max\}\-L\_\{cache\}\-\|\\tau\|\)\}\{L\_\{cache\}\}&L\_\{max\}\-L\_\{cache\}<\|\\tau\|\\leq L\_\{max\}\\\\ \-1,&\|\\tau\|\>L\_\{max\}\\end\{cases\}\(3\)
We only apply the length penalty to trajectories with the correct format to avoid false positive signals\. The final reward is computed as:
R=max\(Rtask,0\.1⋅Rf\)\+λlRl⋅Rf,R=\\max\(R\_\{task\},0\.1\\cdot R\_\{f\}\)\+\\lambda\_\{l\}R\_\{l\}\\cdot R\_\{f\},\(4\)whereRtask∈\{Rsl,Rsql\}R\_\{task\}\\in\\\{R\_\{sl\},R\_\{sql\}\\\}is the task\-specific reward\.λl=0\.2\\lambda\_\{l\}=0\.2is the weight for the length penalty\. We further clip negative rewards to 0 to prevent undesirable trajectories from having a positive advantage\.
### 4\.4Training Objectives
We optimizeDualSQLwith GRPO\([Shao et al\., 2024](https://arxiv.org/html/2609.18135#bib.bib7)\), incorporating token\-mean loss and clip\-higher\([Yu et al\., 2025](https://arxiv.org/html/2609.18135#bib.bib29)\)into the training objective, and sequence\-level masked importance sampling\([Liu et al\., 2025a](https://arxiv.org/html/2609.18135#bib.bib36)\)for enhancing training stability\. For each promptxx, we sample2G2Gtrajectories fromπθ\\pi\_\{\\theta\}\(GGper taskt∈\{sl,sql\}t\\in\\\{sl,sql\\\}\) and compute a task\-specific group\-relative advantageA^t\(i\)\\hat\{A\}^\{\(i\)\}\_\{t\}for policy updates\.
## 5Experiments
### 5\.1Experiment Setup
Training Data PreparationWe train our models on the officially revised training set of BIRD\. We filter out 2715 trivial examples where Qwen3\-8B hasPass16=1Pass^\{16\}=1and 466 intractable examples where Gemini\-2\.5\-Pro hasPass@32=0\\text\{Pass@32\}=0when evaluated in both single\-turn and agentic Text\-to\-SQL settings\. This leads to a training set of 3376 examples\. We further manually analyze the intractable questions and correct 384 annotation errors as augmented training data, leading to 3755 training examples after deduplication\.
RL SetupWe implement our multi\-agent RL framework based on VeRL\([Sheng et al\., 2024](https://arxiv.org/html/2609.18135#bib.bib8)\)\. We use a learning rate of 2e\-6, linear warmup of 20 steps, batch size of 256, and group size of 16 during training\. For rollout, we set the temperature to 1\.0,top\-k=20\\text\{top\-k\}=20andtop\-p=0\.99\\text\{top\-p\}=0\.99to encourage exploration\. We use Qwen3\([Yang et al\., 2025a](https://arxiv.org/html/2609.18135#bib.bib45)\)4B and 8B models as the base models for training\. The trajectory length limit is set to 32K tokens and the overlong buffer sizeLcacheL\_\{cache\}to 4K tokens\. More training details, including the training performance curve, can be found in Appendix[B](https://arxiv.org/html/2609.18135#A2)\.
### 5\.2Experiment Results
We follow the same schema serialization procedure as OmniSQL\([Li et al\., 2025](https://arxiv.org/html/2609.18135#bib.bib13)\)to be consistent with previous work and use OmniSQL’s prompt when evaluating base LLMs\. By default, we report the average performance over 8 runs\.
#### 5\.2\.1In\-Domain Evaluation
Text\-to\-SQLWe compareDualSQLwith existing RL\-based single\-model Text\-to\-SQL methods on the BIRD development set \(BIRD\-Dev\), including single\-turn models like SQL\-R1[Ma et al\. \(2025b\)](https://arxiv.org/html/2609.18135#bib.bib23), Reasoning\-SQL[Pourreza et al\. \(2025b\)](https://arxiv.org/html/2609.18135#bib.bib4)and Arctic\-Text2SQL\-R1\([Yao et al\., 2025](https://arxiv.org/html/2609.18135#bib.bib6)\), and the single\-agent MTIR\-SQL\([Xu et al\., 2025b](https://arxiv.org/html/2609.18135#bib.bib15)\)with only the SQL execution tool\.
MethodSizeAgentEXMTIR\-SQL4Bsqlsql64\.4Reasoning\-SQL7B×\\times64\.0SQL\-R17B×\\times66\.6Arctic\-Text2SQL\-R17B×\\times68\.9MTIR\-SQL8Bsqlsql64\.6Reasoning\-SQL14B×\\times65\.3SQL\-R114B×\\times67\.1MTIR\-SQL14Bsqlsql68\.1Arctic\-Text2SQL\-R114B×\\times70\.1Arctic\-Text2SQL\-R132B×\\times70\.5DualSQL\(Ours\)4Bsl\+sqlsl\+sql68\.0DualSQL\(Ours\)8Bsl\+sqlsl\+sql71\.1Table 1:Performance on the BIRD development set\.As shown by Table[1](https://arxiv.org/html/2609.18135#S5.T1), with multi\-agent RL training of both schema linking and SQL generation,DualSQLachieves impressive Text\-to\-SQL performance with small model sizes\.DualSQL\-4B reaches 68\.0% EX, matching prior 7B baselines\.DualSQL\-8B further improves performance to 71\.1% EX, surpassing previous methods built on 14B or 32B models and establishing a new single\-model state\-of\-the\-art\. Breaking down by question difficulty \(Appendix[C](https://arxiv.org/html/2609.18135#A3)\), our multi\-agent formulation consistently improves over the SQL\-onlyDualSQLsql\\textit\{DualSQL\}\_\{sql\}baseline across all difficulty levels, with the largest gain on challenging questions \(3\.0% EX for the 8B model\)\.
Table 2:Schema linking performance on BIRD\-Dev\. C\-Recall denotes complete recall\.Schema LinkingWe evaluate the schema linking performance ofDualSQLon the BIRD development set by comparing linked schema𝒮′\\mathcal\{S^\{\\prime\}\}with the schema used by the ground truth query𝒮∗\\mathcal\{S\}^\{\*\}\. In addition to precision, recall, and F1 score, we also report complete recall rate \(C\-Recall\), which measures the percentage of examples where all ground truth schema entities are retrieved by the agent\.
Table[2](https://arxiv.org/html/2609.18135#S5.T2)shows the schema linking performance ofDualSQL\. We compare the performance of standalone RL for the schema linking agent \(DualSQLsl\\textit\{DualSQL\}\_\{sl\}\-8B\) and multi\-agent RL\. As shown by the table,DualSQL\-8B can accurately find relevant schema items, achieving over 90% F1 score in schema linking\. Multi\-agent RL training additionally boosts precision by 1\.4% and C\-Recall by 1\.1%, demonstrating the synergy between agents\.
Table 3:SQL generation performance on BIRD\-Dev when paired with an oracle schema linker\.Linking Errors and Parsing Errors\.We conduct a manual error analysis onDualSQL\-8B’s errors and find that only 15\.3% of them are due to schema linking errors such as wrong columns and tables, despite C\-Recall being only 65\.8%\. This discrepancy exists because C\-Recall is a strict and over\-pessimistic metric\. In practice, we findDualSQLcan use tools to dynamically recover missing schema context during its multi\-turn reasoning process in the SQL generation stage, compensating for imperfect schema linking results\.
To quantify the impact of imperfect schema linking, we evaluateDualSQL\-8B’s performance with oracle schema linkers \(Table[3](https://arxiv.org/html/2609.18135#S5.T3)\)\.DualSQL\-8B’s performance can be improved by 5\.4 points, demonstrating sizable headroom for improvement in schema linking\. We also notice thatDualSQLmaintains its advantage overDualSQLsql\\textit\{DualSQL\}\_\{sql\}by 0\.8 points in EX, indicating that joint multi\-agent RL indeed improves reasoning capabilities\.
#### 5\.2\.2Out\-of\-domain Evaluation
Table 4:Comparing different RL training settings on BIRD\-Dev and Spider\.Our models are trained on data from only the BIRD training set\. To evaluate the generalization ability of our models, we also testDualSQLon Spider’s test set\([Yu et al\., 2018](https://arxiv.org/html/2609.18135#bib.bib5)\)and compare single\-turn RL, single\-agent RL, and multi\-agent RL when using the same training data and parameter setup\. As shown by Table[4](https://arxiv.org/html/2609.18135#S5.T4), we observe a significant advantage of single\-agent RL over single\-turn RL on the 8B models\. In addition, our joint multi\-agent RL training method further improves the text\-to\-SQL performance on both benchmarks, demonstrating that the tool\-use and reasoning capabilities learned during training can generalize to Spider\.
#### 5\.2\.3Ablation Studies
Effectiveness of Multi\-Agent RL:To understand the effectiveness of our multi\-agent RL framework, we compare RL outcomes using Qwen3\-8B under 3 settings: \(1\) single\-turn Text\-to\-SQL with reasoning, \(2\) multi\-turn agentic Text\-to\-SQL, and \(3\) multi\-agent Text\-to\-SQL \(schema linking \+ SQL generation\) trained with the same reward function and hyperparameter settings\.
Using the same training data and reward signal, we observe a significant performance gain of 2\.3% EX and 5\.4% REX when moving from single\-turn Text\-to\-SQL to multi\-turn agentic Text\-to\-SQL, demonstrating the effectiveness of our agentic Text\-to\-SQL framework\. Multi\-agent RL training of both schema linking and SQL generation further improves the performance by 1\.5% EX and 1\.9% REX on BIRD\-Dev, showing the benefit of joint optimization of multiple agents\.
Effectiveness of Robust Execution Match:To study the effectiveness of the proposed robust execution match as a reward signal, we compare RL outcomes in the single\-agent setting when using EX or REX asEq\(⋅\)Eq\(\\cdot\)in the reward function\.
Table 5:Comparison of performance on BIRD\-Dev when using EX or REX asEq\(⋅\)Eq\(\\cdot\)in the reward function for single\-agent Text\-to\-SQL RL\. We test on 8B models\.As shown by Table[5](https://arxiv.org/html/2609.18135#S5.T5), using the high\-fidelity REX metric as the reward signal leads to better RL outcomes measured in both EX and REX metrics\. Through error analysis, we find that the model trained with EX as the reward signal struggles with questions where usingDISTINCTandORDER BYclauses is required, which are also the scenarios where EX fails to distinguish\. This demonstrates that a cleaner reward signal consistently leads to better training outcomes, although the target benchmark is measured using a coarser metric\.
Effectiveness of Agentic Rollout Guardrails:To test the effectiveness of the proposed agentic rollout guardrails, we compare RL training runs with and without the guardrails and report execution accuracy on BIRD\-Dev during training\.
Figure 2:Ablation study on the effectiveness of agentic rollout guardrails\. We report execution accuracy \(EX\) on BIRD\-Dev during training\. Sequence\-level masked importance sampling is enabled for both models\.Fig\.[2](https://arxiv.org/html/2609.18135#S5.F2)shows that agentic rollout guardrails prevent mode collapse before convergence by guiding the model to unlearn erroneous behavior immediately at the error turns\. This allows the agent to maintain format correctness and reach higher performance via sustained training\. In contrast, malformed actions are retained in trajectories with high rewards without the guardrails, which are reinforced during training and eventually lead to behavioral collapse\.
#### 5\.2\.4DualSQLReasoning Strategies
To characterize the behavior ofDualSQL, we analyze the reasoning trajectories and tool usage patterns that emerged through joint multi\-agent reinforcement learning\. Table[6](https://arxiv.org/html/2609.18135#S5.T6)summarizes the average number of tool calls made byDualSQLin each stage on BIRD\-Dev\. An ablation study of individual tools is available in Appendix[D](https://arxiv.org/html/2609.18135#A4)\.
Table 6:Average number of tools used byDualSQL\-8Bon BIRD\-Dev\. SE: SQL Execution, FTS: Full Text Search, DP: Database Profiler\.We highlight two primary strategies that distinguishDualSQLfrom single\-turn baselines\. \(Please see Appendix[G](https://arxiv.org/html/2609.18135#A7)for example agent trajectories\.\)
Interactive Schema Linking:Rather than operating on a potentially hallucinated mental model derived from static DDL, the agents employ an interactive schema linking strategy\. By leveraging the Database Profiler to inspect table metadata and the SQL Executor to sample specific rows, the agents actively resolve lexical mismatches and verify columns, tables, and join paths before generating the SQL code\. The strategic separation between schema linking and SQL generation reduces the attention dilution of relevant information within massive input sequences in the SQL generator, allowing it to operate within a pruned, high\-relevance context window\. Additionally, our two\-stage approach achieves robust failure recovery by augmenting self\-correction with cross\-validation, mitigating the risks of relying solely on self\-correction[Zhang et al\. \(2025b\)](https://arxiv.org/html/2609.18135#bib.bib37)\. Should the pre\-filtered schema from the schema linker prove insufficient during execution, the SQL generator retains the capability of using tools to refine its schema understanding\.
Execution\-guided Error Correction:Unlike the standard single\-turn reasoning models that are prone to syntactically valid queries returning incorrect results,DualSQLemulates the behavior of human developers to transform SQL generation from a static parsing task into a dynamic hypothesis\-testing loop\. By analyzing intermediate execution feedback, the agents detect discrepancies \(e\.g\., numerical data stored as strings, non\-standard date formats, or string values in a different language\) and iteratively refine their queries with precise dialect\-specific adjustments, such as type casting or string manipulation\. It ensures the final SQL is consistent with users’ intents and the contents stored in the database\.
## 6Conclusion
We proposeDualSQL, a multi\-agent Text\-to\-SQL system optimized by a robust reinforcement learning framework\.DualSQLunifies schema linking and SQL generation as two agents powered by a single LLM backbone and a set of database access tools, enabling effective reasoning over databases and joint optimization through RL\.DualSQL\-4B reaches 68\.0% EX on BIRD\-Dev, matching prior 7B baselines, whileDualSQL\-8B sets a new single\-model state\-of\-the\-art of 71\.1% EX, surpassing methods built on 32B models\. These results demonstrate that joint multi\-agent optimization is an effective path toward stronger Text\-to\-SQL systems\.
We see three promising directions for future work: \(1\) better reward design for multi\-agent reinforcement learning, including fine\-grained process reward signals and inter\-agent credit assignment mechanisms; \(2\) scaling training data via synthesis of large\-scale databases and challenging Text\-to\-SQL questions; and \(3\) more effective multi\-agent RL recipes for training larger models and supporting longer\-horizon trajectories\.
## Limitations
Model backbone\.We instantiateDualSQLon the Qwen3 family because \(1\) it natively supports both extended reasoning and tool calling, two key capabilities our agentic formulation requires; and \(2\) it is well supported by open\-source training frameworks like VeRL\. Nevertheless, we believe our training recipe to be applicable to any backbone LLMs with these capabilities, including open\-weight and proprietary ones\.
Reward design\.REX substantially improves over EX as a reward signal, as confirmed by our ablations\. However, it is still a proxy for SQL equivalence checking and could produce false signals\. In addition, as with any outcome\-based reward function, our reward design lacks fine\-grained process\-level reward signals which could be important for training stronger Text\-to\-SQL agents in the future\.
Security\.We restrict the agents to read\-only database access throughout training and evaluation\. As with any LLM\-driven system that interfaces with live data sources, deployingDualSQLin production warrants standard precautions against query\-induced resource exhaustion and adversarial prompt injection\.
## Artifact and Data Usage
This work leverages datasets and code from previous research, including the BIRD Dataset\([Li et al\., 2023](https://arxiv.org/html/2609.18135#bib.bib3)\)\(CC BY\-SA 4\.0\), the Spider dataset\([Yu et al\., 2018](https://arxiv.org/html/2609.18135#bib.bib5)\)\(CC BY\-SA 4\.0\), code from the VeRL \(Apache 2\.0\) framework\([Sheng et al\., 2024](https://arxiv.org/html/2609.18135#bib.bib8)\), and the Qwen3 \(Apache 2\.0\) family of models\([Yang et al\., 2025a](https://arxiv.org/html/2609.18135#bib.bib45)\)\. These data, software, and models have permissive licenses for use in academic research\.
## AI Assistant Usage
The authors used AI assistants for editing and improving the language of the paper\. All presented content is reviewed by the authors\.
## References
- Biswalet al\.\(2026\)A\. Biswal, C\. Lei, X\. Qin, A\. Li, B\. Narayanaswamy, and T\. KraskaAgentSM: semantic memory for agentic text\-to\-sql\.arXiv preprint arXiv:2601\.15709\.Cited by:[§2\.1](https://arxiv.org/html/2609.18135#S2.SS1.p1.1)\.
- Chunget al\.\(2025a\)A\. Chung, Y\. Zhang, K\. Lin, A\. Rawal, Q\. Gao, and J\. ChaiEvaluating long\-context reasoning in llm\-based webagents\.arXiv preprint arXiv:2512\.04307\.Cited by:[§1](https://arxiv.org/html/2609.18135#S1.p1.1)\.
- Chunget al\.\(2025b\)Y\. Chung, G\. T\. Kakkar, Y\. Gan, B\. Milne, and F\. OzcanIs long context all you need? leveraging llm’s extended context for nl2sql\.Proc\. VLDB Endow\.18\(7\),pp\. 2735–2748\.External Links:[Link](https://doi.org/),[Document](https://dx.doi.org/10.14778/3742728.3742761)Cited by:[§2\.1](https://arxiv.org/html/2609.18135#S2.SS1.p1.1)\.
- Denget al\.\(2025\)M\. Deng, A\. Ramachandran, C\. Xu, L\. Hu, Z\. Yao, A\. Datta, and H\. ZhangReforce: a text\-to\-sql agent with self\-refinement, format restriction, and column exploration\.InICLR 2025 Workshop: VerifAI: AI Verification in the Wild,Cited by:[§2\.1](https://arxiv.org/html/2609.18135#S2.SS1.p1.1)\.
- Donget al\.\(2025\)G\. Dong, H\. Mao, K\. Ma, L\. Bao, Y\. Chen, Z\. Wang, Z\. Chen, J\. Du, H\. Wang, F\. Zhang,et al\.Agentic reinforced policy optimization\.arXiv preprint arXiv:2507\.19849\.Cited by:[§2\.2](https://arxiv.org/html/2609.18135#S2.SS2.p1.1)\.
- Duet al\.\(2025\)Y\. Du, M\. Tian, S\. Ronanki, S\. Rongali, S\. Bodapati, A\. Galstyan, A\. Wells, R\. Schwartz, E\. A\. Huerta, and H\. PengContext length alone hurts llm performance despite perfect retrieval\.arXiv preprint arXiv:2510\.05381\.Cited by:[§1](https://arxiv.org/html/2609.18135#S1.p1.1)\.
- Gaoet al\.\(2023\)D\. Gao, H\. Wang, Y\. Li, X\. Sun, Y\. Qian, B\. Ding, and J\. ZhouText\-to\-sql empowered by large language models: a benchmark evaluation\.arXiv preprint arXiv:2308\.15363\.Cited by:[§2\.1](https://arxiv.org/html/2609.18135#S2.SS1.p1.1)\.
- Guoet al\.\(2025\)D\. Guo, D\. Yang, H\. Zhang, J\. Song, R\. Zhang, R\. Xu, Q\. Zhu, S\. Ma, P\. Wang, X\. Bi,et al\.Deepseek\-r1: incentivizing reasoning capability in llms via reinforcement learning\.arXiv preprint arXiv:2501\.12948\.Cited by:[§2\.2](https://arxiv.org/html/2609.18135#S2.SS2.p1.1)\.
- Liet al\.\(2024a\)B\. Li, Y\. Luo, C\. Chai, G\. Li, and N\. TangThe dawn of natural language to sql: are we fully ready?\.arXiv preprint arXiv:2406\.01265\.Cited by:[§1](https://arxiv.org/html/2609.18135#S1.p1.1)\.
- Liet al\.\(2025\)H\. Li, S\. Wu, X\. Zhang, X\. Huang, J\. Zhang, F\. Jiang, S\. Wang, T\. Zhang, J\. Chen, R\. Shi, H\. Chen, and C\. LiOmniSQL: synthesizing high\-quality text\-to\-sql data at scale\.Proc\. VLDB Endow\.18\(11\),pp\. 4695–4709\.External Links:ISSN 2150\-8097,[Link](https://doi.org/10.14778/3749646.3749723),[Document](https://dx.doi.org/10.14778/3749646.3749723)Cited by:[§1](https://arxiv.org/html/2609.18135#S1.p2.1),[§2\.1](https://arxiv.org/html/2609.18135#S2.SS1.p1.1),[§5\.2](https://arxiv.org/html/2609.18135#S5.SS2.p1.1)\.
- Liet al\.\(2024b\)H\. Li, J\. Zhang, H\. Liu, J\. Fan, X\. Zhang, J\. Zhu, R\. Wei, H\. Pan, C\. Li, and H\. ChenCodes: towards building open\-source language models for text\-to\-sql\.Proceedings of the ACM on Management of Data2\(3\),pp\. 1–28\.Cited by:[§2\.1](https://arxiv.org/html/2609.18135#S2.SS1.p1.1)\.
- Liet al\.\(2023\)J\. Li, B\. Hui, G\. Qu, J\. Yang, B\. Li, B\. Li, B\. Wang, B\. Qin, R\. Geng, N\. Huo, X\. Zhou, C\. Ma, G\. Li, K\. C\.C\. Chang, F\. Huang, R\. Cheng, and Y\. LiCan llm already serve as a database interface? a big bench for large\-scale database grounded text\-to\-sqls\.InProceedings of the 37th International Conference on Neural Information Processing Systems,NIPS ’23,Red Hook, NY, USA\.Cited by:[Artifact and Data Usage](https://arxiv.org/html/2609.18135#Sx2.p1.1)\.
- Li \(2025\)Y\. LiMathematical formulations of rollout correction methods in verl\.External Links:[Link](https://verl.readthedocs.io/en/latest/algo/rollout_corr_math.html)Cited by:[§1](https://arxiv.org/html/2609.18135#S1.p5.1),[§4\.2](https://arxiv.org/html/2609.18135#S4.SS2.p1.1)\.
- Linget al\.\(2025\)Z\. Ling, K\. Liu, K\. Yan, Y\. Yang, W\. Lin, T\. Fan, L\. Shen, Z\. Du, and J\. ChenLongreason: a synthetic long\-context reasoning benchmark via context expansion\.arXiv preprint arXiv:2501\.15089\.Cited by:[§1](https://arxiv.org/html/2609.18135#S1.p1.1)\.
- Liuet al\.\(2025a\)J\. Liu, Y\. Li, Y\. Fu, J\. Wang, Q\. Liu, and Y\. ShenWhen speed kills stability: demystifying RL collapse from the training\-inference mismatch\.External Links:[Link](https://richardli.xyz/rl-collapse)Cited by:[§1](https://arxiv.org/html/2609.18135#S1.p5.1),[§4\.2](https://arxiv.org/html/2609.18135#S4.SS2.p1.1),[§4\.4](https://arxiv.org/html/2609.18135#S4.SS4.p1.1)\.
- Liuet al\.\(2025b\)S\. Liu, A\. Zhu, S\. Hegde, S\. Cao, S\. Yuan, S\. Suwito, T\. Griggs, M\. Zaharia, J\. E\. Gonzalez, and I\. StoicaSkyRL\-sql: multi\-turn sql data agents via rl\.InFirst Workshop on Multi\-Turn Interactions in Large Language Models \(MTI\-LLM @ NeurIPS\),Cited by:[§2\.1](https://arxiv.org/html/2609.18135#S2.SS1.p1.1)\.
- Liuet al\.\(2025c\)Y\. Liu, Y\. Zhu, Y\. Gao, Z\. Luo, X\. Li, X\. Shi, Y\. Hong, J\. Gao, Y\. Li, B\. Ding,et al\.Xiyan\-sql: a novel multi\-generator framework for text\-to\-sql\.arXiv preprint arXiv:2507\.04701\.Cited by:[§1](https://arxiv.org/html/2609.18135#S1.p2.1)\.
- Luoet al\.\(2025\)Y\. Luo, G\. Li, J\. Fan, C\. Chai, and N\. TangNatural language to sql: state of the art and open problems\.Proceedings of the VLDB Endowment18\(12\),pp\. 5466–5471\.Cited by:[§1](https://arxiv.org/html/2609.18135#S1.p1.1)\.
- Maet al\.\(2025a\)H\. Ma, Y\. Shen, H\. Liu, W\. Zhang, H\. Xu, Q\. Peng, J\. Wang, and W\. LuDB\-explore: automated database exploration and instruction synthesis for text\-to\-sql\.arXiv preprint arXiv:2503\.04959\.Cited by:[§2\.1](https://arxiv.org/html/2609.18135#S2.SS1.p1.1)\.
- Maet al\.\(2025b\)P\. Ma, X\. Zhuang, C\. Xu, X\. Jiang, R\. Chen, and J\. GuoSql\-r1: training natural language to sql reasoning model by reinforcement learning\.arXiv preprint arXiv:2504\.08600\.Cited by:[§2\.1](https://arxiv.org/html/2609.18135#S2.SS1.p1.1),[§5\.2\.1](https://arxiv.org/html/2609.18135#S5.SS2.SSS1.p1.1)\.
- Nguyenet al\.\(2025\)X\. Nguyen, S\. Pandit, R\. G\. Reddy, A\. Xu, S\. Savarese, C\. Xiong, and S\. JotySfr\-deepresearch: towards effective reinforcement learning for autonomously reasoning single agents\.arXiv preprint arXiv:2509\.06283\.Cited by:[§2\.2](https://arxiv.org/html/2609.18135#S2.SS2.p1.1)\.
- Pourrezaet al\.\(2025a\)M\. Pourreza, H\. Li, R\. Sun, Y\. Chung, S\. Talaei, G\. T\. Kakkar, Y\. Gan, A\. Saberi, F\. Ozcan, and S\. O\. ArikCHASE\-SQL: multi\-path reasoning and preference optimized candidate selection in text\-to\-SQL\.InThe Thirteenth International Conference on Learning Representations,External Links:[Link](https://openreview.net/forum?id=CvGqMD5OtX)Cited by:[§1](https://arxiv.org/html/2609.18135#S1.p2.1),[§2\.1](https://arxiv.org/html/2609.18135#S2.SS1.p1.1)\.
- Pourreza and Rafiei \(2023\)M\. Pourreza and D\. RafieiDIN\-SQL: decomposed in\-context learning of text\-to\-SQL with self\-correction\.InThirty\-seventh Conference on Neural Information Processing Systems,External Links:[Link](https://openreview.net/forum?id=p53QDxSIc5)Cited by:[§1](https://arxiv.org/html/2609.18135#S1.p2.1),[§2\.1](https://arxiv.org/html/2609.18135#S2.SS1.p1.1)\.
- Pourrezaet al\.\(2025b\)M\. Pourreza, S\. Talaei, R\. Sun, X\. Wan, H\. Li, A\. Mirhoseini, A\. Saberi, and S\. O\. ArikReasoning\-SQL: reinforcement learning with SQL tailored partial rewards for reasoning\-enhanced text\-to\-SQL\.InSecond Conference on Language Modeling,External Links:[Link](https://openreview.net/forum?id=HbwkIDWQgN)Cited by:[§1](https://arxiv.org/html/2609.18135#S1.p2.1),[§5\.2\.1](https://arxiv.org/html/2609.18135#S5.SS2.SSS1.p1.1)\.
- Shaoet al\.\(2024\)Z\. Shao, P\. Wang, Q\. Zhu, R\. Xu, J\. Song, X\. Bi, H\. Zhang, M\. Zhang, Y\. K\. Li, Y\. Wu, and D\. GuoDeepSeekMath: pushing the limits of mathematical reasoning in open language models\.External Links:2402\.03300,[Link](https://arxiv.org/abs/2402.03300)Cited by:[§2\.2](https://arxiv.org/html/2609.18135#S2.SS2.p1.1),[§4\.4](https://arxiv.org/html/2609.18135#S4.SS4.p1.1)\.
- Shenget al\.\(2024\)G\. Sheng, C\. Zhang, Z\. Ye, X\. Wu, W\. Zhang, R\. Zhang, Y\. Peng, H\. Lin, and C\. WuHybridFlow: a flexible and efficient rlhf framework\.arXiv preprint arXiv: 2409\.19256\.Cited by:[§5\.1](https://arxiv.org/html/2609.18135#S5.SS1.p2.1),[Artifact and Data Usage](https://arxiv.org/html/2609.18135#Sx2.p1.1)\.
- Shkapenyuket al\.\(2025\)V\. Shkapenyuk, D\. Srivastava, T\. Johnson, and P\. GhaneAutomatic metadata extraction for text\-to\-sql\.arXiv preprint arXiv:2505\.19988\.Cited by:[§2\.1](https://arxiv.org/html/2609.18135#S2.SS1.p1.1)\.
- Suet al\.\(2024\)A\. Su, A\. Wang, C\. Ye, C\. Zhou, G\. Zhang, G\. Chen, G\. Zhu, H\. Wang, H\. Xu, H\. Chen,et al\.Tablegpt2: a large multimodal model with tabular data integration\.arXiv preprint arXiv:2411\.02059\.Cited by:[§1](https://arxiv.org/html/2609.18135#S1.p1.1)\.
- Talaeiet al\.\(2024\)S\. Talaei, M\. Pourreza, Y\. Chang, A\. Mirhoseini, and A\. SaberiCHESS: contextual harnessing for efficient sql synthesis\.External Links:2405\.16755,[Link](https://arxiv.org/abs/2405.16755)Cited by:[§1](https://arxiv.org/html/2609.18135#S1.p2.1)\.
- Wanget al\.\(2025a\)B\. Wang, C\. Ren, J\. Yang, X\. Liang, J\. Bai, L\. Chai, Z\. Yan, Q\. Zhang, D\. Yin, X\. Sun, and Z\. LiMAC\-SQL: a multi\-agent collaborative framework for text\-to\-SQL\.InProceedings of the 31st International Conference on Computational Linguistics,Abu Dhabi, UAE,pp\. 540–557\.External Links:[Link](https://aclanthology.org/2025.coling-main.36/)Cited by:[§2\.1](https://arxiv.org/html/2609.18135#S2.SS1.p1.1)\.
- Wanget al\.\(2025b\)P\. Wang, B\. Sun, X\. Dong, Y\. Dai, H\. Yuan, M\. Chu, Y\. Gao, X\. Qi, P\. Zhang, and Y\. YanAgentar\-scale\-sql: advancing text\-to\-sql through orchestrated test\-time scaling\.arXiv preprint arXiv:2509\.24403\.Cited by:[§2\.1](https://arxiv.org/html/2609.18135#S2.SS1.p1.1)\.
- Wanget al\.\(2025c\)S\. Wang, L\. Yu, C\. Gao, C\. Zheng, S\. Liu, R\. Lu, K\. Dang, X\. Chen, J\. Yang, Z\. Zhang,et al\.Beyond the 80/20 rule: high\-entropy minority tokens drive effective reinforcement learning for llm reasoning\.arXiv preprint arXiv:2506\.01939\.Cited by:[§2\.2](https://arxiv.org/html/2609.18135#S2.SS2.p1.1)\.
- Xuet al\.\(2025a\)Y\. E\. Xu, Y\. Savani, F\. Fang, and J\. Z\. KolterNot all rollouts are useful: down\-sampling rollouts in llm reinforcement learning\.arXiv preprint arXiv:2504\.13818\.Cited by:[§2\.2](https://arxiv.org/html/2609.18135#S2.SS2.p1.1)\.
- Xuet al\.\(2025b\)Z\. Xu, S\. Xia, C\. Yue, J\. Chai, M\. Tian, X\. Wang, W\. Lin, H\. Li, and G\. YinMTIR\-sql: multi\-turn tool\-integrated reasoning reinforcement learning for text\-to\-sql\.External Links:2510\.25510,[Link](https://arxiv.org/abs/2510.25510)Cited by:[§2\.1](https://arxiv.org/html/2609.18135#S2.SS1.p1.1),[§5\.2\.1](https://arxiv.org/html/2609.18135#S5.SS2.SSS1.p1.1)\.
- Xueet al\.\(2025\)Z\. Xue, L\. Zheng, Q\. Liu, Y\. Li, X\. Zheng, Z\. Ma, and B\. AnSimpletir: end\-to\-end reinforcement learning for multi\-turn tool\-integrated reasoning\.arXiv preprint arXiv:2509\.02479\.Cited by:[§2\.2](https://arxiv.org/html/2609.18135#S2.SS2.p1.1)\.
- Yanget al\.\(2025a\)A\. Yang, A\. Li, B\. Yang, B\. Zhang, B\. Hui, B\. Zheng, B\. Yu, C\. Gao, C\. Huang, C\. Lv, C\. Zheng, D\. Liu, F\. Zhou, F\. Huang, F\. Hu, H\. Ge, H\. Wei, H\. Lin, J\. Tang, J\. Yang, J\. Tu, J\. Zhang, J\. Yang, J\. Yang, J\. Zhou, J\. Zhou, J\. Lin, K\. Dang, K\. Bao, K\. Yang, L\. Yu, L\. Deng, M\. Li, M\. Xue, M\. Li, P\. Zhang, P\. Wang, Q\. Zhu, R\. Men, R\. Gao, S\. Liu, S\. Luo, T\. Li, T\. Tang, W\. Yin, X\. Ren, X\. Wang, X\. Zhang, X\. Ren, Y\. Fan, Y\. Su, Y\. Zhang, Y\. Zhang, Y\. Wan, Y\. Liu, Z\. Wang, Z\. Cui, Z\. Zhang, Z\. Zhou, and Z\. QiuQwen3 technical report\.arXiv preprint arXiv:2505\.09388\.Cited by:[§5\.1](https://arxiv.org/html/2609.18135#S5.SS1.p2.1),[Artifact and Data Usage](https://arxiv.org/html/2609.18135#Sx2.p1.1)\.
- Yanget al\.\(2025b\)H\. Yang, J\. Zhang, Z\. He, and Y\. R\. FungMARS\-sql: a multi\-agent reinforcement learning framework for text\-to\-sql\.External Links:2511\.01008,[Link](https://arxiv.org/abs/2511.01008)Cited by:[§2\.1](https://arxiv.org/html/2609.18135#S2.SS1.p1.1)\.
- Yaoet al\.\(2025\)Z\. Yao, G\. Sun, L\. Borchmann, Z\. Shen, M\. Deng, B\. Zhai, H\. Zhang, A\. Li, and Y\. HeArctic\-text2sql\-r1: simple rewards, strong reasoning in text\-to\-sql\.External Links:2505\.20315,[Link](https://arxiv.org/abs/2505.20315)Cited by:[§1](https://arxiv.org/html/2609.18135#S1.p2.1),[§2\.1](https://arxiv.org/html/2609.18135#S2.SS1.p1.1),[§5\.2\.1](https://arxiv.org/html/2609.18135#S5.SS2.SSS1.p1.1)\.
- Yuet al\.\(2025\)Q\. Yu, Z\. Zhang, R\. Zhu, Y\. Yuan, X\. Zuo, Y\. Yue, W\. Dai, T\. Fan, G\. Liu, L\. Liu,et al\.DAPO: an open\-source LLM reinforcement learning system at scale\.InThe Thirty\-ninth Annual Conference on Neural Information Processing Systems,External Links:[Link](https://openreview.net/forum?id=2a36EMSSTp)Cited by:[§2\.2](https://arxiv.org/html/2609.18135#S2.SS2.p1.1),[§4\.4](https://arxiv.org/html/2609.18135#S4.SS4.p1.1)\.
- Yuet al\.\(2018\)T\. Yu, R\. Zhang, K\. Yang, M\. Yasunaga, D\. Wang, Z\. Li, J\. Ma, I\. Li, Q\. Yao, S\. Roman, Z\. Zhang, and D\. RadevSpider: a large\-scale human\-labeled dataset for complex and cross\-domain semantic parsing and text\-to\-SQL task\.InProceedings of the 2018 Conference on Empirical Methods in Natural Language Processing,E\. Riloff, D\. Chiang, J\. Hockenmaier, and J\. Tsujii \(Eds\.\),Brussels, Belgium,pp\. 3911–3921\.External Links:[Link](https://aclanthology.org/D18-1425/),[Document](https://dx.doi.org/10.18653/v1/D18-1425)Cited by:[§5\.2\.2](https://arxiv.org/html/2609.18135#S5.SS2.SSS2.p1.1),[Artifact and Data Usage](https://arxiv.org/html/2609.18135#Sx2.p1.1)\.
- Zhanget al\.\(2025a\)J\. Zhang, H\. Zhang, R\. Chakravarti, Y\. Hu, P\. Ng, A\. Katsifodimos, H\. Rangwala, G\. Karypis, and A\. HalevyCoddLLM: empowering large language models for data analytics\.arXiv preprint arXiv:2502\.00329\.Cited by:[§1](https://arxiv.org/html/2609.18135#S1.p1.1)\.
- Zhanget al\.\(2025b\)Q\. Zhang, D\. Wang, H\. Qian, Y\. Li, T\. Zhang, M\. Huang, K\. Xu, H\. Li, L\. Yan, and H\. QiuUnderstanding the dark side of llms’ intrinsic self\-correction\.InProceedings of the 63rd Annual Meeting of the Association for Computational Linguistics \(Volume 1: Long Papers\),pp\. 27066–27101\.Cited by:[§5\.2\.4](https://arxiv.org/html/2609.18135#S5.SS2.SSS4.p3.1)\.
- Zhanget al\.\(2025c\)Y\. Zhang, M\. Fan, J\. Fan, M\. Yi, Y\. Luo, J\. Tan, and G\. LiReward\-sql: boosting text\-to\-sql via stepwise reasoning and process\-supervised rewards\.arXiv preprint arXiv:2505\.04671\.Cited by:[§2\.1](https://arxiv.org/html/2609.18135#S2.SS1.p1.1)\.
- Zhenget al\.\(2025a\)C\. Zheng, K\. Dang, B\. Yu, M\. Li, H\. Jiang, J\. Lin, Y\. Liu, H\. Lin, C\. Wu, F\. Hu,et al\.Stabilizing reinforcement learning with llms: formulation and practices\.arXiv preprint arXiv:2512\.01374\.Cited by:[§1](https://arxiv.org/html/2609.18135#S1.p5.1)\.
- Zhenget al\.\(2025b\)T\. Zheng, H\. Zhang, W\. Yu, X\. Wang, R\. Dai, R\. Liu, H\. Bao, C\. Huang, H\. Huang, and D\. YuParallel\-r1: towards parallel thinking via reinforcement learning\.arXiv preprint arXiv:2509\.07980\.Cited by:[§2\.2](https://arxiv.org/html/2609.18135#S2.SS2.p1.1)\.
## Appendix AMore Tool Implementation Details
To optimize the model’s consumption of tool results, we serialize all tool results using theJSONformat, minimizing the distribution gap between tool results and the model’s pre\-training data\. We further host the tools as an independent asynchronous web service, isolating the high latency of database operations from the GPU\-intensive LLM inference process so that database access does not bottleneck GPU utilization during rollout\.
SQL Executor\.The tool returns query results as row objects\. To prevent retrieved data from exceeding context window limits, we implement a content\-aware truncation strategy: for regular SQL queries, output is restricted to a maximum of 10 rows and overlong cell values \(\>150 characters\) are truncated; for schema\-related queries \(e\.g\.,sqlite\_masterorPRAGMA\), the tool preserves the full result set to ensure the agent maintains accurate and complete knowledge of the database structure\.
Full Text Search\.Databases may contain hundreds of tables and millions of rows, making embedding\-based semantic matching expensive to deploy\. We instead leverage the SQLite FTS5 extension to construct inverted indices over schema names and database contents, facilitating low\-latency fuzzy matching\. The tool returns a structured context containing the matched schema elements and up to five distinct matched values per column\.
Database Profiler\.For each table and column, we prompt an LLM offline to generate a description summarizing semantic intent and to infer foreign\-key relationships that may not be formally defined in the DDL\. The profiler also computes column\-level statistics including distinct value counts, data types, and null\-value ratios\. By precomputing these static features applicable to all queries, the tool offloads complex schema analysis from the runtime reasoning process, so the agent can focus on query logic rather than schema interpretation\.
Train Robust Execution Match \(REX\)
Figure 3:Training robust execution match ofDualSQLsql\\textit\{DualSQL\}\_\{sql\}\-8B \(single\-agent\) andDualSQL\-8B \(multi\-agent\)\.
## Appendix BMore Training Details
We trainDualSQL\-4B for 100 steps\. The training forDualSQL\-8B takes 300 steps, taking about 4\.5 days on a 4\-node compute cluster, with 8 H100 80GB GPUs per node\.
We compare the Robust Execution Match during training for the single\-agentDualSQLsql\\textit\{DualSQL\}\_\{sql\}\-8B and multi\-agentDualSQL\-8B in Fig\.[3](https://arxiv.org/html/2609.18135#A1.F3)\. AlthoughDualSQL\-8B starts a little worse due to limited initial schema linking accuracy, it catches up and consistently outperformsDualSQLsql\\textit\{DualSQL\}\_\{sql\}\-8B in the rest of the training process, demonstrating the effectiveness of our multi\-agent framework\.
## Appendix CPerformance Breakdown by Difficulty
Table 7:Performance on BIRD\-Dev by question difficulty\. We report average execution match\.∗We evaluate the released checkpoints of Arctic\-text2sql\-R1 7B for per\-difficulty performance\. SQL\-R1 and OmniSQL performance are taken from their publications\.We break down the performance ofDualSQLby difficulty in Table[7](https://arxiv.org/html/2609.18135#A3.T7)\. Compared withDualSQLsql\\textit\{DualSQL\}\_\{sql\}, which is trained only on the SQL generation task with the same recipe, our multi\-agent formulation brings performance improvements at all difficulty levels, with the most significant improvement on challenging questions \(3\.0% EX for the 8B model\)\.
Table 8:Average number of tools used on BIRD\-Dev and overall performance\.
## Appendix DAblation on Tools
We conduct an ablation study to evaluate the impact of each tool on the performance ofDualSQL\-8B on BIRD\-Dev\. On the BIRD\-Dev dataset, we evaluate theDualSQL\-8B model, which is trained with all three tools, and disable each tool one at a time\. We report the average number of tool calls and overall performance in Table[8](https://arxiv.org/html/2609.18135#A3.T8)\.
The results demonstrate that each tool contributes positively to the overall performance\. AlthoughDualSQLis able to compensate for the missing tool by increasing the usage of other tools, the removal of any tool results in a performance drop, especially for SQL generation\. The SQL execution tool has the most significant impact when removed\. Without the ability to execute SQL queries and iteratively refine its solutions, the agents suffer a 2\.5% drop in EX and a massive 6\.8% drop in REX during the SQL generation stage\.
## Appendix ERobust Execution Match
This algorithm computes a similarity score between a ground truth dataframe \(GG\) and a sample dataframe \(SS\)\. Equivalence is determined byscore=1\.0score=1\.0\. The behavior is primarily controlled by a user\-defined boolean,strict\_row\_ordering\. If columns do not match by name, then they are matched by content using a standard Linear Sum Assignment Problem solver \(LSAP\) as a subroutine\. If the sample dataframe contains more columns/rows than the ground truth, then a proportional penalty is applied\. Type differences are handled flexibly\.
Algorithm 1Robust Execution Match0:
GG,
SS; parameterstrict\_row\_ordering
1:ifNOTstrict\_row\_orderingAND
max\(\|Gcols\|,\|Scols\|\)\>4\\max\(\|G\_\{cols\}\|,\|S\_\{cols\}\|\)\>4then
2:// Heuristic for wide dataframes
3:Select
KkeyK\_\{key\}columns from
GGwith highest cardinality \(1 or 2 columns depending on
\|Scols\|\|S\_\{cols\}\|\)
4:Align
G\[Kkey\]G\[K\_\{key\}\]and
SSusing exact matching \(line 14\), yielding row map
πrows\\pi\_\{rows\}
5:Reorder
GGand
SSbased on
πrows\\pi\_\{rows\}
6:strict\_row\_ordering
←\\leftarrowTrue// proceed to strict row logic
7:go to line 10
8:endif
9:Identify common columns
KcommonK\_\{common\}and unmatched
KugK\_\{u\_\{g\}\}\(in
GG\),
KusK\_\{u\_\{s\}\}\(in
SS\)
10:ifstrict\_row\_orderingthen
11:Score similarity of
G\[Kcommon\]G\[K\_\{common\}\]and
S\[Kcommon\]S\[K\_\{common\}\]via element\-wise comparison
12:Match
Kug,KusK\_\{u\_\{g\}\},K\_\{u\_\{s\}\}using LSAP to maximize column similarity, yielding
πcols\\pi\_\{cols\}
13:Combine scores from common and best\-matched unmatched columns
14:else
15:// Loose row ordering, exact matching
16:if
Kcommon≠∅K\_\{common\}\\neq\\emptysetthen
17:Match rows of
G\[Kcommon\]G\[K\_\{common\}\]and
S\[Kcommon\]S\[K\_\{common\}\]to find permutation
πrows\\pi\_\{rows\}using LSAP
18:Calculate score for
KcommonK\_\{common\}based on this alignment
19:Reorder
G\[Kug\]G\[K\_\{u\_\{g\}\}\]and
S\[Kus\]S\[K\_\{u\_\{s\}\}\]according to
πrows\\pi\_\{rows\}
20:Match reordered
Kug,KusK\_\{u\_\{g\}\},K\_\{u\_\{s\}\}using column LSAP, yielding
πcols\\pi\_\{cols\}
21:Combine scores
22:else
23:// No common columns
24:Fallback:iterate column permutations of
SSwith
GG
25:For each permutation, find optimal row alignment
πrows\\pi\_\{rows\}using LSAP
26:Keep permutation yielding maximum total similarity
27:endif
28:endif
29:Calculate final score, normalized by
\|Gcols\|\|G\_\{cols\}\|
30:Apply penalty: score
←\\leftarrowscore
×\|Gcols\|max\(\|Gcols\|,\|Scols\|\)\\times\\frac\{\|G\_\{cols\}\|\}\{\\max\(\|G\_\{cols\}\|,\|S\_\{cols\}\|\)\}
31:Apply penalty: score
←\\leftarrowscore
×\|Grows\|max\(\|Grows\|,\|Srows\|\)\\times\\frac\{\|G\_\{rows\}\|\}\{\\max\(\|G\_\{rows\}\|,\|S\_\{rows\}\|\)\}
32:returnscore
### Complexity Analysis Notes
LetNNbe the number of rows andMMbe the number of columns\.
#### Strict Row Ordering
- •Element\-wise scores:O\(N⋅M\)O\(N\\cdot M\)\.
- •Unmatched Column Matching \(LSAP\): Score matrixO\(M2⋅N\)O\(M^\{2\}\\cdot N\), LSAP solutionO\(M3\)O\(M^\{3\}\)\.
- •Total Complexity:O\(N⋅M2\)O\(N\\cdot M^\{2\}\)\.
#### Loose Row Ordering
- •Heuristic \(M\>4M\>4\): - –Row alignment onKkeyK\_\{key\}\(LSAP\):O\(N2⋅\|Kkey\|\+N3\)≈O\(N3\)O\(N^\{2\}\\cdot\|K\_\{key\}\|\+N^\{3\}\)\\approx O\(N^\{3\}\)\. - –Column Matching phase:O\(N⋅M2\)O\(N\\cdot M^\{2\}\)\. - –Total:O\(N3\+N⋅M2\)O\(N^\{3\}\+N\\cdot M^\{2\}\)\.
- •Exact \(M≤4M\\leq 4, With Common Columns\): - –Row alignment onKcommonK\_\{common\}\(LSAP\):O\(N2⋅M\+N3\)O\(N^\{2\}\\cdot M\+N^\{3\}\)\. - –Column matching onKuK\_\{u\}\(LSAP\):O\(M2⋅N\)O\(M^\{2\}\\cdot N\)\. - –Total:O\(N3\+N2⋅M\)O\(N^\{3\}\+N^\{2\}\\cdot M\)\.
- •Exact \(M≤4M\\leq 4, No Common Columns\): - –Column Permutations×\\timesRow LSAP:O\(M\!⋅\(N2⋅M\+N3\)\)O\(M\!\\cdot\(N^\{2\}\\cdot M\+N^\{3\}\)\)\. - –Total:O\(M\!⋅\(N3\+N2⋅M\)\)O\(M\!\\cdot\(N^\{3\}\+N^\{2\}\\cdot M\)\)\.
## Appendix FPrompts
### F\.1Schema Linking Agent Prompt
Figure[4](https://arxiv.org/html/2609.18135#A6.F4)and[5](https://arxiv.org/html/2609.18135#A6.F5)show the system and user prompts for the Schema Linking Agent\.
System Prompt for the Schema Linking AgentYou are a senior data scientist\. Below, you are provided with a set of database access tools, a database schema and a question from users\. Your task is to understand the schema and identify the tables and columns that are useful for constructing a SQL query to answer the question\.
Recall your expertise as a data science expert and solve the question professionally\. Your reasoning should be creative and rigorous\. Be sure to make good use of the available tools\.
Key Requirements:
\- Prioritize coverage but also be mindful about precision\. Your results will be used by downstream processes\. Therefore, be as accurate as possible to avoid cascading failure\.
\- You have access to a few tools that can help you explore the schema and data\. Use them wisely to your advantage\.
Database Engine: SQLiteFigure 4:System Prompt for Schema Linking AgentUser Prompt for Schema Linking AgentDatabase Schema: \{schema\}
Question: \{question\}
Hints: \{hints\}
\# Instructions: In each assistant turn, follow these steps to ensure effective and accurate problem\-solving:
\#\# Step 1: Reasoning
In each assistant turn, you should start your reasoning with the<think\>tag, carefully reason about the problem, and end your reasoning with the</think\>tag\.
\#\# Step 2 Action
After your reasoning, briefly summarize your thought process\. The summary will be visible to the user, therefore, make it concise and clear\. Then you should choose to either call tools \(2\.a\) to assist your reasoning, or conclude the conversation with your identified tables and columns \(2\.b\)\. Show and explain your decision clearly in your response\.\#\# Step 2\.a: Call a tool You can choose to call any of the provided tools\. The execution result of each tool call will be returned to you in the next user turn, wrapped within<tool\_response\></tool\_response\>tags\. Use this information to inform your next steps\.
\#\# Step 2\.b: Submit linked schema When you are confident with your solution, end the conversation with a brief summary of your entire thought process and validation effort, then wrap your solution in a JSON code block\. The identified tables should be the key, and the columns should be the values\. e\.g\. ‘‘‘json \{"table1":\["column1", "column2"\],"table2":\["column1"\]\} ‘‘‘ Keep in mind that you have up to five turns to figure out the solution\. Let’s work this out turn\-by\-turn and find the correct schema to use\.
Figure 5:User Prompt Template for Schema Linking Agent
### F\.2SQL Generation Agent Prompt
Figure[6](https://arxiv.org/html/2609.18135#A6.F6)and[7](https://arxiv.org/html/2609.18135#A6.F7)show the system and user prompts for the SQL Generation Agent\.
System Prompt for the SQL Generation AgentYou are a senior data scientist\. Below, you are provided with a set of database access tools, a database schema and a question from users\. Your task is to understand the schema and compose a SQL query to answer the question with the help of the tools\.Recall your expertise as a data science expert and solve the question professionally\. Your reasoning should be creative and rigorous\. Be sure to make good use of the available tools\.
Key Requirements: \- You must validate the correctness of your SQL solution by executing it at least once using the‘execute\_sql‘tool and checking whether the execution result matches your expectation\. Missing this step renders your solution invalid\. \- Make sure your SQL solution only returns the information asked in the question\. If the question asks for a specific column, make sure to only include that column in the SELECT clause, nothing more\. \- The final SQL query should return all of the information asked in the question without any missing or extra information\. \- Before generating the final SQL query, please think through the steps of how to write the query\. \- The tools are idempotent\. You do not need to call the same tool with the same arguments more than once\. Repeated calls are not encouraged\.
Database Engine: SQLiteFigure 6:System Prompt for SQL Generation AgentUser Prompt for the SQL Generation AgentDatabase Schema: schemaQuestion: question Hints: hints\# Instructions:
In each assistant turn, follow these steps to ensure effective and accurate problem\-solving:
\#\# Step 1: Reasoning
In each assistant turn, you should start your reasoning with the<think\>tag, carefully reason about the problem, and end your reasoning with the</think\>tag\.
\#\# Reasoning Guidelines:
\- Avoid hardcoded values in your SQL query as much as possible\. Instead, compose useful auxiliary queries into your final solution\.
\- Be especially careful for absent values \(NULLs\) in the databases\. Its impact can be subtle and indirect\. But that does not mean you need to always handle NULLs explicitly in your SQL query\.
\- Importantly, you have the privilege to use tools to your advantage\. Think carefully how the available tools can help you in your reasoning\. When in doubt, use the tools to verify\.
\#\# Step 2 Action
After your reasoning, briefly summarize your thought process\. The summary will be visible to the user, therefore, make it concise and clear\. Then you should choose to either call tools \(2\.a\) to assist your reasoning, or conclude the conversation with your SQL solution \(2\.b\)\. Show and explain your decision clearly in your response\.
\#\# Step 2\.a: Call a tool
You can choose to call any of the provided tools\. The execution result of each tool call will be returned to you in the next user turn, wrapped within<tool\_response\></tool\_response\>tags\. Use this information to inform your next steps\.
\#\# Step 2\.b: Submit SQL solution
When you are confident with your solution, end the conversation with a brief summary of your entire thought process and validation effort, then wrap your SQL solution in a code block,
e\.g\.
‘‘‘sql
SELECT \* FROM table1;
‘‘‘Keep in mind that you have up to ten turns to figure out the solution\. Let’s work this out turn\-by\-turn and find the correct SQL query\.
Keep in mind that you have up to five turns to figure out the solution\. Let’s work this out turn\-by\-turn and find the correct schema to use\.Figure 7:User Prompt for the SQL Generation Agent
## Appendix GExample Agent Trajectories and Reasoning Patterns
In this section, we showcase the reasoning patterns that emerged through the agents’ RL training\.
### G\.1Schema Linking Agent
As illustrated in Figure[8](https://arxiv.org/html/2609.18135#A7.F8), the Schema Linking agent learns to actively ground its selection process through database profiling rather than relying on zero\-shot assumptions\. When faced with specific formatting requirements or ambiguous column names, the agent utilizes thedatabase\_profilertool to inspect actual data samples and column descriptions \(e\.g\., verifying date formats\)\. This ensures the semantic correctness of the chosen tables before proceeding\.
Furthermore, Figure[9](https://arxiv.org/html/2609.18135#A7.F9)demonstrates a more sophisticated, multi\-tool dynamic verification strategy\. In this trajectory, the agent sequentially chains multiple tools to adaptively prune the schema: it employsfull\_text\_searchto locate relevant tables based on keywords, profiles the data to confirm formats, and executes exploratory queries viaexecute\_sqlto empirically validate table joins \(e\.g\., checking for overlapping entity IDs between tables\)\. Together, these emergent reasoning patterns highlight the agent’s ability to iteratively gather evidence and construct a highly reliable schema for downstream SQL generation\.
### G\.2SQL Generation Agent
For the SQL Generation agent, we observe a strong tendency toward a minimal output strategy, as depicted in Figure[10](https://arxiv.org/html/2609.18135#A7.F10)\. Rather than generating verbose queries that return extraneous columns or intermediate calculations, the agent carefully aligns its SQL logic with the exact semantic intent of the user’s question\. For instance, when asked to identify which of two players is older, the agent explicitly reasons that the final output should only be a single name\. It subsequently formulates a query utilizing anORDER BYclause combined withLIMIT 1to extract precisely the requested entity\. This behavior indicates that the agent has learned to synthesize highly targeted queries that directly answer the prompt without requiring further human interpretation of the result set\.
Furthermore, the agent exhibits advanced iterative debugging capabilities and an awareness of database\-specific nuances, as illustrated in Figure[11](https://arxiv.org/html/2609.18135#A7.F11)\. In this trajectory, the agent’s initial query execution unexpectedly yieldsNULLvalues\. Instead of halting or blindly guessing a fix, the agent systematically hypothesizes potential mathematical and dialect\-specific causes—such as division by zero or SQLite’s default handling of integer division\. By dynamically reasoning about the underlying database engine’s mechanics, the agent actively corrects its query by applying theCAST\(\.\.\. AS REAL\)function to prevent integer truncation\. This demonstrates how the RL training framework enables the agent to utilize execution feedback not just to fix syntax errors, but to resolve subtle, data\-dependent semantic edge cases\.
Schema Linking Trajectory: Grounding via Database ProfilingUser Prompt:Schema: customers, gasstations, products, transactions\_1k, yearmonth
Question: For all the people who paid more than 29\.00 per unit of product id No\.5\. Give their consumption status in the August of 2012\.
Hints: Date value = ’201208’; Price per unit = Price / Amount
\# Instructions: Identify relevant tables/columns\. Use tools to verify semantics\. Max 5 turns\.Agent Reasoning:<think\>
\[…\] The transactions table probably has the Price and Amount\. The consumption status is likely in theyearmonthtable\. \[…\]Importantly, you have the privilege to use tools to your advantage\. Think carefully how the available tools can help you in your reasoning\. When in doubt, use the tools to verify\.I need to confirm thatyearmonth\.Datefollows the ’YYYYMM’ format and check the nature of theConsumptioncolumn\.</think\>
Action:database\_profiler\(table\_and\_column\_names=\[\.\.\.\]\)Tool Call & Response:yearmonth: "Records monthly consumption data \.\.\. Date in ’YYYYMM’ format\."
transactions\_1k: "Amount column likely represents quantity \(e\.g\., liters\)\.\.\."
Result: \{’yearmonth’: \{’Date’: \{’samples’: \[’201208’, ’201201’\]\}, \.\.\.\}\}Agent Reasoning:<think\>The profiler confirmed that yearmonth\.Date is indeed ’YYYYMM’ and that Consumption is the metric to report\.Joiningtransactions\_1kandyearmonthonCustomerIDis sufficient\.</think\>
‘‘‘json
\{"transactions\_1k": \["CustomerID", "ProductID", "Price", "Amount"\],
"yearmonth": \["CustomerID", "Date", "Consumption"\]
\}‘‘‘Figure 8:Trajectory illustrating the agent’s use ofdatabase\_profilerfor schema linking\. Instead of guessing column formats, it learns to inspect data samples and descriptions, ensuring the final linked schema is sound for the subsequent SQL generation step\.Schema Linking Trajectory: Multi\-Tool Dynamic VerificationUser Prompt:Question: Give the consumption status in August 2012 for people paying \> 29\.00/unit for product 5\.
Hint: August 2012 = ’201208’; Price per unit = Price / Amount
\# Instructions: Identify and link relevant tables/columns\. Use tools \(FTS, Profiler, SQL\) to verify\.Agent Reasoning:<think\>
I need to find where "consumption" is stored\. I will usefull\_text\_searchto scan the database descriptions for this keyword\.</think\>
Action \(FTS\):full\_text\_search\(keyword="consumption"\)
Result:"Table ’yearmonth’ found: records monthly consumption data\.\.\."Agent Reasoning:<think\>
Now I need to confirm the Date format in ’yearmonth’ and check if ’Amount’ in ’transactions\_1k’ means quantity\.I’ll use the profiler to get samples\.</think\>
Action \(Profiler\):database\_profiler\(tables=\["yearmonth", "transactions\_1k"\]\)
Result:yearmonth\.Date samples: \[’201208’, ’201201’\]; Amount is described as "quantity \(liters\)"\.Agent Reasoning:<think\>
Final check: verify if ’CustomerID’ exists in both tables to ensure a valid join\.I’ll run a small query to check for overlapping IDs\.</think\>
Action \(SQL\):execute\_sql\(query="SELECT count\(\*\) FROM transactions\_1k t JOIN yearmonth y ON t\.CustomerID = y\.CustomerID"\)
Result:\["count\(\*\)": 842\]Final Schema Submission \(JSON\):‘‘‘json
\{"transactions\_1k": \["CustomerID", "ProductID", "Price", "Amount"\],
"yearmonth": \["CustomerID", "Date", "Consumption"\]\}
‘‘‘Figure 9:Schema Linking trajectory for adaptive schema pruning based on tool calling responses fromFull\-Text Search,Database Profiler, andExecute SQL\.SQL Generation Reasoning Trajectory: Minimal Output StrategyUser Prompt:Database Schema:
CREATE TABLE Player \(player\_name text, birthday text\);
Question: Which player is older, Aaron Lennon or Abdelaziz Barrada?
Hints: The larger the birthday value, the younger the person is\.\.\.
\[Agent Instructions for Step 1 \(Reasoning\) and Step 2 \(Action\) included in prompt…\]Agent Reasoning:<think\>
\[…\] The user wants to know which is older\. So the SQL should return the name of the older player\.Maybe selecting player\_name \[…\] order by birthday asc\. Then take the first result\. But the user wants to know which is older\. So the SQL should return the name of the older player\. \[…\] So the query would be:SELECT player\_name FROM Player WHERE player\_name IN \(’Aaron Lennon’, ’Abdelaziz Barrada’\) ORDER BY birthday ASC LIMIT 1;
Wait, but the user’s question is to return which is older\. So if the query returns one name, that’s the answer\.</think\>Tool Call & Response:Query: SELECT player\_name FROM Player \.\.\. ORDER BY birthday ASC LIMIT 1;
Result: \[\{’player\_name’: ’Aaron Lennon’\}\]Figure 10:SQL Generation trajectory showing the agent’s decision\-making process to ensure the SQL output is minimal, just answering what the user asked for usingLIMIT 1\.SQL Generation Reasoning Trajectory: Cast to avoid NullUser Prompt:Database Schema:
CREATE TABLE frpm \(
‘Educational Option Type‘ text, \-\- \[’Continuation School’, \.\.\.\]
‘Enrollment \(Ages 5\-17\)‘ real,
‘Free Meal Count \(Ages 5\-17\)‘ real \);
Question: Please list the lowest three eligible free rates for students aged 5\-17 in continuation schools\.
Hints: Rate = ‘Free Meal Count‘ / ‘Enrollment‘
\# Instructions: Follow Step 1 \(Reasoning in <think\> tags\) and Step 2 \(Action: Tool call or Submit SQL\)\. Max 10 turns\.Agent Reasoning:<think\>
\[…\] Maybe the problem is that some rows have zero enrollment, leading to division by zero\. Let’s check if enrollment is zero\. \[…\] Let me adjust the query to add aWHEREclause for enrollment not being zero\.</think\>Tool Call & Response:Query: SELECT ‘Free Meal Count‘ / ‘Enrollment‘ AS rate FROM \.\.\.
Result: \[\{’eligible\_rate’: None\}, \{’eligible\_rate’: None\}\]Agent Reasoning:<think\>
Hmm, the result is still all NULLs\. That’s not right\. \[…\] Wait, maybe the division is not being computed correctly\.Wait, in SQLite, if the division is between integers, it would do integer division\. But the schema says they are real\. Maybe the data is stored as integers, but the division is not working as expected\. So maybe the correct way is to cast them as real\.So, perhaps the query should be:SELECT CAST\(count AS REAL\) / CAST\(enrollment AS REAL\)\.\.\.Let me check the actual values for these rows first\.</think\>Figure 11:SQL Generation trajectory showing the agent identifying an integer division issue in SQLite through iterative tool use and reasoning\.Similar Articles
SERL-SQL: Selective Hindsight Distillation for Text-to-SQL Reinforcement Agentic Learning
SERL-SQL proposes a selective execution-grounded reinforcement learning framework for multi-turn Text-to-SQL agents, using teacher-student likelihood gaps to reweight GRPO advantages on SQL action tokens. It achieves strong results on BIRD and Spider benchmarks.
Learning to Retrieve: Dual-Level Long-Term Memory for Text-to-SQL Agents
This paper proposes MERIT, a dynamic multi-horizon memory retrieval framework for interactive text-to-SQL agents that uses episode-level and turn-level memory with learned retrieval policies optimized via reinforcement learning and a process reward model for dense rewards. Experiments on BIRD-Interact and Spider2-Snow show that MERIT outperforms static and single-horizon dynamic baselines in success rate while requiring fewer interaction turns.
Progress-SQL: Improving Reinforcement Learning for Text-to-SQL via Progressive Rewards
Progress-SQL introduces a multi-turn reinforcement learning framework with progressive rewards for Text-to-SQL, using an Oracle-guided Diagnostic Tree to provide dense reward signals and improve SQL query generation on benchmarks like BIRD and Spider.
SQuaD-SQL: Efficient Text-to-SQL with Small Language Models via LLM-Guided Knowledge Distillation
SQuaD-SQL uses LLM-guided knowledge distillation to train small language models for Text-to-SQL, achieving 86.9% execution accuracy on WikiSQL while offering faster inference and lower memory usage.
AgentNLQ: A General-Purpose Agent for Natural Language to SQL
This paper presents AgentNLQ, a multi-agent system for natural language to SQL conversion that achieves 78.1% semantic accuracy on the BIRD benchmark through schema enrichment and a self-correcting orchestrator.