Arc Labs
BrainDocsPricing
GitHubSign inGet Started
LearnGuides

Choosing Your Memory Schema

By Arc Labs Research·May 13, 2026·8 min read
TL;DR

Agent memory breaks into four types (fact, event, entity, relation) with different retrieval patterns and costs—choose based on whether your agent needs stateless facts, temporal events, rich entity relationships, or first-order relationships.

The Problem: Choosing the Wrong Memory Type

Agents fail quietly when memory types don't match use cases:

  • Storing temporal events as facts: "User browsed shoes on 2026-05-01" stored as a fact, but you lose the timestamp. Later, you can't answer "What did user do last week?"
  • Storing relationships as facts: "User owns product X" stored as { content: "owns product X" }, but queries miss it because it's worded differently elsewhere ("User purchased X", "owns item X").
  • Mixing types: Some code treats memory as immutable facts, other code updates it. Consistency breaks.
  • No filtering strategy: All queries are semantic search. You pay for expensive embeddings instead of using metadata filters.

Production agents need a schema that matches query patterns and minimizes retrieval cost.

Memory Type Decision Tree

START: What are your primary queries?

1. "What are the user's static facts?"
   ├─ Yes → USE FACT
   │  (Example: "User prefers Nike", "Has budget <$500")
   │  
   └─ No, next question

2. "Do you need temporal sequence or causality?"
   ├─ Yes → USE EVENT
   │  (Example: "User browsed shoes at 10am, bought at 2pm")
   │
   └─ No, next question

3. "Do you model the world as interconnected entities + their attributes?"
   ├─ Yes → USE ENTITY
   │  (Example: Customer + Orders + Products + Preferences, interconnected)
   │
   └─ No, next question

4. "Do you need to query relationships between pairs of things?"
   ├─ Yes → USE RELATION
   │  (Example: "What is the relationship between user-123 and product-456?")
   │
   └─ You don't fit the schema yet—consult docs

Four Memory Types: Comparison Table

TypeContentExampleRetrieval PatternCostWhen to Use
FactStateless, single-valued or categorical"Customer prefers Nike", "Has budget 100–100–100–500"Keyword (metadata) + semanticLowStatic user preferences, category tags, configuration
EventTemporal, causally linked, sequence matters"Clicked product at 10:00am", "Purchased boots at 2pm"Temporal (sort by date) + semanticMediumUser actions, conversation history, time-series events
EntityRich object with typed attributes + relationshipsCustomer { name, email, preferences[], orders[], location }Graph traversal + semanticHighComplex domains (customer + orders + products, all interconnected)
RelationBinary relationship between two entities(user-123) --"purchased"--> (product-456), with metadataRelationship query ("What connects X and Y?")MediumKnowledge graphs, recommendation (who likes what?)

Type 1: Fact (Static Attributes)

Use facts for information that doesn't change or changes rarely.

Schema

interface FactMemory {
  spaceId: string;
  namespace: string;
  
  content: string; // "Customer prefers Nike"
  type: "fact";
  
  metadata: {
    category: string; // "preference", "configuration", "setting"
    value?: string; // "Nike" (optional, for filtering)
    strength?: "strong" | "weak" | "neutral"; // Inferred from frequency
    timestamp: string; // When this fact was observed
  };
}

Retrieval Pattern

import { BrainClient, RecallBuilder } from "@brain-db/sdk";

const auth = { kind: "token", token: new TextEncoder().encode(process.env.BRAIN_API_KEY!) };
const client = await BrainClient.connect("127.0.0.1", 9090, { auth });

// Brain has no client-side metadata filter DSL — fact type, category, and strength live in
// the server's typed graph. Express what you want in the query text; the fusion ranker and
// typed graph resolve it server-side.

// All facts for a customer
const facts = await client.recall(
  new RecallBuilder("facts about customer-12345").maxResults(20).build(),
);

// Preference facts only
const preferences = await client.recall(
  new RecallBuilder("brand and product preferences for customer-12345").maxResults(10).build(),
);

// Strong preferences
const strongPrefs = await client.recall(
  new RecallBuilder("strongest preferences of customer-12345").maxResults(5).build(),
);

// Use the results — episodic hits expose their text
const preferredBrands = preferences.memories.map((hit) => hit.text);

When to Use

  • Customer preferences (brand, price range, size, color)
  • Configuration (notification settings, language, timezone)
  • Tags or categories (VIP customer, at-risk churn, high-value)

When NOT to Use

  • Temporal sequences (use Event instead)
  • Relationships between entities (use Relation instead)

Type 2: Event (Temporal Sequence)

Use events for ordered actions with timestamps.

Schema

interface EventMemory {
  spaceId: string;
  namespace: string;
  
  content: string; // "User clicked product page"
  type: "event";
  
