About This Architecture
Multi-agent NL-to-SQL architecture routes natural language queries through a request classifier and prompt architect to generate validated SQL. User requests flow through an API Gateway to Agent 1, which routes simple queries to a static response LLM or complex queries to Agent 2 for dynamic SQL generation. The Prompt Architect (Agent 2) consults the Schema Store and feeds prompts to an LLM-SQL Generator, whose output undergoes multi-stage validation including syntax, schema, semantic, and safety checks. Validation feedback loops back to the Prompt Architect for iterative refinement until SQL passes all checks. This architecture ensures robust, safe SQL generation while minimizing unnecessary LLM calls for straightforward requests. Fork and customize this diagram on Diagrams.so to adapt agent workflows, add validation stages, or integrate your own schema repositories and LLM endpoints.