Current file: app/src/lib/tools/sql-converter.ts
Current model: qwen-3-coder-30b
Current approach: Single prompt with dialect and optional schema. No SQL validation, no query testing, no optimization analysis.
Problems with current approach:
- Generated SQL may have syntax errors for the target dialect.
- No validation against the provided schema (column names, types).
- Optimization suggestions are generic, not query-specific.
- Does not handle ambiguous natural language well.
Upgrade plan:
| Step |
Agent |
Action |
| 1 |
Schema Parser |
Programmatic: If schema is provided, parse to extract table names, column names, types, constraints, relationships. |
| 2 |
Intent Classifier |
Analyze the natural language query to identify: target tables, filter conditions, aggregations, joins, ordering. Output structured query plan. |
| 3 |
SQL Generator |
Generate SQL query using the structured plan and parsed schema. Enforce dialect-specific syntax. |
| 4 |
SQL Validator |
Programmatic: Parse generated SQL using sqlglot. Validate syntax for target dialect. Check referenced columns exist in schema. |
| 5 |
Refinement Agent |
If validation fails, feed errors back and regenerate. Max 2 retries. |
- You are free to enhance the agents stacks in the above plan layout, the above one is just for reference. You can enhance more if needed.
Model suggestions to start with:
- Step 2: Try
deepseek-v3.2 for intent classification (lightweight).
- Steps 3 and 5: Try
qwen-3-coder-30b for SQL generation. Also test kimi-k2.6 and deepseek-coder-33b to compare accuracy.
- For complex analytical queries, try
deepseek-r1-0528 in Step 3 instead.
Model Selection Guidance
- You are free to pick any model from the Oxlo catalog based on your own testing and evaluation.
- The Models suggestions above, not mandates. Try them first, and if they do not meet the accuracy target, experiment with alternatives.
Compare against: GPT 5.3 Thinking & Claude Sonnet 4.6 Thinking.
Acceptance criteria:
- Generated SQL must pass
sqlglot syntax validation in 95%+ of cases.
- Schema-aware queries must correctly reference provided table and column names.
- Output quality matches or exceeds GPT 5.3 Thinking/Claude Sonnet 4.6 on NL-to-SQL test cases.
- Overall accuracy at 80%+.
Current file:
app/src/lib/tools/sql-converter.tsCurrent model:
qwen-3-coder-30bCurrent approach: Single prompt with dialect and optional schema. No SQL validation, no query testing, no optimization analysis.
Problems with current approach:
Upgrade plan:
sqlglot. Validate syntax for target dialect. Check referenced columns exist in schema.Model suggestions to start with:
deepseek-v3.2for intent classification (lightweight).qwen-3-coder-30bfor SQL generation. Also testkimi-k2.6anddeepseek-coder-33bto compare accuracy.deepseek-r1-0528in Step 3 instead.Model Selection Guidance
Compare against: GPT 5.3 Thinking & Claude Sonnet 4.6 Thinking.
Acceptance criteria:
sqlglotsyntax validation in 95%+ of cases.