PlanModel) using an LLM with structured output.SchemaRetrieverNode in the SQL agent subgraph.ASTPlannerNodepackages/nl2sql/src/nl2sql/pipeline/nodes/ast_planner/node.pyrelevant_tables into the planning prompt.ASTPlannerResponse with the PlanModel.Upstream:
SchemaRetrieverNodeRefinerNode (retry loop)Downstream:
LogicalValidatorNode on successretry_handler on retryable failureTrigger conditions:
flowchart LR
SchemaRetriever[SchemaRetrieverNode] --> Planner[ASTPlannerNode] --> Validator[LogicalValidatorNode]
Refiner[RefinerNode] --> Planner
Planner --> RetryHandler[retry_handler]
From SubgraphExecutionState:
sub_query.intent (required)sub_query.expected_schema (optional)relevant_tables (required for schema grounding)errors (optional feedback for retries)Validation performed:
Mutations to SubgraphExecutionState:
ast_planner_response (ASTPlannerResponse)reasoning with plan summaryerrors on planning failureSide effects:
llm_registry.relevant_tables to JSON text.expected_schema payload from sub‑query.PlanModel).ASTPlannerResponse with plan and reasoning.PLANNING_FAILURE error and return plan=None.Implements a LangGraph node callable:
def __call__(self, state: SubgraphExecutionState) -> Dict[str, Any]
Key contracts:
PlanModelASTPlannerResponseEmits PipelineError with:
PLANNING_FAILURE on LLM or parsing errors.Logs failures via logger.exception.
plannerast_planner in llm.yaml.PLANNER_PROMPT and examples.build_sql_agent_graph() to use alternate planning logic.packages/nl2sql/src/nl2sql/pipeline/nodes/ast_planner/node.pypackages/nl2sql/src/nl2sql/pipeline/nodes/ast_planner/schemas.py