Skip to main content
Integrate Graphiti with LangGraph to build sophisticated agents that maintain persistent memory through knowledge graphs, enabling context-aware conversations and personalized responses.

Overview

LangGraph is LangChain’s library for building stateful, multi-actor applications with LLMs. Combined with Graphiti, you can:
  • Maintain persistent conversation memory across sessions
  • Extract and store structured knowledge from interactions
  • Retrieve relevant context using graph-based search
  • Build agents that learn and adapt over time
  • Personalize responses based on user history

Installation

Ensure you have Neo4j or FalkorDB running:

Quick Start Example

This example demonstrates a sales agent that uses Graphiti to:
  1. Remember user preferences and conversation history
  2. Search product knowledge stored in the graph
  3. Personalize recommendations based on learned information

Initialize Graphiti

Load Product Data

Ingest product information into the knowledge graph:

Create User Node

Establish a user entity in the graph:

Define Search Tool

Create a LangChain tool for querying product information:

Build the Agent

Run the Agent

Interactive Agent Loop

Key Integration Patterns

1. Context Retrieval

Use Graphiti’s centered search to retrieve relevant facts:

2. Asynchronous Episode Persistence

Avoid blocking agent responses by persisting episodes asynchronously:

3. Dual Memory Strategy

  • LangGraph MemorySaver: Short-term conversation state within a session
  • Graphiti: Long-term knowledge persistence across sessions

4. Multi-Agent Collaboration

Share knowledge between multiple agents via Graphiti:

Advanced Patterns

Dynamic Tool Generation

Generate tools based on graph entities:

Temporal Context

Leverage Graphiti’s temporal awareness:

Structured Output Integration

Combine Graphiti with LangChain’s structured output:

Visualizing the Knowledge Graph

After interactions, the knowledge graph captures relationships:
Example graph structure:

Best Practices

1. Scope Your Searches

Use center_node_uuid to focus retrieval:

2. Use Group IDs for Multi-Tenancy

3. Balance Concurrency

Adjust SEMAPHORE_LIMIT based on LLM tier:

4. Implement Error Handling

Example: Multi-Agent Customer Service

LangSmith Integration

Trace agent execution with LangSmith:

Resources

Next Steps