# Single-Database Rewards Are Hackable: Counterfactual Execution for Trustworthy Text-to-SQL RL

> Source: <https://aiflash.com/news/158641/>
> Published: 2026-11-26 17:00:46+00:00

**Recommendation:** When training or evaluating text-to-SQL agents, run the final query against several counterfactual databases so lucky matches on a single database don't reward buggy queries.
More in the playbook "Evals and testing for LLM apps": <https://wpnews.pro/playbooks/evals-testing>

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 hidd
