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.
Copy
Ask AI
CONVERSATIONUser: "Remember that this client prefers conservative investment strategies" | vEXTRACTIONFacts automatically extracted: - "Client prefers conservative investment strategies" | vSTORAGEStored with your tags (tag_1=client_id, tag_2=matter_id, etc.)-------------------------------------------------------------LATER... | vRETRIEVALAgent asks: "What are this client's preferences?"Memory returns relevant facts by semantic similarity
// Store a memory scoped to client + matterawait 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 deadlinesconst deadlines = await client.memory.search({ query: 'upcoming deadlines', tag_1: 'client_acme_corp', category: 'deadline', top_k: 10});// List all memories for a specific matterconst matterMemories = await client.memory.list({ tag_1: 'client_acme_corp', tag_2: 'matter_patent_2026_001'});
// List all memories for a clientconst all = await client.memory.list({ tag_1: 'client_123', limit: 50});// List with multiple filtersconst 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 memoriesconsole.log(filtered.count); // Total count matching filters
// Delete all memories for a clientawait client.memory.deleteMany({ tag_1: 'client_123'});// Delete memories for a specific matterawait client.memory.deleteMany({ tag_1: 'client_123', tag_2: 'matter_456'});
Bulk delete removes all matching memories. Use with caution.
For domain-specific extraction, provide a custom prompt:
Copy
Ask AI
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 preferencesOutput ONLY a valid JSON array with this structure:[{"content": "fact", "category": "allergy|medication|symptom|preference", "confidence": 0.9}]`});