# How to keep sensitive data out of your agent's context

By Mehul Patel · Dec 01, 2026 · https://www.getzep.com/blog/sensitive-data-agent-context/ · Tags: Governance and security, Context graphs

Zep content policies stop sensitive details like a medical diagnosis from becoming facts that your agents can retrieve.

**Key takeaways**

- **Agents keep what end users tell them.** Zep persists what users say as facts in their [context graph](https://www.getzep.com/platform/context-lake/), including sensitive details no task needs, such as a health condition.
- **Content policies decide which facts Zep persists.** You write rules for the details to keep out, and Zep checks each fact and summary against them before persisting it.
- **Zep drops matching facts and any it is unsure about.** Facts from the same message that pass your rules are still persisted.
- **Content policies are free for all Zep accounts for the next 90 days.** Zep copies the current policy to each user when it creates the user, and that copy never changes. A user that you created before you wrote the policy has no policy, so write your rules before you add production users.

Agents get more useful as they learn from what users tell them. Zep turns what users say into facts and summaries in their context graph. That can include sensitive details no task needs, such as a health condition or a debt. Those details stay available to later sessions and to other agents that read the graph. Access control limits which agents can read a fact, but it does not decide which facts Zep persists.

Content policies decide which details Zep persists as facts and summaries in the first place. You write rules for the kinds of information to keep out, and Zep checks each fact and summary against them before persisting it. Anything that matches is dropped. The rest of the conversation still becomes context your agents can use.

## How one message becomes shared context

A single message can end up in several places in a user's graph. As an example, a member named Dana Ortiz asks her health insurer's billing assistant to move her premium due date to the 20th. She is taking a few weeks off work to recover from knee surgery.

![A member's premium request yields billing, health, attribute, and summary items; Zep persists the billing fact and drops the rest.](https://www.getzep.com/blog/sensitive-data-agent-context/content-policy-message-flow.png)

A content policy checks each derived item after extraction and before Zep persists it, and Zep drops the items that your rules do not allow.

From that one message, extraction can derive a fact that links the request to her treatment. It can also set an attribute on Dana's entity, a field that says she is recovering from knee surgery. Her user summary can gain a line about it too. Each one is now retrievable by every later session and by any agent that reads Dana's graph, including one that sells supplemental coverage.

Summaries are rewritten from earlier summaries, so a sensitive line can be carried forward after the original message is out of view.

## HIPAA's minimum necessary rule and AI agents

Health insurers are [covered entities](https://www.hhs.gov/hipaa/for-professionals/covered-entities/index.html) under HIPAA, so its Privacy Rule governs how they use members' health information. The rule's [minimum necessary requirement](https://www.hhs.gov/hipaa/for-professionals/privacy/guidance/minimum-necessary-requirement) asks a covered entity to take reasonable steps to limit each use or disclosure of protected health information to what its purpose needs, with some exceptions. It also expects the insurer to decide which people need access to health information, and which kinds of it each one needs for their job.

Dana's surgery is already in the insurer's claims records, where the insurer decides which roles may see it. The billing assistant's context creates a second copy, attached to a premium question that never needed it and readable by every agent that reads Dana's graph.

To prevent that second copy, Zep must check each fact and summary before it persists the item, at the step where context is built. The same check can also keep a graph to the facts each task needs.

## Where deletion and access control fall short

Deletion and access control each handle part of the problem of sensitive facts.

**Deletion after the fact.** Deletion removes a fact after someone finds it. By then, the fact may already have appeared in answers and been folded into summaries.

**Access control.** [Attribute-based access control (ABAC)](https://www.getzep.com/blog/attribute-based-access-control/) controls which users and agents can read which context. The fact itself stays in the graph.

| Control | When it acts | What it does | What it misses |
| --- | --- | --- | --- |
| Deletion | After someone finds the fact | Removes the fact | Answers and summaries can already contain the fact |
| ABAC | When a user or agent reads | Limits which users and agents can read which context | The fact stays in the graph |
| **Content policies** | **After extraction, before persisting** | **Drops matching facts, attributes, and summaries. Include rules keep a named fact type only when the fact matches the rule.** | **The source message stays stored as sent** |

When each control acts in agent context, and what it misses. Content policies and ABAC work together.

## How Zep content policies work

[How Zep content policies keep sensitive details out of your agent's context](https://www.youtube.com/embed/z4BfkGkR7FY?feature=oembed)

Video walk-through of Zep content policies

### Categories and rules

A content policy is a set of categories and rules that you write for a project. A category names a class of information, such as `health_information`. A rule belongs to one category and works in one of two directions. An exclude rule names information that must not enter the graph. An include rule names the only information of a given type that may enter, for entity or edge types defined in your [graph ontology](https://www.getzep.com/blog/type-hierarchies-zep-ontology/). It does not affect other types or summaries. A project policy holds up to 16 categories and 32 rules.

A rule can match an item by its ontology type, by regular-expression patterns, or by a plain-language condition. Patterns are case-insensitive RE2 expressions, up to eight per rule, and they run in code. A condition goes to a language model classifier, guided by prohibited and permitted examples of borderline cases. Zep checks type and pattern matches first and calls the classifier only when neither matched.

This example assumes that the project ontology defines the `REQUESTED_PAYMENT_CHANGE` and `HAS_PAYMENT_PREFERENCE` edge types.

`PUT /project/content-policy` sets this policy:

```json
{
  "categories": [
    {
      "key": "health_information",
      "description": "Health conditions, diagnoses, and treatments of a member"
    },
    {
      "key": "billing",
      "description": "Facts the billing assistant needs"
    }
  ],
  "rules": [
    {
      "category_key": "health_information",
      "condition": "A health condition or treatment of an identifiable member.",
      "patterns": ["\\bsurger(y|ies)\\b", "\\bphysical therap(y|ist)\\b"],
      "prohibited_examples": [
        "Dana Ortiz is recovering from knee surgery.",
        "The member has type 2 diabetes."
      ],
      "permitted_examples": [
        "Dana Ortiz asked to move her premium due date to the 20th.",
        "The member prefers email reminders."
      ]
    },
    {
      "category_key": "billing",
      "action": "include",
      "edge_types": ["REQUESTED_PAYMENT_CHANGE", "HAS_PAYMENT_PREFERENCE"],
      "condition": "A fact about the member's premium, payment schedule, or billing account."
    }
  ]
}
```

### What happens to each derived item

Zep evaluates every item that ingestion derives from an episode before it adds the item to the context graph. That covers facts, entities, entity attributes and summaries, and thread and document summaries. Each item reaches one of four outcomes:

- **An exclude rule matches.** Zep drops the item and flags the episode with the matched category.
- **The classifier is uncertain.** Zep drops the item, and its audit event shows the reason `indeterminate`.
- **The item's type has an include rule, and the item does not match it.** Zep drops the item as not included, without flagging the episode.
- **Nothing blocks the item.** Zep persists it.

If a classifier call fails, Zep retries the evaluation under the ingestion retry policy. Zep persists no item from the episode until the evaluation completes. The ingestion task stays `processing` during the retries. If the last retry fails, the task ends as `failed` with the error code `content_policy_evaluation_failed`, and the episode status becomes `failed`.

![A derived item passes type and pattern checks, a condition classifier, and an include rule, or it is dropped on a match or uncertainty.](https://www.getzep.com/blog/sensitive-data-agent-context/content-policy-decision-flow.png)

Code checks run before the classifier, and Zep drops an item when the classifier is uncertain.

An exclude match always takes precedence over an include match. Zep drops a related item only when it depends on a dropped item. A fact from the same episode that connects to a dropped entity is dropped with it, and a contradiction that depended on a dropped fact is not applied. Permitted items from the same episode are still persisted.

For Dana's message, the payment request is a billing fact, so Zep persists it. The surgery fact and the "recovering from knee surgery" attribute match the health rule's pattern in code and are dropped. The summary update matches the rule's condition, so her user summary keeps its earlier version. If extraction writes a single fact that combines the request and the surgery, Zep drops that fact whole. The policy never rewrites a fact into something the member did not say.

The episode itself is kept exactly as sent, under your existing retention settings, so the source record stays intact for [provenance](https://www.getzep.com/blog/how-zep-tracks-provenance-in-agent-memory/). [Context assembly](https://www.getzep.com/blog/smart-context-assembly-fewer-tokens-higher-quality/) excludes flagged episodes, and by default episode lists and episode search omit them too. When an episode is flagged after a summary used it, Zep withdraws that summary and rebuilds it from eligible inputs.

### See what Zep dropped

Zep records each drop as an audit event. The event identifies the episode, the item kind, and the matched categories and rules. It also records how each rule matched and the reason for the drop, such as `match` or `indeterminate`. Events hold only identifiers and never hold the dropped text. You can filter the events by episode or by reason.

```python
from zep_cloud import Zep

client = Zep(api_key="YOUR_API_KEY")
events = client.graph.list_content_policy_events(
    graph_uuid="YOUR_GRAPH_UUID",
    filters={"drop_reason": "match"},
)
for event in events.items:
    print(event.episode_uuid, event.artifact_kind, event.category_keys, event.rule_ids)
```

Each episode also shows its matched categories and the counts of persisted and dropped items.

## Why the policy belongs where context is built

A filter outside the graph sees the text that goes in and the context that comes out. Zep's content policy runs at the step where context is built, so it sees each fact, attribute, and summary that extraction produces, including summaries rewritten from many conversations. A summary can combine several messages into a statement that none of them made alone, and the policy checks the summary before any agent can read it. If the raw text must never reach Zep at all, filter it before you send it.

Include rules bring the minimum necessary idea to individual fact types. The billing assistant's payment facts are kept only when they meet the billing condition. The supplemental-coverage agent never sees Dana's surgery, because Zep persisted no fact about it and context assembly leaves her flagged message out. The application still passes recent messages to the model directly, so the current conversation can account for everything Dana said.

Content policies add a third control to the governance model of the [Context Lake](https://www.getzep.com/platform/context-lake/). ABAC decides which agent can read which context. Retention policies decide how long context lives. Content policies decide which facts and summaries Zep derives into the graph in the first place.

![Content policies filter derived items before a context graph; ABAC controls which users and agents read it, and retention sets how long it stays.](https://www.getzep.com/blog/sensitive-data-agent-context/content-policy-governance-layers.png)

ABAC and retention govern context already in the graph, and a content policy decides which derived items Zep persists.

## Getting started with content policies

[Content policies](https://help.getzep.com/content-policies) are free for all Zep accounts for the next 90 days. Zep copies the current policy to each user when it creates the user, and a later change to the policy does not apply to that user. Write the policy before you create production users. There is no dry run, so test the rules on a test graph with your own conversations before you rely on them. A language model makes the condition decisions, so treat content policies as one control among several for regulated data, alongside access control and retention.

Read the [content policies documentation](https://help.getzep.com/content-policies).

## FAQ

### What is a Zep content policy?

A content policy is a set of categories and rules that you write for a Zep project. Before Zep persists a fact, entity attribute, or summary that ingestion derives from an episode, it checks the item against the rules. Zep drops an item that matches an exclude rule, that the classifier is unsure about, or that the include rules for its type do not allow. Zep also drops an item that depends on a dropped item. The other items from the episode still become context in the context graph.

### Does a content policy change the stored message?

No. A content policy checks only the items that Zep derives from an episode. The source episode stays stored as sent, under your retention settings, so the record stays intact for provenance. Context assembly excludes flagged episodes, and by default episode lists and episode search omit them. If the raw text must never reach Zep, filter it in your application before you send it.

### How do content policies compare with ABAC and retention policies?

Each control acts at a different step. A content policy decides which facts and summaries Zep derives into the graph. ABAC decides which users and agents can read the context in the graph. Retention policies decide how long that context stays. A language model makes the condition decisions of a content policy, so use the three controls together for regulated data.

### Does a policy change apply to existing users?

No. Zep copies the current project policy to each user when it creates the user. A later change to the project policy does not apply to that user, and a user that you created before you wrote the policy has no policy. Write the policy and test it on a test graph before you create production users.
