Skip to navigation

Deleting Data from the Graph

Delete edges, nodes, episodes, threads, users, and shared Context Graphs

Each delete method in this page takes the UUID of the item. The graph artifact methods also take the UUID of the graph that contains the item. A delete is asynchronous: the call returns a task, and Zep removes the data in the background. See Check data ingestion status to poll a task.

Delete an Edge

Here’s how to delete an edge from a graph:

from zep_cloud.client import Zep
client = Zep(
api_key=API_KEY,
)
result = client.graph.edge.delete(graph_uuid, edge_uuid)
print(f"Delete task UUID: {result.task.uuid_}")

Note that when you delete an edge, it never deletes the associated nodes, even if it means there will be a node with no edges.

Delete a Node

Here’s how to delete a node from a graph:

from zep_cloud.client import Zep
client = Zep(
api_key=API_KEY,
)
result = client.graph.node.delete(graph_uuid, node_uuid)
print(f"Delete task UUID: {result.task.uuid_}")

Deleting a node will also delete all edges connected to that node. This is a cascading delete operation - the node and all its relationships are permanently removed from the graph.

Delete an Episode

Deleting an episode does not regenerate the names or summaries of nodes shared with other episodes. This episode information may still exist within these nodes. If an episode invalidates a fact, and the episode is deleted, the fact will remain marked as invalidated.

When you delete an episode:

  • Edges are deleted only if no other episodes are associated with them. An edge associated with other episodes will be preserved.
  • Nodes are deleted only if no other episodes are associated with them. A node associated with other episodes will be preserved.
  • User entity exception: For user graphs, the user entity node is never deleted when an episode is deleted. The user entity is created automatically when the user is created, before any episodes are added, so it is always preserved.

Here’s how to delete an episode from a graph:

from zep_cloud.client import Zep
client = Zep(
api_key=API_KEY,
)
result = client.graph.episode.delete(graph_uuid, episode_uuid)
print(f"Delete task UUID: {result.task.uuid_}")

How episodes become associated with edges and nodes

Whether an edge or node survives an episode deletion depends on its episode associations — the links between an episode and the artifacts Zep derived from it. For a full explanation of how episodes associate with edges, nodes, and the other context types, how to inspect those associations, and how episode metadata projects across them, see Episode metadata projection.

Delete a Thread

Deleting a thread removes all episodes associated with that thread. This triggers a cascading effect on the graph.

When a thread is deleted, each associated episode is removed. For each episode:

  • Edges are deleted only if no other episodes are associated with them
  • Nodes are deleted only if no other episodes are associated with them
  • User entity exception: For user graphs, the user entity node is never deleted, even if all episodes are removed. The user entity is created when the user is created, before any episodes are added, so it is always preserved.

This design preserves graph integrity. If multiple conversations mention the same entity or establish the same relationship, deleting one thread will not remove data that other threads contributed to the graph.

Here’s how to delete a thread:

from zep_cloud.client import Zep
client = Zep(
api_key=API_KEY,
)
# The thread UUID that you stored when you created the thread
result = client.thread.delete(zep_thread_uuid)
print(f"Delete task UUID: {result.task.uuid_}")