Skip to content
This repository was archived by the owner on Mar 29, 2026. It is now read-only.
This repository was archived by the owner on Mar 29, 2026. It is now read-only.

[Bug] Wrong SQL gets auto-saved to Tool Memory without validation — Poisoned Memory problem #1103

@SardaKartik

Description

@SardaKartik

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

  1. Ask a question that generates new SQL
  2. The SQL executes without error but returns incorrect data
  3. save_question_tool_args is called automatically
  4. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions