Skip to content
AIBRAINWORX / OpenSourceCoder.comLOCAL-FIRST. BUILT IN THE OPEN.
Open Source

A correct SQL answer on one database can reward the wrong query

A text-to-SQL study makes grading harder to game with hidden database copies, but its training results do not establish a better agent.

Listen to this articleBrowser Voice
Ready
Original illustrative comparison of counting orders versus customers across two database states; not output from an executed query.
Original illustrative comparison of counting orders versus customers across two database states; not output from an executed query.
Event / context: 2026-11-25. Source check: Nov 28, 2026.

A generated query can return the expected answer for the wrong reason. Single-Database Rewards Are Hackable, a November 25 preprint by Shreshth Rai, Rishii Kumar Singh and Aksh Aggarwal at Delhi Technological University, studies what happens when that coincidence becomes a reinforcement-learning reward.

The core example is ordinary data logic: counting orders can match a question about distinct customers when each customer happens to have placed one order. Adding a second order reveals the semantic error without changing what the original question meant.

Grade beyond the database the agent explored

The proposed reward runs the final query on the original database and a few hidden, code-generated copies. Some edits change the reference answer; others preserve it while exposing duplicate-counting, join or filtering mistakes. The agent can inspect the original database, not those grading copies.

The strict reward requires matches on every database. The mean form used in the main training comparison first requires a match on the original, then grades the fraction of hidden copies matched. These are distinct reward rules, and their results should not be mixed.

In an audit of 1,302 synthetic questions, the authors report that blind-copy strict grading reduces fully rewarded buggy queries from 29.5% to 16.8%, and constructed reward hacks from 54.1% to 1.9%. It rejects none of the 2,847 correct queries examined. That is an observed audit result, not proof that no valid query could ever be rejected.

A stronger grader did not produce a stronger in-domain agent

The controlled training comparison uses one 3.35B model with three seeds per arm. Pooled verified in-domain accuracy is 8.4% with the mean counterfactual reward, versus 11.7% with the single-database reward. The rewards disagree on only about 5–7% of training rollouts, limiting the learning signal.

On Spider, the counterfactual arm improves test-suite accuracy by about 1.6 points, but a seed-level interval includes no improvement, and one seed reverses the direction. The finding is a reason to separate grading improvements from training claims, not a new state-of-the-art SQL-model announcement.

Source access and limits

The released reward implementation uses final SQL extraction and per-database checks. Its comparator retains row multiplicity rather than treating every result as a set; its numeric normalization and ordering rules still define what a match means. We reviewed those functions without executing queries.

Our repository profile links the Apache 2.0 code. That code license does not cover everything else: the authors describe noncommercial terms for their adapters and generated trajectories, with separate ShareAlike terms for released Spider trajectories. External databases and gated base-model access have additional requirements.

Our analysis

The useful contribution is a falsification test: change the data in a way that should preserve the question's meaning and ask whether the query still behaves correctly. It catches some lucky answers while leaving a measurable remainder. One synthetic schema, limited training, one model and possible benchmark exposure prevent a broader reliability claim. We reviewed the paper and source without downloading models, datasets or running its experiments.

EXPLORE THE SOURCE

GitHub repositories

Original primary-source review. No upstream tests, experiments, model inference, training, dataset or weight downloads, installations or cloud provisioning performed. Published results remain author/provider claims.

Follow your curiosity.

Pass the signal.