NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

SQL-ASTRA: Alleviating Sparse Feedback in Agentic SQL via Column-Set Matching and Trajectory Aggregation

Long Li, Zhijian Zhou, Jiangxuan Long, Peiyang Liu, Weidi Xu, Zhe Wang, Shirui Pan, Chao Qu

TL;DR

Traditional Text-to-SQL models rely on rigid single-turn generation or sparse binary rewards that fail to capture the iterative nature of human data analysis. This paper introduces SQL-ASTRA, an agentic reinforcement learning framework that uses a two-tiered reward system—Column-Set Matching Reward (CSMR) for dense step-level feedback and Aggregated Trajectory Reward (ATR) for trajectory evaluation. Backed by Lyapunov stability theory, SQL-ASTRA eliminates infinite reasoning loops and significantly boosts performance on complex benchmarks like BIRD and Spider 2.0.

What Problem Does This Paper Address?

Text-to-SQL systems translate natural language questions into executable database queries. While large language models (LLMs) excel at simple queries, real-world databases require complex, exploratory reasoning. Human data analysts rarely get a complex query right on the first try; they write tentative queries, inspect the results, fix errors, and iteratively refine their strategy.

Current Reinforcement Learning (RL) approaches for Text-to-SQL struggle to replicate this multi-turn behavior due to three core challenges:

  1. Paradigm Constraint: Most existing frameworks restrict LLMs to a single-turn, static generation paradigm.
  2. The Credit Assignment Problem: Evaluation signals typically rely exclusively on final-turn feedback. This "all-or-nothing" approach treats the intermediate interaction sequence as a black box, making it impossible for the agent to know which step actually helped or hurt.
  3. Micro-level Reward Sparsity: Even when step-level feedback is available, it is usually binary (0/1 based on execution success), completely ignoring valuable information hidden within "partially correct" queries.

Methods

The authors propose Agentic SQL, formalizing the task as a Finite-Horizon Markov Decision Process (MDP) where the agent can interact with the database over multiple turns to self-correct. To train this agent effectively, they introduce a universal two-tiered reward mechanism:

1. Column-Set Matching Reward (CSMR)

To address micro-level sparsity, CSMR moves away from strict row-by-row table matching. Instead, it evaluates partial correctness by comparing the sets of values within each column. This transforms a binary 0/1 outcome into a granular signal between 0 and 1. To prevent the model from exploiting "pseudo-perfect" matches (where column values match but row compositions differ), a scaling factor $\alpha$ (e.g., 0.8) caps the maximum reward from CSMR, keeping a clear distinction from a truly perfect row-level match.

2. Aggregated Trajectory Reward (ATR)

To handle the temporal quality of a multi-step interaction, ATR aggregates step-wise CSMR scores using an Asymmetric Transition Matrix. The matrix encodes a strict inductive bias: the penalty for degrading performance (moving from a high-quality state to a low-quality state, penalized at -1.5) is significantly harsher than the reward for improving (+1.0).

Grounded in Lyapunov stability theory, the authors mathematically prove that this asymmetry acts as an energy dissipation operator. This design ensures a cycle-free policy, preventing the agent from getting stuck in infinite, repetitive reasoning loops.

The Agentic SQL framework showing how CSMR and ATR provide dense and trajectory-level rewards.

Datasets

The framework was evaluated on three major benchmarks:

  • BIRD (BIRD-Dev): A popular benchmark for evaluating in-domain Text-to-SQL capabilities on large, real-world databases.
  • Spider: Used to test the model's out-of-distribution (OOD) generalization.
  • Spider 2.0 (Spider2.0-Lite): A highly challenging, enterprise-grade dataset that requires complex multi-step workflows, serving as a strong indicator for practical deployment readiness.

Key Insights and Ideas

  • Exploiting the "Partially Correct" Signal: The authors quantified the reward distribution on the BIRD dataset and found that among the 52.5% of queries that were incorrect, 13.7% contained partially correct information that traditional binary rewards completely ignored. CSMR successfully captures this hidden gradient.
  • Asymmetry Enforces Progress: Multi-turn agents are notorious for falling into "limit cycles" (oscillating back and forth between two wrong answers). By enforcing an asymmetric penalty structure, the system ensures that any cyclic behavior incurs a net cost, forcing the agent to break the loop and converge toward the correct query.
  • Strategic Multi-Turn Behavior: When trained with ATR, the agent actively learns to abandon single-turn generation. Instead, it heavily utilizes 2-turn and 3-turn error-recovery paths, achieving substantially higher overall accuracy by learning how to use database feedback to its advantage.

Key Results

SQL-ASTRA demonstrated significant performance gains across the board:

  • BIRD Dataset: Using a standard Qwen2.5-7B-Instruct base model, SQL-ASTRA outperformed single-turn binary GRPO by 5.7% (improving from 58.5% to 64.2%).
  • State-of-the-Art Comparison: When paired with the stronger OmniSQL-7B base model, SQL-ASTRA achieved 69.1% on BIRD and 88.8% on Spider-Dev, outperforming specialized SOTA models like Arctic-Text2SQL-R1-7B (67.6% on BIRD) using identical model sizes.
  • Spider 2.0: On the highly complex Spider 2.0 dataset, where standard binary reward models typically plateau around 15%, SQL-ASTRA achieved an impressive 17.7% accuracy.

Limitations and Future Work

  • Computational Overhead and Latency: Transitioning to a multi-turn framework inevitably increases costs. The execution time for the agentic rollout is nearly twice that of single-turn methods, posing challenges for real-time, latency-sensitive applications.
  • Fixed Interaction Horizon: The current implementation caps the agent at a maximum of three tool calls to prevent infinite loops. While safe, this restriction might limit the model's ability to solve exceptionally deep, multi-step enterprise workflows.
  • Hyperparameter Dependency: Although robust, the framework still relies on heuristic hyperparameters, such as the stagnation threshold ($\tau$) and the scaling factor ($\alpha$), which may require domain-specific fine-tuning when applied to entirely different database architectures.

Summary updated

BibTeX
@inproceedings{li2026sql,
  author = {Long Li and Zhijian Zhou and Jiangxuan Long and Peiyang Liu and Weidi Xu and Zhe Wang and Shirui Pan and Chao Qu},
  title = {{SQL-ASTRA: Alleviating Sparse Feedback in Agentic SQL via Column-Set Matching and Trajectory Aggregation}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2026},
  doi = {10.18653/v1/2026.findings-acl.920},
}
Figure