Prevent Prompt Injection by Removing Dangerous Tokens from Query Grammar

go_kul_07 · reddit · 2026-09-02

The author proposes moving security boundaries from system prompts down to the grammar level to prevent prompt injection. In their agent memory engine, dangerous commands like DELETE or ERASE are not valid tokens and are rejected by the lexer. The only destructive operation allowed is FORGET <hash>, which deletes exactly one record by its content hash. This physical isolation via non-existent syntax is more reliable than a "never delete" request. The author advocates for real controls outside the model using permissions, isolated environments, and approval gates.

Original post →

More from coding & agent

coding & agent channel →