Migrate Memory System to Backend-Agnostic Architecture
Refactor the memory system (currently telegram/ava-specific) into a generic, backend-agnostic architecture that integrates with the free monad agent implementation in Omni/Agent.
data MemoryBackend m = MemoryBackend
{ mbStore :: MemoryEntry -> m ()
, mbSearch :: Text -> Int -> m [MemoryEntry] -- semantic search
, mbRecent :: Int -> m [MemoryEntry] -- temporal
, mbByTag :: [Tag] -> m [MemoryEntry]
, mbPrune :: m () -- cleanup/consolidation
}
data EmbeddingProvider m = EmbeddingProvider
{ epEmbed :: Text -> m (Vector Float)
, epBatchEmbed :: [Text] -> m [Vector Float]
}
Implementations: ollama (local), openai, noop (for tests)
1. In-memory (IORef, good for dev/testing) 2. SQLite (refactor from current ava implementation) 3. Future: postgres, qdrant, neo4j
Add memory operations to the agent DSL:
data AgentF next
= ...
| Remember MemoryEntry next
| Recall Text Int ([MemoryEntry] -> next)
| Forget MemoryId next
The interpreter config takes a MemoryBackend:
data AgentConfig = AgentConfig
{ acMemory :: MemoryBackend IO
, acModel :: Model
, ...
}
1. Define MemoryBackend and EmbeddingProvider abstractions in Omni/Agent/Memory.hs 2. Add Remember/Recall/Forget ops to the free monad DSL in Omni/Agent/Engine.hs 3. Implement interpreter cases that delegate to the configured backend 4. Refactor existing sqlite memory code from Ava into a reusable backend 5. Create in-memory backend for testing 6. Update Ava to wire up its sqlite backend via the new abstraction
Duplicate of t-477