  metadata: {
    timestamp: string; // ISO 8601, required for sorting
    action: string; // "click", "purchase", "view", "message"
    entityId?: string; // Product ID, order ID, etc.
    entityType?: string; // "product", "order", "page"
    outcome?: string; // "success", "failed", "abandoned"
    context?: {
      sessionId?: string;
      source?: string; // "web", "mobile", "api"
    };
  };
}

Retrieval Pattern

// Recent events — recency is a first-class fusion signal, so ask for "most recent"
const recentEvents = await client.recall(
  new RecallBuilder("most recent actions by customer-12345").maxResults(10).build(),
);

// Events in a time window
const lastWeekEvents = await client.recall(
  new RecallBuilder("actions by customer-12345 in the last week").maxResults(50).build(),
);

// Events of a specific action
const purchases = await client.recall(
  new RecallBuilder("purchases by customer-12345").maxResults(20).build(),
);

// Semantic search on events
const shoeBrowsing = await client.recall(
  new RecallBuilder("customer-12345 browsing shoes or boots").maxResults(5).build(),
);

// Use the results — reconstruct the sequence from the returned episodic hits
const timeline = recentEvents.memories.map((hit) => hit.text);
// Reconstruct sequence: clicked product -> added to cart -> purchased

When to Use

  • Conversation history (messages, turn sequence)
  • User actions (clicks, purchases, logins, errors)
  • Time-series data (sensor readings with timestamps)
  • Audit logs (who did what when)

When NOT to Use

  • Static attributes (use Fact instead)
  • Complex object relationships (use Entity instead)

Type 3: Entity (Rich Objects with Relationships)

Use entities when you model a domain as interconnected objects.

Schema

interface EntityMemory {
  spaceId: string;
  namespace: string;
  
  content: string; // JSON serialized or prose description
  type: "entity";
  
  metadata: {
    entityId: string; // Unique ID (customer-123, product-456)
    entityType: string; // "customer", "order", "product", "location"
    
    // Entity attributes (use for filtering and updates)
    attributes?: {
      name?: string;
      category?: string;
      status?: string;
      [key: string]: any;
    };
    
    // Links to related entities
    relations?: {
      customer?: string[]; // Related customer IDs
      products?: string[]; // Related product IDs
      orders?: string[]; // Related order IDs
    };
    
    timestamp: string;
  };
}

// Example: Customer entity
const customerEntity = {
  spaceId: "space-ecommerce",
  content: `
    Customer Sarah Chen (sarah@example.com)
    - Account created 2026-01-15
    - Tier: Gold (lifetime spend >$5000)
    - Preferences: Nike shoes, budget $100–$300, size 8
    - Recent orders: [order-789, order-790]
    - Associated reviews: [review-123, review-124]
  `,
  type: "entity",
  metadata: {
    entityId: "customer-sarah-123",
    entityType: "customer",
    attributes: {
      name: "Sarah Chen",
      email: "sarah@example.com",
      accountCreated: "2026-01-15",
      tier: "Gold",
      lifetimeSpend: 5500,
    },
    relations: {
      orders: ["order-789", "order-790", "order-656"],
      reviews: ["review-123", "review-124"],
      referrals: ["customer-alex-456"],
    },
  },
};

Retrieval Pattern

// Get an entity by name / id
const customer = await client.recall(
  new RecallBuilder("customer-sarah-123 profile").maxResults(1).build(),
);

// Expand relationships — the graph retriever walks entity/relation neighbors server-side
// and fuses them into the result; there is no client-side relation traversal to write.
const orders = await client.recall(
  new RecallBuilder("orders belonging to customer-sarah-123").maxResults(10).build(),
);

// Search by attribute
const goldTierCustomers = await client.recall(
  new RecallBuilder("Gold tier customers").maxResults(50).build(),
);

// Semantic search for entities
const nikeFans = await client.recall(
  new RecallBuilder("customers who prefer Nike shoes").maxResults(20).build(),
);

When to Use

  • Recommendation systems (customers + products + reviews, all interconnected)
  • Knowledge bases (entities + attributes + relationships modeled together)
  • CRM systems (customers, accounts, contacts, interactions)
  • Complex domains where you traverse relationships frequently

When NOT to Use

  • Simple, flat data (use Fact instead)
  • Temporal sequences (use Event instead)
  • You only have 1–2 entity types (use simpler types)

Type 4: Relation (Binary Relationships)

Use relations for first-order relationships between pairs of things.

Schema

interface RelationMemory {
  spaceId: string;
  namespace: string;
  
  content: string; // "Sarah purchased a Nike Air Jordan 1"
  type: "relation";
  
  metadata: {
    subject: string; // "customer-sarah-123"
    subjectType: string; // "customer"
    
    predicate: string; // "purchased", "reviewed", "recommended", "follows"
    
    object: string; // "product-nike-aj1-456"
    objectType: string; // "product"
    
    strength?: number; // 0.0–1.0, confidence/weight of relationship
    timestamp: string; // When relationship was formed
    
    // Optional: relationship details
    context?: {
      reviewScore?: 5; // If predicate is "reviewed"
      quantity?: 1; // If predicate is "purchased"
      reason?: "recommendation_engine"; // Why this relationship?
    };
  };
}

