Skip to main content
MemLayer organizes every stored memory into one of three types: episodic, semantic, and summary. Selecting the right type isn’t required — MemLayer works if you always pick one — but matching type to content improves retrieval relevance, keeps your agent’s context clean, and makes filtering far more precise.

Episodic

Episodic memories capture things that happened during past interactions. Think of them as a timestamped event log: a complaint the user filed, a product they purchased, a support ticket they opened, or a decision made in a previous session. Because episodic memories are inherently time-bound, MemLayer’s recency signal naturally surfaces the most recent events first when you query. Use memory_type="episodic" when you want to remember what occurred:
from memlayer import MemLayerClient

client = MemLayerClient(api_key="YOUR_API_KEY")

client.remember(
    "User complained that checkout was slow on mobile.",
    user_id="user_abc",
    agent_id="support_bot",
    memory_type="episodic",
    importance=0.8,
)
Good fits for episodic: support tickets, complaints, purchases, user decisions, conversation highlights, errors encountered.

Semantic

Semantic memories hold stable facts about the user — information that rarely changes and doesn’t have a meaningful timestamp. A user’s city, job title, preferred language, dietary restrictions, or subscription tier are all semantic. Because these facts stay relevant across many sessions, they benefit less from recency scoring and more from direct similarity matching. Use memory_type="semantic" when you want to remember what is true about the user:
client.remember(
    "User is based in Lagos, Nigeria, and works as a product manager.",
    user_id="user_abc",
    agent_id="support_bot",
    memory_type="semantic",
    importance=0.7,
)
Good fits for semantic: location, preferences, job role, account type, communication style, language settings, accessibility needs.

Summary

Summary memories are compressed representations of older episodic memories. MemLayer auto-generates summaries as your episodic log grows, collapsing older events into a single dense memory so your agent’s recalled context stays within token limits. You can also store summaries manually — for example, to inject a session recap at the start of a new conversation.
client.remember(
    "User has contacted support three times this quarter: "
    "once about billing, twice about mobile performance. "
    "Issue resolved as of 2024-11-01.",
    user_id="user_abc",
    agent_id="support_bot",
    memory_type="summary",
    importance=0.6,
)
Auto-generated summaries are created by MemLayer in the background — you don’t need to trigger them manually. They appear alongside episodic and semantic memories in recall results.

Choosing the Right Type

TypeBest forExample
episodicEvents, interactions, and timestamped occurrences”User cancelled their order on 2024-10-15”
semanticStable facts and persistent user attributes”User prefers dark mode and communicates in Spanish”
summaryCompressed digests of older episodic history”User had 4 support tickets in Q3, all billing-related”
If you’re unsure which type to use, default to episodic — it’s the most general type and works well for the majority of agent memory use cases.

Filtering by Type

Pass memory_type to recall() to restrict results to a specific category. This is especially useful when your agent has separate retrieval paths — for example, fetching stable user facts before a conversation starts, then fetching relevant events during it.
# Recall only stable facts about the user
facts = client.recall(
    query="Where does the user live?",
    user_id="user_abc",
    agent_id="support_bot",
    memory_type="semantic",
)

for m in facts:
    print(m.content)
You can also filter by type when listing all memories for a user:
# List only episodic memories
page = client.list(
    user_id="user_abc",
    agent_id="support_bot",
    memory_type="episodic",
)

for m in page.memories:
    print(m.content)
Omit memory_type entirely to search across all three types in a single call — MemLayer’s hybrid scorer will rank the best matches regardless of type.