Agentic Search: Teaching an AI to Remember Like a Human

Vector search finds similar text. Agentic search finds relevant context. The difference is reasoning.
The Search Problem
Traditional search asks: "What documents contain these words?"
But humans ask: "What did I mean when I said that?"
Example query: "How did I handle user authentication?"
Vector search approach:
- Finds docs with "user" and "authentication"
- Misses: Sessions about "auth", "login", "sign-in"
- Misses: Context about why you chose JWT vs sessions
- Misses: The error → fix → success chain
Human memory approach:
- "I remember working on that last month"
- "It was for the e-commerce project"
- "I tried OAuth first, then switched to JWT"
- "The issue was with token refresh"
Humans search with reasoning, not similarity.
Agentic Search
Agentic search combines:
- Semantic understanding — What does the query mean?
- Temporal navigation — When did this happen?
- Pattern recognition — What type of solution?
- Causal reasoning — What led to success?
const response = await searchEngine.search({
userId: 'user_123',
query: "How did I handle user authentication?",
strategy: 'hybrid', // temporal + semantic + pattern
depth: 3,
limit: 10,
});
// Returns:
response.insights.summary
// "Found 3 authentication implementations across 2 projects"
response.insights.patterns
// ["jwt-auth", "oauth-integration", "session-management"]
response.insights.suggestions
// ["Consider reusing the JWT pattern from Project A"]
response.results[0].reasoning
// "Session from March 2025 implemented JWT authentication
// with refresh tokens for the e-commerce project"
Four Search Strategies
1. Temporal Search
"What did I do last week?"
const response = await searchEngine.search({
userId: 'user_123',
query: "Show me recent authentication work",
strategy: 'temporal',
});
How it works:
- Parse temporal markers ("recent", "last week", "Tuesday")
- Weight by recency (exponential decay)
- Boost matches from requested time period
// Relevance scoring
const daysAgo = (Date.now() - session.createdAt) / (1000 * 60 * 60 * 24);
const recencyBoost = Math.max(0.1, 1 - daysAgo / 30);
2. Semantic Search
"How did I handle user roles?"
const response = await searchEngine.search({
userId: 'user_123',
query: "Find my role-based access control implementation",
strategy: 'semantic',
});
How it works:
- Extract semantic concepts ("roles", "access", "permissions")
- Match against preferences and project context
- Cross-reference with session content
const concepts = extractConcepts(query);
// { entities: ['Role', 'User'], patterns: ['guard'], actions: ['authorize'] }
// Match against sessions
const matches = sessions.filter(s =>
s.entities.some(e => concepts.entities.includes(e)) ||
s.patterns.some(p => concepts.patterns.includes(p))
);
3. Pattern Search
"Show me all list views I've built"
const response = await searchEngine.search({
userId: 'user_123',
query: "Find all my list views",
strategy: 'pattern',
});
How it works:
- Extract pattern terms ("list", "table", "grid", "cards")
- Search pattern affinity records
- Return sessions using those patterns
const patternTerms = ['list', 'table', 'grid', 'cards'];
const userPatterns = await memoryManager.getUserPatterns(userId);
// Find high-success patterns
const goodPatterns = userPatterns.filter(p =>
p.successCount / p.usageCount > 0.8
);
4. Hybrid Search
"What worked well for forms?" (combines all strategies)
const response = await searchEngine.search({
userId: 'user_123',
query: "What worked well for forms?",
strategy: 'hybrid',
depth: 3,
});
Combines temporal, semantic, and pattern results with deduplication.
The Reasoning Engine
Agentic search doesn't just return matches — it explains why they match:
interface SearchResult {
type: 'preference' | 'session' | 'project' | 'pattern';
data: unknown;
relevance: number; // 0-1
reasoning: string; // Human-readable explanation
source: string; // Where it came from
}
// Example result
{
type: 'session',
data: { /* session record */ },
relevance: 0.87,
reasoning: "Session from March 2025 contains 'User' entity with
'role' field and uses 'guard-clause' pattern.
User previously marked this pattern as successful.",
source: 'generation_history'
}
Generating Insights
Beyond individual results, agentic search generates insights:
interface Insights {
summary: string; // What was found
patterns: string[]; // Common patterns
trends: string[]; // Temporal trends
suggestions: string[]; // Actionable next steps
}
// Example
{
summary: "Found 12 sessions involving forms across 3 projects",
patterns: ["form-section", "validation-rules", "wizard-flow"],
trends: [
"High success rate (92%) with form-section pattern",
"Validation errors decreased after adopting std/validate"
],
suggestions: [
"Consider reusing the wizard-flow pattern for complex forms",
"Add entity-form to your preferred patterns"
]
}
Real-World Example
User query: "How did I build the checkout flow?"
Agentic search process:
-
Concept Extraction
concepts = {
entities: ['Order', 'Payment', 'Cart'],
patterns: ['wizard', 'form', 'validation'],
actions: ['checkout', 'purchase', 'pay']
} -
Temporal Search
- Found 5 sessions from last 3 months
- Weighted by recency
-
Semantic Search
- Matched "checkout" in prompts
- Found related entities (Order, Cart)
-
Pattern Search
- Found
wizard-flowpattern usage - 90% success rate
- Found
-
Insight Generation
{
summary: "Found checkout implementation using 3-step wizard",
patterns: ["wizard-flow", "form-section", "validation-rules"],
trends: [
"Most successful: 3-step wizard (92% completion)",
"Less successful: single-page checkout (67%)"
],
suggestions: [
"Reuse wizard-flow for future checkout flows",
"Consider adding progress indicator pattern"
]
}
