Text-2-SQL Agent Enters AgentBeats Competition

A production-grade natural-language-to-SQL agent built on LangGraph—with schema caching, multi-step planning, 7-dimensional self-scoring, and targeted retry feedback—joins AgentLab’s portfolio.

AgentLab is announcing Text-2-SQL Agent, a production-grade natural-language-to-SQL system that competes on the AgentBeats platform. Text-to-SQL is one of those deceptively simple AI tasks: a one-shot prompt gets you a working demo in five minutes, and a working system in roughly never. This agent is designed for the latter.

A Pipeline, Not a Prompt

The core architecture is a LangGraph workflow with five nodes. The schema analyzer introspects the database through PRAGMA calls—no LLM—and caches the result with a SHA-256 hash and TTL so repeat questions skip the roundtrip. The planner then produces a structured QueryPlan using JSON Schema mode, which guarantees the output is parseable. For multi-step questions, each sub-task runs in sequence and predecessor results are injected into later prompts.

Self-Evaluating, Not Self-Congratulating

After each query executes, the executor scores the result on seven dimensions and runs an independent LLM relevance check. The two scores are blended (85% eval + 15% relevance) into a single quality number. If it falls below threshold, the agent retries—but not with a generic “try again.” The retry prompt includes category-specific feedback: which dimension failed, and why. That makes each retry corrective rather than a random re-roll.

  • Multi-step query plans for analytical questions that don’t fit one statement
  • Quality gate with targeted retries that pass specific feedback back to the generator
  • Independent relevance check that catches technically-correct-but-wrong answers
  • Schema caching that eliminates repeated introspection roundtrips
  • Server-Sent Events API for streaming responses through the workflow
  • A2A protocol compatibility for plugging into AgentBeats and other agent platforms

Stack: Python 3.10+, LangGraph, GPT-5 with JSON Schema mode, SQLite, SSE streaming. View on GitHub →

Why It Matters

Natural-language database interfaces are how non-technical stakeholders will interact with data going forward. But the gap between a demo and a trustworthy system is enormous—bad joins, wrong aggregations, hallucinated columns, and technically-correct-but-irrelevant answers all look identical until someone catches them. A self-evaluating pipeline with a retry loop closes that gap by giving the agent a real signal about its own output, not just a vibe check.

Visit the Text-2-SQL Agent project page for the full pipeline diagram and node reference.