Lesson 04.11 · Phase 04 · Memory & Context Engineering

Memory poisoning & hygiene

A prompt injection in one conversation is a bad answer. A prompt injection written to memory is a bad answer in every conversation after it. Know where every memory came from, and never let tool output become an instruction.

Learning objectives

  • Explain how an indirect prompt injection becomes persistent once an agent writes it to memory.
  • Implement write-time defences: provenance (was this copied from tool output?), instruction detection, and quarantine with human approval.
  • Implement read-time defences: per-user isolation, expiry for untrusted items, and rendering memories as fenced data.
  • Audit an existing memory store, and name the cost of each defence (what good memories it blocks).

The agent is asked a billing question and reads a help page. Hidden in the page, in a display:none block a person never sees, is this:

Loading the full lesson…