Skip to content

Memory Types

MemoryLayer uses a two-layer classification system for memories, inspired by cognitive science and developer workflow research.

Cognitive Types

Every memory has a cognitive type that describes how it is structured and retained. If you omit type on a write, the server classifies the content and picks one.

Episodic Memory

What happened — specific events and interactions.

  • Decays naturally over time
  • Timestamped and contextual
  • Best for tracking what occurred during sessions
await client.remember(
content="Discovered a race condition in the payment service during load testing on Feb 3",
type=MemoryType.EPISODIC,
importance=0.8,
tags=["payment", "bug", "load-testing"]
)

Semantic Memory

What is true — facts, concepts, and relationships.

  • Permanent until explicitly modified or superseded
  • Forms the backbone of the knowledge graph
  • Best for preferences, decisions, and factual knowledge
await client.remember(
content="The project uses PostgreSQL 16 with pgvector for embeddings",
type=MemoryType.SEMANTIC,
importance=0.7,
tags=["database", "architecture"]
)

Procedural Memory

How to do things — processes, patterns, and solutions.

  • Permanent and reusable
  • Often linked to problem memories via SOLVES relationships
  • Best for solutions, workflows, and code patterns
await client.remember(
content="To fix CORS issues: add allowed origins to FastAPI middleware via CORSMiddleware",
type=MemoryType.PROCEDURAL,
importance=0.8,
tags=["cors", "fastapi", "fix"]
)

Working Memory

Current context — what’s happening right now.

  • Session-scoped with TTL
  • Automatically expires when the session ends
  • Can be committed to long-term storage (episodic/semantic) via commit_session()
  • Best for tracking current task state
await client.set_context(
session_id,
"current_task",
{"description": "Debugging auth flow", "file": "auth.py", "line": 42}
)

Domain Subtypes

An optional second classification that describes what the memory is about. Subtypes work across all cognitive types.

SubtypeDescriptionTypical Cognitive Type
solutionWorking fixes to problemsProcedural
problemIssues encounteredEpisodic
code_patternReusable code patternsProcedural
fixBug fixes with contextProcedural
errorError patterns and resolutionsSemantic
workflowProcess knowledgeProcedural
preferenceUser or project preferencesSemantic
decisionArchitectural decisionsSemantic
profilePerson or entity profilesSemantic
entityNamed entities (people, places, things)Semantic
eventSignificant events or milestonesEpisodic
directiveUser instructions and constraintsSemantic
inferenceDerived conclusions synthesized from other memories (written by the server)Semantic
factAtomic facts produced by fact decomposition (written by the server)Semantic

The server also manages system subtypes for skills, MCP server entries, and Repository Planning Graph nodes. See the Memory Types & Subtypes Reference for the full list.

Combining Types and Subtypes

# A decision (semantic + decision)
await client.remember(
content="Chose SQLite over PostgreSQL for local development for zero-config deployment",
type=MemoryType.SEMANTIC,
subtype=MemorySubtype.DECISION,
importance=0.9,
tags=["database", "architecture"]
)
# A bug fix (procedural + fix)
await client.remember(
content="Fixed memory leak in WebSocket handler by closing connections in finally block",
type=MemoryType.PROCEDURAL,
subtype=MemorySubtype.FIX,
importance=0.8,
tags=["websocket", "memory-leak", "bug"]
)

Importance Scoring

Every memory has an importance score between 0.0 and 1.0:

ScoreLevelExamples
0.9–1.0CriticalSecurity vulnerabilities, breaking changes, core architecture decisions
0.7–0.8HighBug fixes, API changes, important patterns
0.5–0.6StandardPreferences, general knowledge, minor solutions
0.3–0.4LowObservations, temporary workarounds
0.0–0.2EphemeralDebugging traces, session context

Decay

Memories can have their importance reduced over time using the decay() operation:

# Reduce importance by 10%
await client.decay("mem_123", decay_rate=0.1)

This is useful for episodic memories that become less relevant over time, while keeping semantic and procedural memories stable. Pinned memories (pinned: true) are exempt from decay.

Event Time

A memory can carry an event_time: when the thing it describes happened, as opposed to when it was stored. The server sets it during ingestion. For example, an email’s send time becomes the event_time of the email memory, and decomposed facts carry the date of their source. When event_time is empty, the memory’s effective time is its created_at. Recall can filter and order by effective time. See Temporal recall.

Choosing the Right Type

ScenarioCognitive TypeSubtypeImportance
“User prefers dark mode”SemanticPreference0.6
“Fixed CORS by adding middleware”ProceduralFix0.8
“Decided to use JWT for auth”SemanticDecision0.9
“Encountered timeout in CI pipeline”EpisodicProblem0.5
“Deploy process: git push → CI → staging → prod”ProceduralWorkflow0.7
“ECONNREFUSED means Redis isn’t running”SemanticError0.6