Agent Memory for Customer Support
The Problem: Why Stateless Chat Fails
Traditional support chatbots treat every interaction as isolated. When a customer returns:
- No context: Agent asks "What's your issue?" again, ignoring the ticket from last week.
- Repeat questions: "When did this start?" "What's your account number?" Customer repeats themselves every turn.
- No pattern recognition: Agent doesn't know this customer always prefers async responses, or that this issue has 3 known workarounds.
- Escalation fatigue: Agent escalates to humans with zero history, forcing humans to re-read old tickets and re-establish context.
Result: Slower resolution times, customer frustration, wasted human effort.
Agent memory solves this by storing what the agent learns, so it remembers across sessions and surfaces relevant context instantly.
Memory Types for Support
A support agent needs four types of memory:
| Type | Content | Example | Retrieval |
|---|---|---|---|
| Conversation History | Messages, turn sequences | User's last 3 messages + agent responses | Temporal (recent-first) |
| Customer Facts | Account info, preferences, settings | "Prefers email over phone", "Timezone: PST", "VIP tier" | Keyword + semantic |
| Policy Decisions | Approvals, refunds, exceptions | "Approved $50 refund on 2026-05-10" | Keyword + semantic |
| Solutions Tried | Past troubleshooting, workarounds | "Cleared cache (worked)", "Reinstalled app (failed)" | Semantic + causal |
Retrieval Pattern: "Multi-Level Context Pyramid"
When a customer message arrives, retrieve in order:
1. Last 10 conversation turns (temporal)
→ Agent knows what was just said
2. Customer facts (semantic keyword: "customer preferences")
→ Agent knows this customer's settings and personality
3. Similar past tickets (semantic: embedding of customer's current message)
→ Agent finds 3 past tickets with same/similar issue
4. Solutions tried in those tickets (causal: what was attempted, did it work?)
→ Agent avoids suggesting failed approachesExample:
import { Brain } from "brain-ai";
const memory = new Brain({
namespace: "support",
});
// When customer message arrives:
async function handleSupportQuery(customerId: string, message: string) {
// 1. Get recent conversation
const recentTurns = await memory.retrieve({
agentId: `support-${customerId}`,
query: "What did we just discuss?",
topK: 10,
filters: { type: "conversation" },
});
// 2. Get customer preferences
const preferences = await memory.retrieve({
agentId: `support-${customerId}`,
query: "customer preferences communication style",
topK: 3,
filters: { type: "customer_fact" },
});
// 3. Get similar past tickets
const similarTickets = await memory.retrieve({
agentId: `support-${customerId}`,
query: message, // Semantic similarity
topK: 3,
filters: { type: "conversation" },
});
// 4. Build context for agent
const context = {
recentTurns,
preferences,
similarTickets,
};
// Agent uses context to craft response
const response = await agent.chat(message, context);
// 5. Store agent response in memory
await memory.store({
agentId: `support-${customerId}`,
content: `Customer: ${message}\nAgent: ${response}`,
type: "conversation",
metadata: {
customerId,
turn: recentTurns.length + 1,
timestamp: new Date().toISOString(),
},
});
return response;
}Example: Support Agent Remembers
Customer returns after 2 months:
Customer: "Hi, I'm having issues with my export again."
Agent lookup:
1. Conversation history: Empty (new session)
2. Customer facts:
- "Prefers email over phone"
- "Timezone: PST (UTC-7)"
- "VIP tier, 2-hour SLA"
3. Similar past tickets:
- Ticket #2401 (8 weeks ago): "Export timing out"
Solution: "Increased database timeout from 30s to 60s"
- Ticket #2156 (4 months ago): "Export returns empty"
Solution: "Filter syntax issue, corrected to use 'AND' not 'OR'"
4. Solutions tried:
- #2401: Increased timeout → WORKED
- #2156: Filter syntax fix → WORKED
Agent response:
"I see you had export issues before. Last time, increasing the timeout from 30s to 60s fixed it. Let's try that first. I'm sending the fix via email (as you prefer) and will follow up by 4pm PST."Without memory: Agent asks "What version are you using?" "When did this start?" "Have you tried restarting?" Customer repeats themselves. 30 minutes later, agent finds old ticket and apologizes for wasted time.
With memory: Agent knows the history, avoids failed approaches, respects preferences, delivers solution in 5 minutes.
Memory Schema for Support
Design your memory schema for easy retrieval:
interface SupportMemory {
agentId: string; // "support-{customerId}"
namespace: "support";
// What was stored
content: string; // The actual message or fact
// How to retrieve it
type: "conversation" | "customer_fact" | "policy_decision" | "solution_tried";
metadata: {
customerId: string;
ticketId?: string;
turn?: number; // For conversation ordering
timestamp: string;
// For solutions_tried: did it work?
outcome?: "success" | "failure" | "partial";
// For customer facts: category
category?: "communication" | "timezone" | "tier" | "account";
// For policy decisions: who approved?
approver?: string;
};
}Use-Case Decision Table
When should you use structured vs. unstructured memory for support?
| Decision | Structured (Typed Fields) | Unstructured (Free Text) | Example |
|---|---|---|---|
| Conversation history | Only if you need causal linking | Yes, unstructured | Store as-is: turn sequence, timestamps |
| Customer facts | Yes, strongly typed | No | { type: "customer_fact", category: "timezone", content: "PST" } |
| Policy decisions | Yes, include approver + amount | Optionally include reason | { outcome: "refund_approved", amount: 50, approver: "manager_x" } |
| Solutions tried | Yes, include outcome (success/failure) | Optionally describe why | { solution: "increased timeout", outcome: "success" } |
Rule of thumb: Typed fields for data you'll filter, sort, or check the outcome of. Unstructured for narrative/explanation.
Metrics: Impact of Agent Memory
Organizations using agent memory for support see:
- 30% faster resolution time: Agent remembers history, avoids re-reads
- 20% fewer escalations: Agent has context, makes better decisions
- 50% fewer repeat questions: Agent knows customer preferences and past issues
- Customer satisfaction +15%: Customers feel understood, not re-explained
Implementation Checklist
- Design memory schema (conversation, customer facts, solutions, policies)
- Implement retrieval pipeline (recent turns → facts → similar tickets → solutions tried)
- Add memory store after each agent response
- Test with historical tickets: does agent retrieve relevant past context?
- Monitor resolution time and escalation rate
- Iterate on retrieval weights (recency bias, relevance, solution success rate)
Next Steps
- Learn more: Check Schema Design Patterns for indexed fields and search optimization
- Quick reference: See Agent Memory Cheat Sheet for memory types and retrieval modes
- Build: Start with Brain open-source, or try Managed Cloud for production scale