Retrieval Pattern

// What did Sarah purchase?
const sarahPurchases = await client.recall(
  new RecallBuilder("products purchased by customer-sarah-123").maxResults(20).build(),
);

// Who purchased this product?
const aj1Buyers = await client.recall(
  new RecallBuilder("customers who purchased product-nike-aj1-456").maxResults(100).build(),
);

// High-confidence relationships (the ranker surfaces the strongest matches first)
const strongRelations = await client.recall(
  new RecallBuilder("strongest relationships of customer-sarah-123").maxResults(10).build(),
);

// Implicit relationships
const similarTaste = await client.recall(
  new RecallBuilder("customers with a similar purchase history to customer-sarah-123").maxResults(50).build(),
);

When to Use

  • Recommendations (who-bought-what, who-reviewed-what)
  • Social networks (follows, friends, collaborates-with)
  • Knowledge graphs (simple facts about connections)
  • Audit trails (user-performed-action, system-generated-event)

When NOT to Use

  • Static attributes (use Fact instead)
  • Many-to-many relationships with complex logic (use Entity instead)

Schema Design Decision Checklist

  • Identify query patterns: What are your 5 most common queries? (e.g., "Get customer preferences", "What did user do last week?")
  • Map to memory types: Does each query fit fact, event, entity, or relation?
  • Test schema compatibility: Can you answer all 5 queries efficiently with your chosen schema?
  • Design for filtering: Which fields should be indexed for fast metadata filters? (These are cheaper than semantic search.)
  • Define relationships: If using Entity or Relation, define how entities/subjects/objects link.
  • Prototype retrieval: Write recall() calls for each query pattern. Do they return results in <\100ms?
  • Measure costs: Estimate semantic vs. metadata retrieval breakdown. Aim for >70% metadata, <\10% semantic.

TypeScript Interface Examples

Ecommerce Customer Support

// Facts: preferences, settings
interface CustomerPreferenceFact {
  type: "fact";
  metadata: {
    category: "preference" | "setting";
    value: string;
    strength: "strong" | "weak";
    timestamp: string;
  };
}

// Events: browsing, purchases, messages
interface CustomerActionEvent {
  type: "event";
  metadata: {
    action: "browse" | "purchase" | "review" | "inquire";
    entityId: string;
    timestamp: string;
    outcome?: "success" | "abandoned";
  };
}

// Relations: who-bought-what, who-reviewed-what
interface PurchaseRelation {
  type: "relation";
  metadata: {
    subject: string; // customer-id
    predicate: "purchased" | "reviewed" | "refunded";
    object: string; // product-id
    strength: number; // confidence
    timestamp: string;
  };
}

Conversational Agent

// Facts: user properties
interface UserPropertyFact {
  type: "fact";
  metadata: {
    category: "name" | "role" | "location" | "preference";
    value: string;
    timestamp: string;
  };
}

// Events: conversation turns
interface ConversationEvent {
  type: "event";
  metadata: {
    action: "user_message" | "assistant_message" | "function_call";
    role: "user" | "assistant";
    turnNumber: number;
    timestamp: string;
  };
}

// Relations: user-mentions-entity, user-asks-about
interface MentionRelation {
  type: "relation";
  metadata: {
    subject: string; // user-id
    predicate: "mentions" | "asks_about" | "clarifies";
    object: string; // topic, entity
    turnNumber: number;
    timestamp: string;
  };
}

Next Steps

  • Deep dive: See Schema Design Patterns for advanced patterns (hierarchical types, polymorphism)
  • Memory lifecycle: Review Longterm Memory for retention, eviction, and aging strategies
  • Production: Check Cost Optimization for Agent Memory to optimize query cost by schema choice

Related reading

  • ProductionSchema Design Patterns for Agent Memory
  • ProductionLong-Term Memory for Agents
PreviousCost Optimization for Agent MemoryNextSelf-Hosted vs Managed Cloud

Updates from the lab.

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

Arc Labs

Cognitive infrastructure for AI agents. Open core in Rust. Composable primitives you own.

GitHubX / TwitterDiscussions

Brain

  • Memory Layer
  • Documentation
  • Pricing
  • Changelog
  • Status

Developers

  • Start here
  • TypeScript SDK
  • Python SDK
  • Rust SDK
  • MCP Server

Company

  • About
  • Careers
  • Blog
  • Security
  • Contact
Encode"Priya lives in Berlin."mem_7f3a · storedRecall"where does Priya live?"→ BerlinSupersede"Priya moved to Lisbon."mem_9c21 ⊃ mem_7f3aBerlin→ LisbonARC LABSARC LABSARC LABS
© 2026 ARC LABS · BANGALOREPrivacyTermsDPAApache 2.0