Text-to-SQL systems let users without programming expertise query relational databases in natural language. Reinforcement learning has become the dominant way to train such systems, yet progress is still judged by a single number, execution accuracy, which counts correct queries but says nothing about which kinds of semantic error survive training. This paper develops a theoretical framework that examines text-to-SQL from the perspective of reward design. We introduce Reward Error Sensitivity, a measure of how strongly a reward function separates queries that contain a given error type from queries that do not, and prove a Reward Blindness theorem: when this sensitivity is zero, policy-gradient training carries no systematic signal for removing that error. Using fourteen published finegrained error signals for four text-to-SQL systems on the BIRD benchmark, we build error profiles and estimate sensitivities for common reward designs. Predicate and result-level errors are the most frequent, firing on up to 27 percent of queries, while structurally deep errors such as suboptimal joins persist at 5 to 12 percent. Each reward family has a distinct and predictable set of blind spots, and inexpensive database-level checks that need no language model calls detect 45 to 60 percent of semantic errors. Controlled training simulations confirm that executiononly reward leaves output-preserving errors untouched, whereas a signal-grounded reward removes them even when the detectors are noisy.
Figures & tables
Fig. 1: RES framework. Error types present in a generated query influence learning only through the reward; RES measures how much of each error type survives this filtering.
Reward design
ejoin
epred
eschema
eevid
estruct
Execution-only [ 2 ]
M
M
M
M
0/L
+ N-gram similarity
M
M+
M
L
0/L
+ Schema linking
M
M
M+
L
0/L
+ LLM-as-judge
M+
M+
M+
M+
L
Composite [ 3 ]
M+
M+
M+
M
L
Graph matching [ 4 ]
H
L
M
0
M
TABLE I: Theoretical RES Profiles. H = High, M = Medium, L = Low, 0 = Provably Blind on the Output-Preserving Subset
System
Pipeline
Acc.
# Incorrect
# Semantic
Vanilla
Zero-shot
59.07%
684
589
DIN-SQL [ 8 ]
Decomposed prompting
39.49%
989
835
MAC-SQL
Multi-agent
60.04%
631
601
CHESS
Context-harnessed
67.91%
497
490
TABLE II: Systems Analysed (Statistics From SQLENS [ 1 ] , Table 8)
Error signal
Type
Van.
DIN
MAC
CHE
Join errors
Suboptimal Join Tree
DB
11.9
11.5
6.4
5.1
Incorrect Join Pred.
DB
0.7
0.1
0.9
0.1
Predicate errors
Empty Predicate
DB
5.3
26.5
4.0
4.2
Value Ambiguity
DB
5.1
4.8
3.5
4.7
TABLE III: Error Signal Frequency (%) on BIRD-dev. Bold: Highest per Row; “–”: No Detections
Reward design
ejoin
epred
esch
eevid
estr
Execution-only
0.31
0.52
0.35
0.28
0.08
Composite partial
0.34
0.55
0.48
0.32
0.10
DB-signal (ours)
0.87
0.81
0.73
–
0.87
Full signal (ours)
0.87
0.81
0.81
0.87
0.87
DB-signal omits the LLM-based evidence signals (“–”).
TABLE IV: Estimated RES on BIRD-dev Using ( 7 ). Higher Means Stronger Differentiation
Error signal
RES
DIN → CHESS
Reduction
Empty Predicate
0.52
26.5% → 4.2%
84.2%
Abnormal Result
0.50
20.2% → 4.3%
78.7%
Suboptimal Join
0.31
11.5% → 5.1%
55.7%
Value Ambiguity
0.31
4.8% → 4.7%
2.1%
Incorrect GROUP BY
0.08
4.2% → 0.1%
97.6%
Spearman ρ=0.95 without GROUP BY ( n=4 , exact permutation p=0.083 ); ρ=−0.05 with all five. Descriptive only.
TABLE V: Signal-Level RES Versus Error Reduction From DIN-SQL to CHESS
Fig. 2: Share of category-level signal firings per system, computed from Table III (LLM reasoning signals excluded). From DIN-SQL to CHESS the join and schema shares rise while the evidence and structural shares fall.
Reward
corr( A,epred )
corr( A,ejoin )
Silent-join gap
Execution-only
−0.77
−0.17
+0.00
Signal-grounded
−0.78
−0.37
−0.79
Signal-grounded, noisy
−0.72
−0.30
−0.53
Silent-join gap: mean advantage of output-preserving join errors minus that of error-free queries.
TABLE VI: GRPO Advantage Analysis (Mean Over 20 Seeds; All Standard Deviations ≤ 0.03)
Fig. 3: Join error rate under GRPO training (mean of 10 seeds). Execution reward cannot reduce output-preserving join errors and reduces partly visible ones slowly; signal-grounded reward reduces them quickly even with noisy detectors.
Signal family
Signals
Cost/query
LLM calls
Coverage
DB-only
9
∼ 30 ms
0
45.5–59.6%
LLM-only
5
∼ 500 ms
1
19.2–29.6%
Combined
14
∼ 530 ms
1
64.7–89.2%
TABLE VII: Cost–Coverage Trade-Off of Signal Families
Reinforcement learning (RL) for text-to-SQL agents pays a query when its result matches the reference on one database. However, a wrong query can match by luck when the data lack the rows that expose its bug. We study a counterfactual-database (CF) reward that also runs the final query on a few hidden, code-generated copies of the database and pays only if all results match (strict form) or by the share matched (mean form). On 1,302 synthetic audit questions, the strict form lowers the share of buggy queries paid in full from 29.5% to 16.8% and of reward hacks from 54.1% to 1.9%, rejecting 0 of 2,847 correct queries; copies from a family-blind generator do about as well. In a controlled GRPO comparison on a 3.35B model with three seeds per arm, training on the mean form did not improve in-domain accuracy (8.4% vs 11.7%), because the two rewards disagreed on only 5-7% of rollouts; on Spider it gained 1.6 points. One seed reverses both signs, so single-seed reward comparisons mislead. Code: https://github.com/RishiiGamer2201/counterfactual-sql-rewards ; data, models, demo: https://huggingface.co/counterfactual-sql
Shreshth Rai, Rishii Kumar Singh, Aksh Aggarwal
Artificial Intelligence and Machine Learning Society (AIMS-DTU) Delhi Technological University, New Delhi, India
Reinforcement learning has recently shown promise in improving large language models for Text-to-SQL generation, yet existing methods typically optimize one-shot rewards defined over a single SQL state. Such rewards provide limited guidance for iterative SQL correction and are insufficient to capture the improvement of multi-turn SQL refinement. In this paper, we propose Progress-SQL, a multi-turn reinforcement learning framework with progressive rewards for Text-to-SQL. Our approach introduces an Oracle-guided Diagnostic Tree (ODT), which abstracts SQL queries into clause-level structural profiles and produces diagnostic feedback for next-turn refinement. To provide dense and robust reward signals, we combine ODT-based structural alignment with lexical alignment and define a progressive reward that measures the improvement from the initial SQL to the final SQL. We further incorporate a progression latency reward that favors earlier correctness and an execution status reward that encourages recovery from the invalid SQL. Experiments on BIRD, Spider, and Spider robustness variants demonstrate that our method consistently improves Text-to-SQL performance across both primary and robustness evaluations.
Recent work has shown that reinforcement learning from execution feedback can substantially improve text-to-SQL performance, often enabling smaller models to match or exceed much larger systems. However, most existing approaches treat SQL generation as a single-turn task, limiting the model's ability to recover from errors through iterative refinement. We present ReToolSQL, a two-stage training framework for text-to-SQL that combines (i) a supervised warm-start on rejection-sampled reasoning traces with (ii) agentic reinforcement fine-tuning (RFT) over multi-turn tool-use trajectories. The key insight is that the two stages act on complementary axes, the supervised fine-tuning (SFT) on verified privileged-teacher traces expands the set of solvable questions (raising pass@k coverage on the hardest cases), while RFT converts that expanded capability into higher single-pass accuracy by teaching the model when to verify, what evidence to retrieve, and how to repair faulty SQL from execution feedback. Applied to Gemma 4 instruction-tuned (31B), RFT alone achieves 73.66% execution accuracy (EX) on the BIRD-SQL development benchmark (74.12% EX with self-consistency). Initializing RFT from the SFT checkpoint (SFT→RFT) yields our strongest model at 74.32% EX single-pass and 74.77% EX with self-consistency. At the time of writing, this ranked first on the BIRD single-model development-set leaderboard. The approach uses composite rewards anchored on execution correctness, requires no human annotation beyond the benchmark itself, and operates within a single dense 31B model, showing that a properly designed SFT→RFT pipeline over tool-use trajectories is a practical path toward robust enterprise-grade text-to-SQL.