nl2sql

The SQL Agent

The SQL Agent is the core execution engine of the platform. For every relevant datasource identified by the routing layer, a dedicated SQL Agent is instantiated.

Unlike traditional text-to-SQL systems that attempt to generate SQL in one shot, the SQL Agent treats the problem as a multi-step reasoning process.

Execution Pipeline

The pipeline is modeled as a state machine:

graph TD
    Planner["Planner Node"] --> LogicalValidator{"Logical Validator"}
    
    LogicalValidator -- "Valid" --> Generator["Generator Node"]
    LogicalValidator -- "Invalid" --> Refiner["Refiner Node"]
    
    Generator --> PhysicalValidator{"Physical Validator"}
    
    PhysicalValidator -- "Valid" --> Executor["Executor Node"]
    PhysicalValidator -- "Invalid" --> Refiner

    Refiner -- "Feedback" --> Planner

1. Planner Node

2. Logical Validator Node

3. Generator Node

4. Physical Validator Node

5. Executor Node

6. Refiner Node