TOOL WIKI · MEMORY & STATE

Graphiti

Builds and queries time-aware context graphs with provenance.

Download example files Code + setup + checks in a ZIP
Jump to a section 10 sections

EXAMPLE USE CASE

Recall a preference with episode provenance

A returning user’s preference or an unfinished run needs an explicit owner, storage lifetime and recall rule.

Input
An episode, reference time, source description and group ID.
Expected output
Extracted facts matching the response-format question.
  • Success check: The stored preference can be recalled for the intended user. Inspect the record and its source rather than only the generated answer.
  • Try a failure: Search another group and verify that scoped facts are not returned.

Example scope: Actual temporal-graph ingestion/search using configured graph and model services.

Official reference · Graphiti

WHAT IT ISTemporal graph framework
WHERE IT FITSMemory & state
SEE HOW THE SYSTEM FITS TOGETHERSELECT A COMPONENT
candidateretainqueryrecordscontextmaintainInteractionSubject + evidenceWrite policySelect and verifyGraphitiTemporal graph frameworkRecall requestAuthenticated scopeContext builderRelevant selected factsLifecycle controlsCorrect, expire, delete
  1. Separate working conversation state from candidate long-term facts.

  2. Retain only permitted information and preserve where it came from.

  3. Representing changing entities, relationships, and historical facts. It is a graph-building framework; choose and operate the backing store.

  4. Use verified tenant and subject identifiers when retrieving memory.

  5. Choose useful records within the current context budget.

  6. Apply corrections and deletion to records, derived indexes, and caches.

Graphiti

Representing changing entities, relationships, and historical facts. It is a graph-building framework; choose and operate the backing store.

Follow the arrows, then select a component to inspect its responsibility. On mobile, downward arrows connect the next step; bent arrows identify branches and return paths. Select a destination to jump to that component.

When to consider it

  • Representing changing entities, relationships, and historical facts.

A design decision to make

  • It is a graph-building framework; choose and operate the backing store.

Prerequisites and setup

  • A compatible Neo4j service, a restricted scratch database and provider credentials for extraction/embedding.
  • This example uses Graphiti’s default OpenAI clients; configure alternative clients explicitly when changing provider.
Shell
python3 -m venv .venv
source .venv/bin/activate
pip install graphiti-core
export OPENAI_API_KEY="YOUR_KEY"
export NEO4J_URI="bolt://localhost:7687"
export NEO4J_USER="neo4j"
export NEO4J_PASSWORD="YOUR_LOCAL_PASSWORD"

Try a small integration

memory.py

Python · memory.py
import asyncio
import os
from datetime import datetime, timezone
from graphiti_core import Graphiti
from graphiti_core.nodes import EpisodeType

async def main():
    graph = Graphiti(os.environ["NEO4J_URI"],os.environ["NEO4J_USER"],os.environ["NEO4J_PASSWORD"])
    try:
        await graph.build_indices_and_constraints()
        await graph.add_episode(name="format-preference", episode_body="Demo User prefers concise bullet answers.",
            source=EpisodeType.text, source_description="Explicit user preference in demo conversation",
            reference_time=datetime.now(timezone.utc), group_id="asg-demo-user")
        results = await graph.search("What answer format does Demo User prefer?", group_ids=["asg-demo-user"])
        print([r.fact for r in results])
    finally:
        await graph.close()

asyncio.run(main())

Run and check the result

Shell
python memory.py
  • The stored preference can be recalled for the intended user. Inspect the record and its source rather than only the generated answer.
  • A different user must not inherit this preference.

Common failures

  • Extraction acceptance does not establish immediate query visibility; inspect job/index state when results are empty.
  • Do not silently copy memory across users after a failed lookup.

Production decisions

  • Define allowed memory types, evidence/provenance, correction, expiry and user deletion before accepting automatic writes.
  • Derive user and tenant scope from authenticated application state. Test cross-user recall, expired facts and deletion from every derived index.
  • A group_id partitions retrieval; application authorization must decide which group IDs the caller may access. Validate temporal conflicts and graph-summary deletion.

Keep exploring

A layered architecture for agent memoryA context pipeline for a long-running agent

Explore the same layer

Mem0LettaZepCognee

Compare candidates on your own workload. This entry describes a product’s role; it is not a claim that products in the category are interchangeable.