Skip to main content
Build stateful agents with LangGraph that remember context across sessions. Supermemory handles memory storage and retrieval while LangGraph manages your graph-based conversation flow.

Overview

This guide shows how to integrate Supermemory with LangGraph to create agents that:
  • Maintain user context through automatic profiling
  • Store and retrieve relevant memories at each node
  • Use conditional logic to decide what’s worth remembering
  • Combine short-term (session) and long-term (cross-session) memory

Setup

Install the required packages:
Configure your environment:
Get your Supermemory API key from console.supermemory.ai.

Basic integration

A minimal agent that fetches user context before responding and stores the conversation after:

Core concepts

User profiles

Supermemory automatically builds user profiles from stored memories:
  • Static facts: Long-term information (preferences, expertise, background)
  • Dynamic context: Recent activity and current focus

Memory storage

Content you add gets processed into searchable memories:
Search returns both extracted memories and document chunks:

Complete example: support agent

A support agent that learns from past tickets and adapts to each user’s technical level:

Advanced patterns

Conditional memory storage

Not everything is worth remembering. Use conditional edges to filter:

Parallel memory operations

Fetch memories and categorize at the same time:

Metadata filtering

Organize memories by project, topic, or any custom field:

Combining session and long-term memory

LangGraph’s checkpointer handles within-session state. Supermemory handles cross-session memory. Use both:

Next steps

User profiles

Deep dive into automatic user profiling

Search API

Advanced search patterns and filtering

OpenAI SDK

Native OpenAI integration with memory tools

AI SDK

Memory middleware for Next.js apps