Code, data and labels for the PVLDB paper Where Do Text-to-SQL Agent Systems Fail? An Empirical Analysis [Experiment, Analysis & Benchmark].
The paper annotates 7,816 decisions in 1,328 questions of BIRD, BEAVER and Spider 2.0-Lite and follows them through information acquisition (Section 4), SQL generation (Section 5) and refinement (Section 6) in four LLMs run as ReAct agents. Section 7 measures the same decisions in two existing agent systems.
| Folder | Contents |
|---|---|
agent/ |
The agent environment (PROBE, DESCRIBE, ASK, EXECUTE), the conditions of Sections 4–6, the refinement harness and the EX scorers (agent/README.md) |
experiments/ |
One script per experiment of the paper, with the paper's settings |
data/ |
Agent inputs: analysis set, Standard and Specified inputs, simulated-user answers, Target lists, DESCRIBE documentation (data/README.md) |
annotations/ |
Decision annotations (decisions.jsonl.gz), the rules for the eight decision types, and the gold SQL check of all 1,816 questions with the reason for each of the 488 exclusions |
prompts/ |
Every prompt a model saw: agent, simulated user and judges (prompts/README.md) |
results/ |
Released runs, judge labels, and the tables and figures of the paper (results/README.md) |
analysis/ |
The scripts that compute every table and figure from results/, and make_all.sh |
In decisions.jsonl.gz, a decision counts as determined by Standard only when standard_input is
sufficient; in_analysis_set marks the 1,328 questions used in the paper.
- Python 3.12 and
pip install -r requirements.txt. Regenerating the tables needs only matplotlib (and gnuplot for Figure 3). - Benchmarks. Download BIRD (development set), BEAVER (DW) and Spider 2.0-Lite as described in
data/README.mdand put them underbenchmarks/(benchmarks/bird/,benchmarks/beaver/dev_dw.json,benchmarks/spider2-lite/), or pointBIRD_ROOT,BEAVER_DEV_FILEandSPIDER2_LITE_ROOTto them. - MySQL for BEAVER. Load the BEAVER DW dump into a local MySQL database
dw; the code connects read-only withBEAVER_MYSQL_HOST,BEAVER_MYSQL_USER,BEAVER_MYSQL_PASSWORD,BEAVER_MYSQL_DATABASE(defaults127.0.0.1,root, empty,dw). - API keys, in the environment or as
KEY=valuelines inagent/.env:OPENAI_API_KEY(GPT-4o, GPT-5.5 and the simulated user GPT-5 mini; needed by every live run),ANTHROPIC_API_KEY(Claude Sonnet 5),DEEPSEEK_API_KEY(DeepSeek-V4 Pro). - BigQuery. 100 of the 115 Spider 2.0-Lite questions of the analysis set run on BigQuery, billed to your
Google Cloud project (
GOOGLE_APPLICATION_CREDENTIALS,BIGQUERY_PROJECT). Pass--backends sqliteto the agent run scripts to run only the 15 local Spider questions.
Each script runs one experiment for the four models (4o, gpt55, sonnet5, deepseek4) on the three
benchmarks. Narrow it with --models, --datasets and --items; any other option goes to the agent runner.
--help prints the settings.
| Experiment | Command | Feeds |
|---|---|---|
| Default, budget 10 (Section 4; also Section 5 Standard and the Q0 of Section 6) | experiments/run_default.sh |
Tables 4–6, 8–10, 14; Figures 3, 4 |
| Default, budgets 5 and 20 | experiments/run_default.sh --budgets "5 20" |
Figure 3 |
| Tool-first, Lookup-first, Ask-first, Self-check, Target list | experiments/run_conditions.sh |
Tables 5–7 |
| Specified (Section 5) | experiments/run_specified.sh |
Tables 8, 10; Figure 4 |
| EX of any run | experiments/score_ex.sh [run ids] |
Table 10 |
| Refinement: Basic, Type-guided, Targeted, Informed, Clarification (Section 6) | experiments/run_refinement.sh |
Tables 11–13; Figure 5 |
| Informed with full SQL text submitted (Section 6.3) | experiments/run_refinement.sh --models 4o --text-submission |
Section 6.3 |
| Spider-Agent and ReFoRCE (Section 7.1) | not scripted; changes listed in experiments/existing_systems.md |
Table 14 |
The pipeline, in order:
-
Run the agent. The run scripts write one trace per question to
agent/runs/<run id>/, with run ids<model>-<dataset>-<condition>-b<budget>. -
Score EX.
experiments/score_ex.shwritesagent/scores/<run id>/per_item.csv. -
Judge the decisions. The judge-calling code is not released; the prompts, models and settings are. Each judge reads one annotated decision from
annotations/decisions.jsonl.gztogether with a run trace (the input and the tool responses before Q0 for acquisition, the SQL query for implementation; the implementation judge never sees the gold SQL). Each prompt file begins with where it was used and its model; the fields it is filled with are the placeholders in braces.Label Prompt ( prompts/judges/)Model Released labels ( results/judgments/)Acquisition before Q0 acquisition_judge.txtgpt-5-mini-2025-08-07, reasoning effort low, two passesacquisition/acquisition*.jsonl.gz,existing_systems/acquisition.jsonl.gzRelated calls, Self-check list related_call_judge.txt,selfcheck_list_match.txtgpt-5-mini-2025-08-07, reasoning effort lowacquisition/related_calls.jsonl.gzClarification requests ask_audit_prompt.txtgpt-5.5-2026-04-23, reasoning effort low, two passesacquisition/ask_audit.csvSQL implementation implementation_judge_v2_3.txt,implementation_alternatives_merge.txtgpt-5-mini-2025-08-07, reasoning effort lowgeneration/implementation.jsonl.gz,refinement/*decisions.jsonl.gz,existing_systems/implementation.jsonl.gzClarification delivery refinement_clarification_delivery.txtgpt-5-mini-2025-08-07refinement/clarification_delivery.csvRe-examination of "differs" labels implementation_differs_recheck.txtClaude Opus 5.5 judge_validation/Section 5 case readings section5_case_readers.txtClaude Opus 5.5, Claude Sonnet 5.5 generation/*.csv -
Make the tables.
analysis/make_all.sh(below) computes the tables and figures from the label files.
Without API keys, every script runs with --dry-run: a scripted mock replaces the model and the simulated
user, and the prompts are those of the paper runs. A dry run still needs the benchmark files of the selected
questions (and MySQL for BEAVER); BigQuery is never queried.
experiments/run_default.sh --models 4o --datasets bird --items "bird:0 bird:1" --dry-run
experiments/score_ex.sh 4o-bird-default-b10-dry
experiments/run_refinement.sh --models 4o --datasets bird --dry-runanalysis/make_all.shrecomputes every table and figure from results/, data/ and annotations/. It needs no API key, database
or network, only Python 3 with matplotlib (and gnuplot for Figure 3). Tables go to results/tables/ and
figures to results/figures/.
| Paper | Script (analysis/) |
|---|---|
| Tables 1–3, Figure 2 | make_sec2.py, plot_figure2.py |
| Section 3.3 judge validation | make_sec3.py |
| Table 4, Figure 3 | make_table4_figure3.py, plot_figure3.py |
| Tables 5, 6, 7 | make_table5.py, make_table6.py, make_table7a.py, make_table7b.py |
| Tables 8–10, Figure 4, Sections 5.2–5.3 | make_table8_table9.py, make_sec5.py, plot_figure4.py, make_sec5_case_readings.py |
| Tables 11–13, Figure 5 | make_sec6.py, plot_figure5.py |
| Table 14 | make_table14.py |
The output file of each table and the files each script reads are listed in
results/README.md and in the docstring of each script.
- Benchmark databases and question files. They are not ours to redistribute;
data/README.mdgives the download links and the versions we used. - Full run traces (every prompt, tool call and tool response of each run, about 3 GB). Available on
request;
results/outputs/holds Q0, the final query, EX and tool-call counts of every run. - The code that called the judges. The judge prompts, models and settings are in
prompts/judges/and the labels inresults/judgments/. - Patches to Spider-Agent and ReFoRCE. Listed in
experiments/existing_systems.md; available on request.
Code is released under the MIT License (LICENSE). Data is released under CC BY-SA 4.0 (LICENSE-DATA),
because it includes text derived from BIRD, BEAVER and Spider 2.0-Lite.