The problem
Your AI agent forgets everything between conversations. Users repeat themselves, context is lost, and the experience feels broken.
The solution
Memory gives your agent persistent, searchable storage for facts extracted from conversations. When a user says “I prefer dark mode” or “The client is risk-averse,” those facts are stored and can be retrieved later.
CONVERSATION
User: "Remember that this client prefers conservative
investment strategies"
|
v
EXTRACTION
Facts automatically extracted:
- "Client prefers conservative investment strategies"
|
v
STORAGE
Stored with your tags (tag_1=client_id, tag_2=matter_id, etc.)
-------------------------------------------------------------
LATER...
|
v
RETRIEVAL
Agent asks: "What are this client's preferences?"
Memory returns relevant facts by semantic similarity
How it works
- Add memories - Pass conversation messages, we extract discrete facts
- Search memories - Query by meaning, not just keywords
- Filter by tags - Scope memories using 12 generic indexed tag fields
The API handles:
- Fact extraction (turning “I like X but hate Y” into separate facts)
- Deduplication (updating existing facts instead of creating duplicates)
- Semantic search (finding “investment preferences” when you stored “conservative strategies”)
Quick start
import Casedev from 'casedev';
const client = new Casedev({ apiKey: process.env.CASEDEV_API_KEY });
// 1. Store memories from a conversation
const result = await client.memory.add({
messages: [
{ role: 'user', content: 'Remember that this client prefers conservative investments and is risk-averse.' }
],
tag_1: 'client_123', // Your client ID
tag_2: 'matter_456', // Your matter/case ID
category: 'preference'
});
console.log(result.results);
// [
// { id: 'mem_abc', memory: 'Client prefers conservative investments', event: 'ADD' },
// { id: 'mem_def', memory: 'Client is risk-averse', event: 'ADD' }
// ]
// 2. Later, search for relevant memories
const memories = await client.memory.search({
query: 'investment preferences',
tag_1: 'client_123',
top_k: 5
});
console.log(memories.results[0].memory);
// "Client prefers conservative investments"
Tag fields
Memory provides 12 generic indexed tag fields (tag_1 through tag_12) for filtering. You decide what each tag means for your application:
| Use Case | tag_1 | tag_2 | tag_3 | tag_4 |
|---|
| Legal | client_id | matter_id | attorney_id | session_id |
| Healthcare | patient_id | encounter_id | provider_id | department |
| E-commerce | customer_id | order_id | product_id | session_id |
| Support | user_id | ticket_id | agent_id | channel |
All tag fields are indexed for fast filtering. Use them for any dimension you need to query by.
Example: Legal application
// Store a memory scoped to client + matter
await client.memory.add({
messages: [
{ role: 'user', content: 'The patent filing deadline is March 15th, 2026.' }
],
tag_1: 'client_acme_corp', // Client ID
tag_2: 'matter_patent_2026_001', // Matter ID
tag_3: 'atty_jane_smith', // Attorney ID
category: 'deadline'
});
// Search only this client's deadlines
const deadlines = await client.memory.search({
query: 'upcoming deadlines',
tag_1: 'client_acme_corp',
category: 'deadline',
top_k: 10
});
// List all memories for a specific matter
const matterMemories = await client.memory.list({
tag_1: 'client_acme_corp',
tag_2: 'matter_patent_2026_001'
});
Categories
The category field is free-form text - you define your own categories. Here are suggested categories for different domains:
Legal categories
| Category | Description | Example |
|---|
fact | General facts about client/matter | ”Client founded company in 2019” |
preference | Communication or work preferences | ”Client prefers email updates” |
deadline | Filing deadlines, court dates | ”Motion due March 15th” |
decision | Decisions made by client/court | ”Client approved settlement terms” |
contact | Contact information | ”Client’s assistant is Jane ([email protected])“ |
relationship | Relationships between parties | ”Defendant is client’s former business partner” |
court_ruling | Court rulings and precedents | ”Judge denied motion to dismiss” |
procedural | Procedural information | ”Case assigned to Judge Thompson” |
Healthcare categories
| Category | Description |
|---|
allergy | Patient allergies |
medication | Current medications |
preference | Treatment preferences |
history | Medical history |
family_history | Family medical history |
social | Social/lifestyle factors |
Filtering by category
// Get only deadline memories for a client
const deadlines = await client.memory.list({
tag_1: 'client_123',
category: 'deadline'
});
// Search preferences only
const prefs = await client.memory.search({
query: 'communication method',
tag_1: 'client_123',
category: 'preference'
});
Listing memories
// List all memories for a client
const all = await client.memory.list({
tag_1: 'client_123',
limit: 50
});
// List with multiple filters
const filtered = await client.memory.list({
tag_1: 'client_123',
tag_2: 'matter_456',
category: 'deadline',
limit: 20,
offset: 0
});
console.log(filtered.results); // Array of memories
console.log(filtered.count); // Total count matching filters
Deleting memories
Delete a single memory
await client.memory.delete('mem_abc123');
// Delete all memories for a client
await client.memory.deleteMany({
tag_1: 'client_123'
});
// Delete memories for a specific matter
await client.memory.deleteMany({
tag_1: 'client_123',
tag_2: 'matter_456'
});
Bulk delete removes all matching memories. Use with caution.
Memory events
When you add memories, the API returns what happened to each extracted fact:
| Event | Description |
|---|
ADD | New memory created |
UPDATE | Existing memory was updated/merged |
DELETE | Contradicting info caused memory deletion |
NONE | Duplicate - memory already exists |
const result = await client.memory.add({
messages: [
{ role: 'user', content: 'Actually, the client now prefers phone calls instead of email.' }
],
tag_1: 'client_123'
});
// Result might show:
// { id: 'mem_xyz', memory: 'Client prefers phone calls', event: 'UPDATE' }
// (merged with existing email preference)
To store a fact directly without LLM extraction, set infer: false:
await client.memory.add({
messages: [
{ role: 'user', content: 'Client SSN: 123-45-6789' }
],
tag_1: 'client_123',
category: 'contact',
infer: false // Store as-is, no extraction
});
For domain-specific extraction, provide a custom prompt:
await client.memory.add({
messages: conversation,
tag_1: 'patient_123',
extraction_prompt: `You are a medical memory extraction system.
Extract discrete facts about the patient, focusing on:
- Symptoms and conditions
- Medications and dosages
- Allergies and reactions
- Treatment preferences
Output ONLY a valid JSON array with this structure:
[{"content": "fact", "category": "allergy|medication|symptom|preference", "confidence": 0.9}]`
});
Pricing
| Operation | Cost |
|---|
| Add memory | $0.001 per operation |
| Search | $0.001 per operation |
| List/Get/Delete | Free |
LLM usage for fact extraction and embeddings is billed separately through the LLM service at standard rates.
API reference