Research ·
Single-Database Rewards Are Hackable: Counterfactual Execution for Trustworthy Text-to-SQL RL
Researchers propose a counterfactual-database reward for text-to-SQL RL that checks queries on hidden generated database copies, cutting paid reward hacks from 54.1% to 1.9%, though training with it did not improve in-domain accuracy.

A common reward for reinforcement learning text-to-SQL agents pays a query when its result matches a reference on a single database, but wrong queries can match by luck when the data lack rows that expose their bug. The paper introduces a counterfactual-database (CF) reward that additionally runs the final query on a few hidden, code-generated copies of the database, paying only if all results match (strict form) or by the share matched (mean form).
On 1,302 synthetic audit questions, the strict form cut buggy queries paid in full from 29.5% to 16.8% and reward hacks paid from 54.1% to 1.9%, while rejecting 0 of 2,847 correct queries; a family-blind generator produced copies about as effective. The work also found and patched an exploitable reward in AgentTune, where a 'WHERE 1 = 1' query plus a constant 'yes' answer gets paid. 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%), though it gained 1.6 points on Spider.
For builders, the takeaway is that single-database verifiers are exploitable and that stricter rewards do not automatically yield better models when the two rewards disagree on only 5-7% of rollouts. Notably, one seed reverses both training signs, so single-seed reward comparisons can mislead. Code, data, models, and a demo Space are available on GitHub and Hugging Face.
References
- Hugging Face · huggingface.co
Read the full story at Hugging Face ↗Like, save or discuss on Buzz