Lesson 66.2 · 2 of 7 · 5 min read · Reviewed 24 Nov 2026
Data retention and zero-data-retention agreements
By the end, you can
- Build a retention schedule for every copy of prompt and output data.
- Explain what a zero-data-retention agreement does and does not cover.
Every prompt your agentAgent: A system where a model decides its own next steps, calling tools in a loop until the task is done. sends can end up stored in more places than anyone planned. Retention is the rule for how long each copy lives before it is deleted. Data protection law in many places (for example the GDPR’s storage limitation principle) expects personal dataPII: Personally identifiable information: data that can identify a person, such as name, email, address or ID numbers. to be kept no longer than needed for its purpose.
Count the copies
| Copy | Who holds it | Typical purpose |
|---|---|---|
| Request and response at the model provider | Provider | Serving the request, abuse and safety monitoring |
| Application logs | You | Errors and audits |
| Traces with prompt text | You or a tracing vendor | Debugging (67.3) |
| Response and semantic caches | You | Speed and cost (70.1) |
| Conversation and memory stores | You | Continuity for the user |
| Vector stores built from user content | You | Retrieval |
| Eval sets copied from real traffic | You | Testing (67.4) |
| Backups of all the above | You or your cloud | Recovery |
A retention schedule
Write one line per copy: what, where, how long, who can read it, how it is deleted. Illustrative example:
| Copy | Kept for | Deleted by |
|---|---|---|
| Trace metadata (ids, timings, tokens) | 13 months | Storage lifecycle rule |
| Trace prompt text, redacted | 14 days | Lifecycle rule |
| Response cache | 24 hours TTL | Cache expiry |
| Conversation history | Until the user deletes it, or 90 days idle | Scheduled job |
| Audit log (66.1) | Set by policy, often years | Legal hold rules |
| Backups | 35 days | Backup rotation |
The point is not these numbers. It is that every copy has one, and that a user’s deletion request reaches every row, including caches, vectors and evalEval: A repeatable test that measures how well an AI system performs on a set of cases with defined success criteria. sets.
Zero data retention
A zero-data-retention (ZDR) arrangement is an agreement with a model provider that inputs and outputs are not stored after the response is returned, except where the agreement says otherwise (for example where the law requires it). Providers that offer it usually do so for approved organisations, under a contract, rather than as a setting anyone can toggle.
What it changes:
- The provider-side copy in the first row of the table goes away (within the stated terms).
What it does not change:
- Every other row. Your tracesTrace: A record of everything that happened during one request or agent run, as a tree of timed steps., caches, memory and backups are yours to control.
- Features that inherently store data, such as stored files, server-side conversation state or asynchronous batch jobs, may be excluded from ZDR or unavailable under it. Each provider documents which of its features are eligible; read that list before designing around a feature.
Worked example
A legal-tech team must promise clients that contract text is not retained by third parties. They:
- Get ZDR in writing from the model provider and check that the features they use are covered.
- Turn off prompt capture in their hosted tracing tool and keep only metadata there.
- Store redactedRedaction: Removing or masking sensitive data, such as PII or secrets, before it is stored, logged or sent. text for 7 days in a self-hosted store for debugging.
- Set the semantic cacheSemantic cache: A cache that returns a stored answer when a new question is similar in meaning to an earlier one. to per-client keys with a short TTL.
- Add a test that deletes a test client and checks every store is empty for that client.
Common mistakes
- Treating ZDR as “we are compliant” while traces keep full prompts for a year.
- Forgetting embeddingsEmbedding: A list of numbers (a vector) that represents the meaning of a piece of text, so similar meanings land close together.: vectors derived from personal data are still tied to it.
- Retention rules on paper with no job that actually deletes anything.
- Copying production prompts into eval sets with no expiry or redaction.
This is general guidance, not legal advice. Retention duties depend on your contracts, your sector and the laws that apply to you; check each provider’s current terms rather than relying on remembered durations.
Key points
- Retention is how long each copy of data is kept; an AI system makes many copies: provider side, logs, traces, caches, vector stores, eval sets and backups.
- A zero-data-retention (ZDR) arrangement means the provider does not keep your inputs and outputs after the request is served, apart from stated exceptions.
- ZDR covers the provider's copies only; your own logs, caches and stores still need their own limits.
- Some features need stored data and may not be available under ZDR; check eligibility before you design around them.
Trace a deletion request through every store
Give every copy of prompt data a retention rule and make one user's deletion reach all of them.
You will have: A retention script that applies each store's rule and proves a deleted user is gone from every store.
Steps
- Run the starter and read which store has no retention rule.
- Give the eval set a rule (for example 180 days) and apply retention to every store.
- Extend delete_user() beyond conversations to traces, caches, vectors and eval sets.
- Check the backups line: explain why rotation, not editing, removes the user there.
Done when
- No store is left without a rule.
- 8 expired rows are removed.
- u_42 is left in no store except backups, which rotate out within 35 days.
Open in the Playground No API key needed.
Starter code (Python)
# Give every copy of prompt data a retention rule, apply it, and make one deletion request reach every store.
# Each row is (user, age in days). The provider copy is gone after serving: this team has a ZDR agreement.
STORES = {
"trace_text": {"keep_days": 14, "rows": [("u_17", 3), ("u_42", 9), ("u_42", 20), ("u_88", 30)]},
"trace_metadata": {"keep_days": 395, "rows": [("u_17", 3), ("u_42", 9), ("u_88", 400)]},
"response_cache": {"keep_days": 1, "rows": [("u_42", 0), ("u_17", 2)]},
"conversations": {"keep_days": 90, "rows": [("u_17", 10), ("u_42", 40), ("u_88", 120)]},
"vectors": {"keep_days": 90, "rows": [("u_42", 40), ("u_88", 120)]},
"eval_set": {"keep_days": None, "rows": [("u_42", 60), ("u_17", 200)]}, # TODO 1: nobody set a rule
"backups": {"keep_days": 35, "rows": [("u_42", 5), ("u_17", 50)]},
}
ROTATES_OUT = {"backups"} # rows here are not edited one by one; they expire when the backup rotates
def missing_rules(stores):
return [name for name, s in stores.items() if s["keep_days"] is None]
def apply_retention(stores):
# TODO 2: drop rows older than keep_days in every store that has a rule; return how many were removed
return 0
def delete_user(stores, user):
# TODO 3: this only clears conversations. Make it reach every store except those in ROTATES_OUT.
s = stores["conversations"]
s["rows"] = [r for r in s["rows"] if r[0] != user]
def where_is(stores, user):
return [name for name, s in stores.items() if any(r[0] == user for r in s["rows"])]
print("no retention rule:", ", ".join(missing_rules(STORES)) or "none")
print("expired rows removed:", apply_retention(STORES))
delete_user(STORES, "u_42")
left = where_is(STORES, "u_42")
print("u_42 left in:", ", ".join(n for n in left if n not in ROTATES_OUT) or "none")
for n in left:
if n in ROTATES_OUT:
print(f"u_42 in {n}: rotates out within {STORES[n]['keep_days']} days")
Show a solution
# Give every copy of prompt data a retention rule, apply it, and make one deletion request reach every store.
# Each row is (user, age in days). The provider copy is gone after serving: this team has a ZDR agreement.
STORES = {
"trace_text": {"keep_days": 14, "rows": [("u_17", 3), ("u_42", 9), ("u_42", 20), ("u_88", 30)]},
"trace_metadata": {"keep_days": 395, "rows": [("u_17", 3), ("u_42", 9), ("u_88", 400)]},
"response_cache": {"keep_days": 1, "rows": [("u_42", 0), ("u_17", 2)]},
"conversations": {"keep_days": 90, "rows": [("u_17", 10), ("u_42", 40), ("u_88", 120)]},
"vectors": {"keep_days": 90, "rows": [("u_42", 40), ("u_88", 120)]},
"eval_set": {"keep_days": 180, "rows": [("u_42", 60), ("u_17", 200)]},
"backups": {"keep_days": 35, "rows": [("u_42", 5), ("u_17", 50)]},
}
ROTATES_OUT = {"backups"} # rows here are not edited one by one; they expire when the backup rotates
def missing_rules(stores):
return [name for name, s in stores.items() if s["keep_days"] is None]
def apply_retention(stores):
removed = 0
for s in stores.values():
if s["keep_days"] is None:
continue
before = len(s["rows"])
s["rows"] = [r for r in s["rows"] if r[1] <= s["keep_days"]]
removed += before - len(s["rows"])
return removed
def delete_user(stores, user):
for name, s in stores.items():
if name not in ROTATES_OUT:
s["rows"] = [r for r in s["rows"] if r[0] != user]
def where_is(stores, user):
return [name for name, s in stores.items() if any(r[0] == user for r in s["rows"])]
print("no retention rule:", ", ".join(missing_rules(STORES)) or "none")
print("expired rows removed:", apply_retention(STORES))
delete_user(STORES, "u_42")
left = where_is(STORES, "u_42")
print("u_42 left in:", ", ".join(n for n in left if n not in ROTATES_OUT) or "none")
for n in left:
if n in ROTATES_OUT:
print(f"u_42 in {n}: rotates out within {STORES[n]['keep_days']} days")