[Bug] Wrong SQL gets auto-saved to Tool Memory without validation — Poisoned Memory problem
Author: SardaKartikCreated Feb 23, 2026Updated Feb 28, 2026
Labelsbug
Bug Description
When the LLM generates SQL and executes it successfully, save_question_tool_args
is called automatically — even if the result is semantically wrong.
A query can execute without any SQL error but still return incorrect data
(e.g. summing order_count instead of revenue). This incorrect behavior
gets saved to Tool Memory and reused for all future similar questions,
reinforcing errors over time.
Steps to Reproduce
- Ask a question that generates new SQL
- The SQL executes without error but returns incorrect data
save_question_tool_argsis called automatically- Ask a similar question → the wrong SQL is retrieved and reused
Expected Behavior
SQL should only be saved to Tool Memory after a human confirms the result is correct.
Proposed Fix
Add an optional require_human_approval_for_memory flag.
When enabled, show a " Save to memory" button and only persist
the SQL after explicit user approval.
Source: vanna-ai/vanna