[BUG]SQL Parsing Fails for Valid LLM Outputs with Non-Standard JSON Structure
@xuwei-fit2cloud ya está trabajando en esto.
Desde el 2/1/2026.
- Lenguaje dominante
- JavaScript
- Estrellas
- 6.8k
- Forks
- 882
- Merge medio
- 4 h 37 min
- PR fusionados (30 d)
- 32
Descripción
SQLBot Version
1.5.1
Run Mode
Is it running in a Docker container or running from source code?
Docker
Describe the bug
When using local or open-source LLMs (e.g. Qwen2.5-32B, Qwen3-32B, LLaMA 3.x), SQLBot fails to parse valid SQL generated by the model and raises the error:
Cannot parse sql from answer
This happens even though the LLM output contains a correct and executable SQL statement.
The failure is caused by SQLBot relying on a strict JSON schema for parsing, while many LLMs return SQL in alternative but reasonable formats.
To Reproduce
Deploy SQLBot 1.5.1 using Docker
Configure a local LLM (Qwen2.5-32B / Qwen3-32B / LLaMA 3.x) via Ollama or vLLM
Ask a simple SQL question (e.g. daily aggregation query)
Let the LLM generate SQL
Observe the error:Cannot parse sql from answer
Example LLM output that is rejected:{
"query": "SELECT SUM(chulu_guoshu) FROM example_table WHERE DATE(insert_time) = '2025-12-31'"
}
Expected behavior
SQLBot should successfully extract and execute SQL as long as the generated SQL is valid, including cases such as:
{ "query": "SELECT ..." }
{ "sql": "SELECT ..." }
Nested JSON containing SQL
Plain SQL strings starting with SELECT
The system should not require a single rigid JSON structure for SQL parsing.
Screenshots
If applicable, add screenshots to help explain your problem.
Additional context
SQLBot rejects valid SQL outputs that do not strictly match the expected JSON schema and throws:Cannot parse sql from answer
Additional context
This is not an SQL generation issue — the SQL itself is correct
The problem occurs at the SQL parsing stage only
Cloud models tend to follow the expected format, but local/open-source models do not
This significantly limits SQLBot’s usability with local LLM deployments
A more tolerant SQL extraction mechanism or fallback for raw SQL would greatly improve compatibility.
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Evaluación
Este issue todavía no se ha evaluado.