Teaching SQL with an Agentic LLM: A Fifteen-Category Hallucination Taxonomy and Context-Pack Mitigation Strategy for Claude Sonnet 5
Text-to-SQL generation with large language models (LLMs) is increasingly used in database teaching, yet it remains susceptible to hallucination: the production of syntactically valid but referentially or semantically incorrect queries. This paper proposes a working taxonomy of fifteen hallucination categories in text-to-SQL generation, spanning schema-referential errors, join and cardinality errors, aggregation-grain errors, linguistic ambiguity, dialect and type misuse, NULL and temporal-logic errors, and higher-order failure modes such as explanation-query inconsistency, fabricated execu- tion results, and false security assumptions. Each category is illustrated with a natural-language request and a corresponding hallucinated query against a common PostgreSQL schema, together with a targeted mitigation. Mitigations are organized into two complementary layers: a context pack supplied once by the instructor (schema DDL, column catalog, foreign-key graph, and a set of standing rules) and an agentic execute-observe-correct loop, formalized here through explicit definitions of "generation" and "session", in which an assistant such as Claude Sonnet 5 issues queries against a live PostgreSQL database via the Model Context Protocol (MCP), inspects the returned rows or errors, and revises the query before presenting it to the user. The paper provides a recap table of categories and countermeasures, intended as a practical checklist for instructors and students applying agentic LLMs to SQL laboratory training. The taxonomy is positioned against related error classifications from the text-to-SQL and broader LLM-hallucination literature, showing convergence on schema- and logic-level categories while identifying conversational and pedagogical failure modes – ambiguity, car- dinality fan-out, explanation inconsistency, fabricated results, and security over-confidence – that fall outside the scope of static, benchmark-based taxonomies.
- Link
- https://doi.org/10.20944/preprints202609.2080.v1
- Found by
- Crossref
- Authors
- Paolino Di Felice
- Categories
- benchmark
- Published
- 2026-09-24
- Last seen by the radar
- 2026-09-26
- Citations
- 0
- Radar score
- 26.75 / 100 (how it is scored)
- Why it scored so
- Matched: benchmark; Primary record: Crossref