Memory Extraction
LLM-powered memory extraction from conversations using MemoryExtractionService
The MemoryExtractionService (apps/api/src/arena/memory-extraction.service.ts) uses Claude to extract structured memories from conversation transcripts. It handles all three operations/surfaces.
Extraction Model
All extraction calls use claude-haiku-4-5 for fast, cost-effective processing.
Methods
extractAgentMemories(agentName, transcriptText)
Extracts 3–8 individual memories for a specific agent from an arena voice transcript.
Categories: decision, position, task, open_question, learning
Used by: Arena session end handler
extractFromChat(agentName, chatHistory)
Extracts 3–6 memories from a 1:1 text chat conversation.
Categories: decision, position, task, open_question, learning, preference
Used by: Agent chat message handler
extractFromTeamChat(teamName, agentNames, chatHistory)
Extracts both per-agent and team-level memories from a group chat.
Returns:
{
agentMemories: Record<string, ExtractedMemory[]>,
teamMemories: ExtractedMemory[]
}Used by: Team chat message handler
extractSessionBrief(transcriptText, agentNames)
Extracts a structured session brief from an arena transcript.
Returns:
{
decisions: { text: string; confidence: string }[],
actionItems: { owner: string; task: string; deadline?: string }[],
unresolved: { topic: string; positions: string[] }[],
nextSessionQuestions: string[]
}consolidateMemories(memories)
Consolidates a cluster of related memories into a single comprehensive memory. Used by the weekly operations/cron-jobs|consolidation cron.
Input: Array of { content, memoryType } objects
Output: Single { content, memoryType } with 2–3 sentence summary
Memory Object Structure
All extraction methods return arrays of:
interface ExtractedMemory {
category: 'decision' | 'position' | 'task' | 'open_question' | 'learning' | 'preference';
content: string; // 1-2 sentence concise statement
confidence: 'high' | 'medium' | 'low';
}JSON Parsing
The service uses defensive parsing with parseJsonArray() and parseJsonObject():
- Regex extracts the first
[...]or{...}from the LLM response - Falls back to empty array or default object on parse failure
- Logged warnings for debugging
Related Pages
- operations/surfaces — Where extraction is triggered
- pipeline/lifecycle — What happens after extraction
- pipeline/scoring — How extracted memories are later retrieved
- operations/cron-jobs — Consolidation that uses
consolidateMemories()