Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

4 Commits

Folders and files

Repository files navigation

Where Do Text-to-SQL Agent Systems Fail?

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.

Repository layout

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.

Setup

Python 3.12. Regenerating the tables needs only matplotlib (and gnuplot for Figure 3).

pip install -r requirements.txt

Download BIRD (development set), BEAVER (DW) and Spider 2.0-Lite as described in data/README.md and put them under benchmarks/:

benchmarks/
  bird/             dev.json, dev_databases/
  beaver/dev_dw.json
  spider2-lite/     spider2-lite.jsonl, resource/, evaluation_suite/

or point the code to them:

export BIRD_ROOT=<path to bird>
export BEAVER_DEV_FILE=<path to dev_dw.json>
export SPIDER2_LITE_ROOT=<path to spider2-lite>

API keys, in the environment or as KEY=value lines in agent/.env:

export OPENAI_API_KEY=<your key>      # GPT-4o, GPT-5.5 and the simulated user (GPT-5 mini); every live run
export ANTHROPIC_API_KEY=<your key>   # Claude Sonnet 5
export DEEPSEEK_API_KEY=<your key>    # DeepSeek-V4 Pro

MySQL for BEAVER: load the BEAVER DW dump into a local MySQL database dw. The code connects read-only with BEAVER_MYSQL_HOST, BEAVER_MYSQL_USER, BEAVER_MYSQL_PASSWORD, BEAVER_MYSQL_DATABASE (defaults 127.0.0.1, root, empty, dw).

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 sqlite to the agent run scripts to run only the 15 local Spider questions.

Running the experiments

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:

  1. Run the agent. The run scripts write one trace per question to agent/runs/<run id>/, with run ids <model>-<dataset>-<condition>-b<budget>.

  2. Score EX. experiments/score_ex.sh writes agent/scores/<run id>/per_item.csv.

  3. 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.gz together with a run trace. prompts/README.md lists each judge prompt with its model and the label files it produced in results/judgments/.

  4. 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-run

Using the released results

analysis/make_all.sh

recomputes 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_benchmark_tables.py, plot_figure2.py
Section 3.3 judge validation make_judge_validation.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_generation_tables.py, plot_figure4.py, make_case_readings.py
Tables 11–13, Figure 5 make_refinement_tables.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.

Not included

  • Benchmark databases and question files. They are not ours to redistribute; data/README.md gives 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 in results/judgments/.
  • Patches to Spider-Agent and ReFoRCE. Listed in experiments/existing_systems.md; available on request.

License

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.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages