Skip to navigation

Cloning Graphs

Create complete copies of graphs with new identifiers for testing, migration, or templating

Overview

The graph.clone method creates a complete copy of a graph with a new identifier. Clone a user graph to test or migrate one user’s context. Clone a shared Context Graph to create an isolated test copy of an account, project, product, or business-domain graph, or to use a maintained graph as a template.

The clone request has no body fields. You give only the UUID of the source graph. Zep creates the target graph, gives it a new UUID, and returns the new graph and a task in the response. The response contains the UUID of the copy at once, so store it before the task completes. Use the task to track the copy of the graph data. See Check data ingestion status for polling instructions.

The copy is always a new shared Context Graph, also when the source is a user graph. A clone does not create a user, and it does not copy data into an existing graph.

Clone a Graph

To clone a user graph, use the graph_uuid of the user as the source.

from zep_cloud.client import Zep
client = Zep(
api_key=API_KEY,
)
# The graph_uuid that you stored when you created the user
user = client.user.get(zep_user_uuid)
# Clone the user graph to a new Context Graph
result = client.graph.clone(user.graph_uuid, request={})
# Store the UUID of the copy before the task completes
zep_graph_uuid = result.graph.uuid_
print(f"Cloned graph UUID: {zep_graph_uuid}")
print(f"Clone task UUID: {result.task.uuid_}")

Key Behaviors and Limitations

  • New target: Zep always creates a new graph for the copy. You cannot select the identifier of the copy, and you cannot clone into an existing graph.
  • Identifier at once: The response contains the new graph with its uuid before the copy of the data is complete. Read data from the copy after the task succeeds.
  • User graphs: The copy of a user graph is a shared Context Graph. It is not a user graph, and Zep does not create a new user for it.
  • Retries: Each clone call creates a new graph. If your application can retry a clone, you can send an Idempotency-Key with the call: idempotency_key in Python, idempotencyKey in the TypeScript request options, or option.WithIdempotencyKey in Go.