Agent Memory Cheat Sheet

By Arc Labs Research5 min read

Memory Types

TypeDataRetrievalUse case
ConversationMessages, turnsTemporal, semanticMulti-turn dialogue, context
DecisionActions, outcomesSemantic, causalLearned policies, reasoning
EpisodicEvents, factsTemporal, spatialTimeline reconstruction
SemanticConcepts, rulesSemantic, similarityKnowledge base, reasoning
ProceduralSteps, methodsKeyword, sequenceWorkflows, task chains

Retrieval Modes

ModeInputOutputLatencyUse
KeywordQuery stringExact/substring matches< 1msFast filters
SemanticQuery embeddingTop-K similarity< 50msMeaning-based
HybridQuery + embeddingRanked fusion< 100msBest of both
TemporalTime rangeRecent-first< 10msRecency bias
CausalPrevious eventConsequence links< 50msEffect chains

Retrieval Fusion Methods

Lexical (BM25) score: sr
Semantic (embedding distance) score: se
Metadata filter score: sm

Combined score = w1*sr + w2*se + w3*sm
where w1 + w2 + w3 = 1

Typical: w1=0.3, w2=0.6, w3=0.1

Schema Fields

FieldTypeExampleIndex
agent_idUUID"agent-123"Primary
namespaceString"conversation"Index
contentText"User asked about pricing"FTS + Semantic
embeddingVector[0.1, 0.2, ...]HNSW
metadataJSON{"turn": 5, "user": "u1"}Partial
timestampDateTime"2026-05-12T14:30:00Z"Index
ttlDateTimeExpiry timeIndex

Embedding Models

ModelDimsSpeedCostUse
text-embedding-3-small (OpenAI)512Fast$General-purpose
text-embedding-3-large (OpenAI)3072Slower$$High quality
nomic-embed-text (Nomic AI)768FastFree (OSS)Production OSS
all-MiniLM-L6-v2 (Sentence)384Very fastFree (OSS)Lightweight

Deployment Patterns

Self-Hosted (low latency, high cost per instance)

Agent → Brain SDK → Local/Docker server
Latency: < 10ms
Scaling: Horizontal per agent

Managed Cloud (balanced)

Agent → Brain Cloud API → Managed storage
Latency: < 50ms P99
Scaling: Auto-scaling, multi-region

Hybrid (cache + persistent)

Agent → Redis (cache) → Brain Cloud (persistent)
Latency: < 5ms (cache hit), < 50ms (miss)
Scaling: Redis cluster + managed backend

Configuration Quick Start

Local development

import { Brain } from "brain-ai";

const memory = new Brain({
  model: "memory",
  endpoint: "http://localhost:9090", // self-hosted server: arena + WAL + redb
  embedding: "all-MiniLM-L6-v2",
});

Production Cloud

const memory = new Brain({
  apiKey: process.env.BRAIN_API_KEY,
  agentId: "agent-123",
  region: "us-east-1",
});

API Patterns

Store

await memory.store({
  agentId: "agent-1",
  content: "User prefers async communication",
  type: "preference",
  metadata: { priority: "high" },
});

Retrieve

const results = await memory.retrieve({
  agentId: "agent-1",
  query: "User communication preferences",
  topK: 5,
  filter: { type: "preference" },
});

Batch operations

await memory.batch([
  { action: "store", payload: {...} },
  { action: "retrieve", payload: {...} },
]);

Performance Targets

OperationP50P99P99.9
Store5ms50ms200ms
Retrieve10ms50ms200ms
Search (1M vectors)15ms100ms500ms
Batch (100 ops)50ms500ms2s

Troubleshooting

ProblemCauseFix
High latencyNetwork round-tripCo-locate a self-hosted server or add a cache layer
Low recallPoor embedding modelUpgrade to larger model
High costsToo many vectorsImplement TTL/eviction
Data lossNo persistenceUse managed Cloud, not cache
Semantic driftUnstable embeddingsUse fixed embedding model version

Common mistakes

  1. Using only semantic retrieval — Add keyword filtering for precision
  2. No temporal indexing — Always include timestamp for recency bias
  3. Storing raw conversations — Summarize/compress to reduce vectors
  4. Ignoring metadata — Use JSON metadata for filtering and aggregation
  5. No monitoring — Track retrieval quality and latency percentiles

Further reading

Related reading

Updates from the lab.

Engineering notes, research drops, occasional product updates. Roughly monthly.