When to reach for it
- The agent must utilize domain-specific knowledge long-term.
- Facts and preferences are reused.
- Relationships between entities are crucial.
What the agent knows, indexed for retrieval.
Long-term knowledge is stored structurally, as embeddings, or as entities and relations, independently of single conversations. Match the store to the access pattern and start simple: vector DBs for similarity recall, key-value (Redis) for fast exact lookup, relational for structured/auditable querying, and graph DBs only once vector-plus-relational becomes the bottleneck.
In practiceA support assistant stores the fact that a customer is on the Enterprise plan, and recalls it in a conversation weeks later without the user repeating it.
Knowledge is written once, outside any conversation, and read whenever a question needs it. The model stays as it is; to change what the agent knows, you change the store.
1 · Write, when knowledge arrives
2 · Read, when a question comes
| Stored passage | Written | Similarity | Loaded |
|---|---|---|---|
| Single sign-on is included from the Enterprise plan | Product documentation | 0.88 | Yes |
| Acme is on the Enterprise plan | A conversation six weeks ago | 0.82 | Yes |
| Setting up single sign-on takes about one hour | Product documentation | 0.74 | No |
| Acme's billing contact has changed | A conversation last week | 0.41 | No |
def remember(text):
for chunk in split(text, words=100):
index.add(embed(chunk), chunk)
def recall(question, k=5):
return index.search(embed(question), k) # maximum inner product search
def answer(question):
passages = recall(question)
return model(f"Use only these passages:\n{passages}\n\nQuestion: {question}")When to reach for it
When it backfires
Embeddings score by surface similarity. A high-similarity match can be a year-old answer to a question whose ground truth has since changed.
Countermeasure
Include a freshness signal in ranking and reject documents past a recency cutoff. Re-embed when the source updates, not on a schedule.
Each write appends. The store ends up holding both 'the customer is on Free' and 'the customer is on Enterprise', and retrieval may surface either, so the agent contradicts itself between sessions.
Countermeasure
Upsert facts by a stable entity key rather than appending, and resolve conflicts on write (latest-wins or explicit reconciliation) instead of at read time.
Threat exposure
Adopting this pattern opens these attack surfaces. Each links to its entry in the threat model.
Full threat model →EU law
Duties from EU law that this pattern helps meet, or that land on it. A reading aid, not legal advice.
An engineer's reading aid, not legal advice. The legal texts and their interpretation are authoritative.
Keep going
Search patterns, frameworks, and pages.