
Your agent repeats a mistake you corrected last week. The team starts debating where its memory should live: the vendor’s built-in memory, a Git repository of notes or a managed database. Then someone asks the question your data protection officer will ask anyway: what exactly will this memory contain, where will it sit and how do we delete it?
One recent enquiry came from an AI company building its own agent harness on real customer data. In that setting, choosing where an agent remembers things stops being only a tooling preference. It becomes a decision about personal data, retention, access and deletion.
The storage choice is the last decision, not the first. Decide what the agent must remember, who corrects it and what the law requires of it. The right store usually follows.
Answer in 60 seconds
- Sort before you store. Standing instructions and procedures belong in reviewed files, such as
AGENTS.mdand skills. Only changeable facts and history need a memory store. - Native memory suits one client, one team and no customer data. Check where it is stored, how to switch it off and how to delete it.
- Git suits reviewed instructions, skills and curated technical notes. Keep personal data out: removing anything from Git history means rewriting it, and existing clones keep their copies.
- A database suits several writers, per-item access, expiry and deletion on request, which customer data usually requires.
- Before legal review, prepare five answers: which data enters memory, where it is stored and by whom, how long it stays, how it is deleted and who may read it.
- If the source data is not recorded reliably, no memory store will fix it. Postpone the build.
- Saving is not enforcing. A remembered rule can still be ignored. Restrictions belong in tools and permissions.
In this article
- Memory, context and enforcement are different jobs
- Sort what the agent must remember
- Native memory, Git or a database
- What to settle before legal review
- One agent, worked through
- When to postpone the build
- Test one workflow before widening the system
1. Memory, context and enforcement are different jobs
Stored memory is information kept between sessions. Loaded context is what the model actually receives for the current task. Enforcement is a technical restriction on an action. Saving a rule establishes neither that it will be loaded nor that it will be obeyed.
A large store does not make a large prompt by itself: what is retrieved or injected does. Anthropic’s engineering note on the components of agent memory reports benefits from memory, and from checking notes against original transcripts, in specific evaluations. Its context-engineering guidance argues for the smallest set of high-signal material. Chroma’s context-rot report measured performance falling as input length grew on controlled tasks. None of this sets a universal limit for today’s models. It does mean that keeping everything is not a strategy.
Before changing storage, inspect one failure: what was saved, what actually reached the model and what the tool allowed.
2. Sort what the agent must remember
Use this allocation as a starting design, then confirm it in your client.
| Material | Suggested home | What to check |
|---|---|---|
| Stable working rules | Project instruction file (AGENTS.md, CLAUDE.md) |
Scope, precedence and actual loading |
| Repeatable procedure | Skill with supporting material | Discovery, invocation and prerequisites |
| Durable but changeable facts | Native memory, curated notes or the system of record | Source, date, owner and correction |
| Past runs and decisions | Searchable history | Retrieval, permissions and retention |
| Event-triggered check | Supported hook | Timing, blocking and failure behaviour |
| Mandatory restriction | Restricted tool or permission boundary | Whether another path bypasses it |
Only the third and fourth rows need a memory store in the sense this article discusses. The others are reviewed files or runtime controls.
An instruction file stays short enough to review. For example:
# AGENTS.md (excerpt)
- Customer identifiers never go into notes or memory files.
- Contract facts come from the contract system, not from earlier conversations.
- Use the extract-clause skill for contract questions; cite the source document.
- Stop and ask if the source document is missing or unreadable.
File names and loading rules are client-specific. Claude Code’s memory documentation describes how it loads CLAUDE.md, AGENTS.md and its automatic memory. By default, Claude Code reads AGENTS.md only when there is no CLAUDE.md or CLAUDE.local.md in the working directory or above it. OpenAI’s Codex customisation guide, hosted on its ChatGPT Learn site, separates instructions, memories, skills and connected tools. The Agent Skills specification defines a portable skill structure with progressive loading. None of these formats guarantees that a procedure is invoked or executed correctly.
Hooks can enforce, but only within their documented behaviour. In Claude Code’s hooks reference, exit code 2 blocks only on certain events, such as before a tool call, while other non-zero exits let the action continue unless the hook is configured to block on failure. Codex hooks have their own event-specific rules. For a restriction that must hold, put it in the tool itself. Our article on MCP, skills and CLI covers where that boundary belongs; this article stays with memory.
Normalise before you store. Facts rarely arrive as clean text. They come from tickets, scanned contracts, spreadsheets, Word files, photos and call recordings. Before a fact enters memory, keep its source, format, extraction date and the person who validated it. A fact read from a scanned PDF without that trail becomes an instruction nobody can check.
3. Native memory, Git or a database
| Criterion | Native memory | Git repository | Managed database |
|---|---|---|---|
| Set-up effort | Lowest | Low | Highest |
| Change review | Client-dependent | Pull requests | Must be built |
| Several writers and clients | Usually one client | Possible, with merge conflicts | Designed for it |
| Per-item access and expiry | Client-dependent | Repository-wide access only | Designed for it |
| Deleting one record | Client-dependent | Requires rewriting history | Standard operation |
| Customer personal data | Only if location and deletion are confirmed | Avoid | Possible, with controls |
Start with native memory when one client and a small scope cover the workflow. “Native” describes the integration, not the hosting. Claude Code keeps its automatic memory as local files on the developer’s machine, and it can be switched off. Codex memories are off by default and, when enabled, stored under the local Codex home directory. Hosted agent platforms may differ: Anthropic’s data residency page states that memory stores attached to its managed agents remain stored by Anthropic. Check where it is stored, how material is selected, how to correct, export and delete it, and how to switch it off.
Use Git for reviewed material: project instructions, skills and curated technical notes. Pull requests give you review and an audit trail. Assign someone to resolve corrections and conflicting edits. Keep personal data out of the repository: according to GitHub’s guidance on removing sensitive data, removal means rewriting history, and copies in existing clones and forks can survive.
Choose a database when you need structured queries, several writers, per-item permissions, expiry or deletion on request across clients. Specify those requirements first. You still have to build retrieval, correction, permissions and a way to supersede records.
Put memory where the team already works. A new memory surface that nobody opens goes stale. If the team reviews everything in pull requests, Git-based notes will be maintained. If current facts already live in a ticketing system, a CRM or a contract repository, retrieve them from there instead of copying them into a new store. The same applies to the people: a domain expert who already owns those facts should own their corrections.
A hybrid is common: reviewed procedures in Git, current facts in their system of record, run history in a database with a retention rule. Make the owner of each fact explicit so that two stores never become competing authorities.
If the real problem is finding company knowledge across many systems, our article on searchable operating memory covers that wider architecture.
4. What to settle before legal review
Your DPO or legal counsel will decide what is lawful. Arriving with these answers shortens that conversation. The articles cited are from the General Data Protection Regulation.
| Question | Why it matters | What to bring |
|---|---|---|
| What data can enter memory? | Transcripts and notes pick up names, emails and customer content without anyone deciding to store them | A list of data classes per store, and what is filtered out |
| Where is it stored, and by whom? | A vendor storing memory for you is likely acting as a processor, which requires a contract (Art. 28); storage outside the EEA raises transfer rules (Chapter V) | Storage location per store, provider, contract status |
| How long does it stay? | Personal data must not be kept longer than needed (Art. 5(1)(e)) | A retention period and an automatic expiry mechanism |
| How is one record deleted? | People can request erasure (Art. 17), and summaries, caches and Git history keep copies | A tested deletion path covering derived copies |
| Who can read it? | Shared memory can expose one customer’s data to another user or agent | Access rules per store and per item |
Add the memory stores to your record of processing activities (Art. 30) once they hold personal data. The CNIL’s recommendations on AI system development concern building AI systems rather than runtime memory, but their logic carries over: a defined purpose, minimised data and a retention period set by that purpose.
Check residency options at the same time; they change often. On the date this article was checked, OpenAI offered European data residency to eligible API and ChatGPT Enterprise customers, while Anthropic’s own API listed only US and global regions for inference, and the US alone for storage at rest.
Keep secrets out of every memory store. A vault alone does not isolate credentials if the agent has an unrestricted shell; the MCP, skills or CLI article explains how to keep them out of prompts, results and logs.
This section prepares a conversation with your DPO. It is not legal advice.
5. One agent, worked through
Consider a hypothetical team building an agent that answers internal questions about customer contracts. Contracts arrive as Word files, PDFs and scans.
- Standing rules go in
AGENTS.md: no customer identifiers in notes, contract facts only from the contract system, stop if a document is unreadable. - The procedure goes in a skill: find the contract, extract the clause, cite the document and page, flag low-confidence extractions from scans.
- Current facts, such as contract status and renewal date, stay in the contract system. The agent retrieves them for each question. Nothing is copied into memory.
- Run history goes into a database with a retention period agreed with the DPO and a deletion path tested on a sample record.
- The restriction that the agent can read contracts but not modify them sits in the contract system’s permissions, not in the instructions.
- Native memory is switched off for this workflow, because it would capture customer content outside the agreed store.
Each decision has an owner. Each piece of remembered information has one home. Legal review then examines a design, not a promise.
6. When to postpone the build
Data quality decides whether the system makes sense at all. If a company does not record staff arrivals and departures completely, no agent can automate that process: the data simply does not exist. Memory works the same way. If the current contract status is not maintained anywhere reliable, storing yesterday’s answer only preserves the error.
Postpone the build, or narrow the pilot to a safe corpus, when:
- the facts the agent needs are not recorded reliably at the source;
- nobody owns the corrections for a given store;
- legal review cannot approve the storage location or the provider’s terms;
- you cannot delete one record from every copy, including summaries and history.
Saying “not yet” here is cheaper than building a memory that gives confident answers from incomplete data.
7. Test one workflow before widening the system
Choose a recurring task with an observable result. Keep a baseline configuration and compare it with the proposed allocation using the same inputs and comparable permissions. Repeat across fresh sessions and record the client, model and configuration.
| Dimension | Evidence to collect |
|---|---|
| Quality | Correct result, relevant recall, stale facts, missed steps, human corrections |
| Cost | Token or billing records, latency, retrieval, summaries, retries |
| Control | Actions allowed or refused, hook failures, alternate paths, sensitive output |
Include an irrelevant memory, a corrected fact, a procedure that should apply and a prohibited operation. Delete one record and check that it no longer reaches the model, including through summaries or caches. Use synthetic data and synthetic credentials. Set acceptance conditions before the run: the current fact replaces the obsolete one, the deleted record does not reappear, the forbidden action is refused.
For the wider relationship between context, permissions and verification, see our AI agent harness framework.
Conclusion: decide what to remember, then where
Native memory, Git and a database are all reasonable answers to different questions. Start with one repeated correction. Decide whether it is a rule, a procedure, a fact or history, who owns it and what the law requires of it. The store then follows, and legal review has something concrete to approve.
Map one agent’s memory before legal review
Bring one agent or workflow, one correction your team keeps repeating, the places the agent currently stores information and the data classes it touches. We work with your domain expert to assign each item a home, fit it into the tools your team already uses and list what your DPO will need to see.
Designing and running that memory is part of our AI Agents & LLM Products service.
Frequently asked questions
For one client, one team and no customer data, often yes. Confirm where it is stored, how it is deleted and whether it can be switched off for workflows that touch personal data.
For instructions, skills and curated technical notes, yes: you gain review and history. Keep personal data out, because deleting it later means rewriting history and existing clones keep copies.
When several writers or clients share memory, when access differs per item, or when records must expire or be deleted on request. Those needs usually arrive with customer data.
They address different gaps. claude-mem captures tool activity and writes observation notes for later retrieval. Serena provides symbol-level code retrieval and editing, with optional memory. Delta, from Zed Industries and currently in beta, keeps code and agent conversations together. Each adds a store, so each needs the same answers on location, retention and deletion.
To save your own time and money. An expert’s hours are better spent designing the memory than discovering which data you hold, who owns it and whether it is recorded at all.
Sources and limitations
- Anthropic, The components of agent memory: memory and note-correction results in specific evaluations.
- Anthropic, Effective context engineering for AI agents: selecting a small set of high-signal context.
- Chroma, Context rot: performance degradation with longer inputs on controlled tasks.
- Claude Code memory and hooks documentation.
- Codex customisation and hooks on OpenAI’s ChatGPT Learn site.
- Agent Skills specification.
- GDPR, official text, Articles 5, 17, 28, 30 and Chapter V.
- GitHub, Removing sensitive data from a repository.
- CNIL, AI system development: recommendations to comply with the GDPR: purpose, minimisation and retention, for the development phase.
- Codex memories, Anthropic data residency and OpenAI data residency in Europe: volatile product facts.
The contract-agent example is hypothetical. The opening request describes a real enquiry; no client outcome is claimed. Product behaviour is volatile and refers to the linked documentation. This article is not legal advice: the DPO or legal counsel decides what is lawful for each deployment. Sources checked on 19 November 2026.