Facts

Precise, time-stamped information capturing detailed relationships about specific events

Overview

Facts are precise and time-stamped information stored on edges that capture detailed relationships about specific events. They include valid_at and invalid_at timestamps, ensuring temporal accuracy and preserving a clear history of changes over time.

How Zep Updates Facts

When incorporating new data, Zep looks for existing nodes and edges in the graph and decides whether to add new nodes/edges or to update existing ones. An update could mean updating an edge (for example, indicating the previous fact is no longer valid).

Here’s an example of how Zep might extract graph data from a chat message, and then update the graph once new information is available:

graphiti intro slides

As shown in the example above, when Kendra initially loves Adidas shoes but later is angry that the shoes broke and states a preference for Puma shoes, Zep attempts to invalidate the fact that Kendra loves Adidas shoes and creates two new facts: “Kendra’s Adidas shoes broke” and “Kendra likes Puma shoes”.

Zep also looks for dates in all ingested data, such as the timestamp on a chat message or an article’s publication date, informing how Zep sets the edge attributes. This assists your agent in reasoning with time.

The Four Fact Timestamps

Each fact stored on an edge includes four different timestamp attributes that track the lifecycle of that information:

Edge attributeExample
created_atThe time Zep learned that the user got married
valid_atThe time the user got married
invalid_atThe time the user got divorced
expired_atThe time Zep learned that the user got divorced

The valid_at and invalid_at attributes for each fact are then included in Zep’s Context Block which is given to your agent:

# format: FACT (Date range: from - to)
User account Emily0e62 has a suspended status due to payment failure. (2024-11-14 02:03:58+00:00 - present)

Adding or Deleting Facts

Facts are generated as part of the ingestion process. If you follow the directions for adding data to the graph, new facts will be created.

Deleting facts is handled by deleting data from the graph. Facts will be deleted when you delete the edge they exist on.

Choosing Between Facts and Summaries

Choosing Between Facts and Summaries

Zep does not recommend relying solely on summaries for grounding LLM responses. While summaries provide a high-level overview, the Context Block should be used since it includes relevant facts (each with valid and invalid timestamps). This ensures that conversations are based on up-to-date and contextually accurate information.