Robust SQL extraction: handles explanations, markdown, prefixes

clean_sql now uses 3 strategies in priority order:
1. Extract from ```sql...``` markdown blocks
2. Find first SELECT/WITH/INSERT statement in text
3. Strip leading "sql" keyword fallback

Tested against 5 real model output patterns:
- Clean SQL ✓
- "sql" prefixed ✓
- Markdown fenced ✓
- Explanation before ```sql block ✓
- Explanation with SELECT buried in text ✓

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
root
2026-03-27 20:42:11 -05:00
co-authored by Claude Opus 4.6
parent 34c03894ae
commit 0bd753294b
5 changed files with 195 additions and 13 deletions
Binary file not shown.