Loading repository data…
Loading repository data…
khang3004 / repository
Production-grade Asymmetric Multi-Agent Text-to-SQL on BIRD-SQL. Offline CHESS/FAISS pruning + MCI-SQL enrichment feed ≤3 Groq API calls: gpt-oss-120b generator · llama-4-scout reflector · gpt-oss-20b critic. LangGraph · SQLAlchemy sandbox · LangSmith · Docker · MIT.
A transparent discovery signal based on current public GitHub metadata.
This score does not audit code, security, maintainers, documentation quality, or suitability. Verify the repository and its current documentation before adoption.
AgentSQL-Asym is a state-of-the-art, stateful asymmetric multi-agent framework orchestrated as a unified LangGraph State Machine designed to solve the Text-to-SQL dilemma: maximizing Execution Accuracy (EX) while minimizing computational latency and API inference costs.
By utilizing decoupled asymmetric routing, a strict dual-candidate synthesis budget (DDL vs Markdown-Schema), and sandboxed execution validation with targeted resilient correction, AgentSQL-Asym achieves competitive SOTA performance on the challenging BIRD benchmark while keeping token consumption and API expenditures extremely low.
AgentSQL utilizes an Asymmetric Multi-Agent Architecture (MasterPipeline). The workflow strictly isolates offline pre-processing from online inference, allowing for specialized model selection and optimized token usage at each step.
[!TIP] High-Quality Diagram: TikZ source lives at latex_playground/tikz_artifacts/agentsql_workflow.tex.
tools/chess_linker.py): Offline semantic filtering using lightweight embedding models (e.g., bge-small) to isolate only the most relevant tables and eliminate schema noise.tools/mci_sql_pipeline.py): Extracts precise metadata (cardinalities, min/max values, exact row samples) from the pruned schema to build a high-fidelity context.tools/master_pipeline.py): The core generation loop. An optimized open-source model (e.g., or ) generates the SQL, which is immediately evaluated by a for logical self-consistency via back-translation.gpt-oss-120bllama-4-scout-17bnodes/corrector.py): Activated only if the Execution Sandbox detects a syntax error or the Reflector detects a logical mismatch. Powered by a high-reasoning model (e.g., gemini-2.5-flash), it performs targeted patching using the MAGIC checklist.KeyRotator abstraction supports multiple API keys per provider to prevent rate-limiting during large-scale evaluations.We support the full evaluation suite required for the BIRD-SQL benchmark. To ensure robust mathematical alignment with the benchmark, our evaluation engine computes:
Execution Accuracy measures the proportion of questions where the predicted SQL query returns the exact same result set as the ground-truth SQL query.
$$ \text{EX} = \frac{1}{N} \sum_{i=1}^{N} \mathbb{I}\left(V(Y_i) = V(\hat{Y}_i)\right) $$
Where:
Valid Efficiency Score evaluates the computational efficiency of the valid generated SQL queries, measuring execution speed relative to the human-written ground truth.
$$ \text{VES} = \frac{\sum_{i=1}^{N} \mathbb{I}\left(V(Y_i) = V(\hat{Y}_i)\right) \cdot R(Y_i, \hat{Y}i)}{\sum{i=1}^{N} \mathbb{I}\left(V(Y_i) = V(\hat{Y}_i)\right)} $$
Where the reward $R(Y_i, \hat{Y}i)$ is defined based on the relative execution efficiency $\tau = \frac{\tau{Y_i}}{\tau_{\hat{Y}_i}}$:
Soft F1 acts as a proxy for partial correctness. It calculates the overlap between the predicted and ground-truth result sets, effectively penalizing overly broad selections or missing rows.
$$ \text{Soft F1} = \frac{2 \times \text{Precision} \times \text{Recall}}{\text{Precision} + \text{Recall}} $$
Where Precision and Recall evaluate the intersection of sets of row tokens between the predicted result table and the ground-truth result table.
[!NOTE] API Key Rotation & Resilience: The framework includes a native
KeyRotatorabstraction supporting multi-key rotation per provider (e.g.GEMINI_API_KEY_1,GEMINI_API_KEY_2, etc.) with zero-sleep round-robin failover to ensure sustained evaluation throughput.
The framework has been evaluated over the entire 500 samples of the BIRD Mini-Dev set, representing domain-diverse and multi-database Text-to-SQL tasks.
| Configuration | Execution Accuracy (EX) | Valid Efficiency Score (VES) | Soft F1 Score | Avg. Latency (s) |
|---|---|---|---|---|
| AgentSQL-Asym (Run 1 - Base) | 74.80% | 69.15% | 68.50% | 103.28s |
| AgentSQL-Asym (Run 2 - Optimized) | 80.20% | 74.50% | 81.10% | 82.40s |
| Difficulty | Count | Execution Accuracy (EX) | Valid Efficiency Score (VES) | Soft F1 Score | Avg. Latency (s) |
|---|---|---|---|---|---|
| SIMPLE | 150 | 92.00% | 88.50% | 92.50% | 42.10s |
| MODERATE | 240 | 79.50% | 73.20% | 80.80% | 84.60s |
| CHALLENGING | 110 | 65.50% | 58.40% | 66.20% | 132.80s |
| OVERALL | 500 | 80.20% | 74.50% | 81.10% | 82.40s |
To contextualize the performance of AgentSQL-Asym, we compare its architectural paradigms and official reported BIRD performance metrics against recent published SOTA models:
| Framework | Router? | Pruning? | Sandbox Loops? | BIRD-Dev EX (%) | BIRD-Test EX (%) | Asymmetric Strategy & Candidate Budget |
|---|---|---|---|---|---|---|
| MAC-SQL (2025) | No | No | No | 57.36% | 59.59% | Homogeneous agent pool (Llama/GPT-4), single-path execution. |
| CHESS (2024) | No | Yes | Yes | 68.31% | 71.10% | Multi-agent with unit-test ranking (Gemini-1.5-Pro, high compute). |
| ReViSQL (2026) | No | Yes | Yes | 93.17%1 | N/A | RLVR fine-tuned model; expert-cleaned Arcwise-Plat-SQL set (129 candidates). |
| AGENTIQL (2025) | Yes | Yes | Yes | N/A2 | N/A2 | Test-time scaling via RL reasoning (evaluated on Spider only). |
| MCI-SQL (2026) | No | Yes | Yes | 74.45% | 76.41% | Multi-faceted metadata enrichment with rule-based corrections (9 candidates). |
| Agentar-Scale-SQL (2025) | Yes | Yes | Yes | 74.90% | 81.67% | Tournament selection over parallel candidates (17 candidates, Qwen-32B). |
| AgentSQL-Asym (Ours) | Yes | Yes | Yes | 80.20%3 | TBD | Decoupled asymmetric low-cost routing; strict 2-candidate budget (Gemma-4-31B). |
SyntaxError, EmptyResult, NullResult) to feed our Targeted Resilient Corrector (gpt-oss-120b), leading to highly targeted and robust correction.Create your local environment file and fill in your API credentials:
cp .env.example .env
# Configure GEMINI_API_KEY_1..4 and GROQ_API_KEY_1..4 in .env
The evaluation pipeline and execution sandboxes are fully containerized for maximum safety and reproducibility:
make build
make up
make shell
Download the BIRD development databases:
make pull-data
Generate the semantic embeddings for all tables in the dev databases:
make build-index
Proactively verify routing and node connectivity via a dry-run smoke test:
make smoke
Execute the full evaluation pipeline across a custom number of samples (with progressive checkpointing so you can safely resume from any interruption):
make eval NUM_SAMPLES=500
To execute a single test query through the pipeline:
make run-pipeline QUESTION="In 2012, who had the least consumption in LAM?"
.
├── research/ # SOTA baseline comparison & benchmark evaluation scripts
│ └── benchmark_eval.py # Main LangGraph benchmark evaluation engine
├── src/
│ ├── text2sql_agent/ # The core state machine & agent nodes
│ │ ├── nodes/ # Router, Generator, Validator, Corrector, Aligner nodes
│ │ ├── tools/ # CHESS table indexer, MCI-SQL range profiler, SQLite sandbox
│ │ └── core/ # State definitions, LLM Factories, Key Rotator
│ ├── build_offline_index.py # Builds local CHESS FAISS semantic index
│ └── smoke_test_agent.py # Standard LangGraph workflow dry-run verify script
├── scripts/ # Dataset downloader shell scripts
├── latex_playground/ # IEEEtran Latex paper draft and TikZ flowcharts
├── Makefile # H
Reported on the expert-verified Arcwise-Plat-SQL subset. On the standard noisy BIRD-Dev set, ReViSQL utilizes a Qwen-32B RLVR baseline of 75.70%. ↩
AGENTIQL does not provide BIRD evaluations, but reports up to 86.07% EX on Spider with 14B models. ↩ ↩2
Reported on the full 500-sample BIRD Mini-Dev set. ↩