cortex memory

Search and manage the 5-tier memory system. CortexPrism uses a hybrid retrieval approach combining FTS5 keyword search with cosine vector similarity, scored with exponential decay.

Usage

cortex memory search "<query>"       # Search all memory types (hybrid return)
cortex memory search "<query>" --type semantic  # Semantic-only search
cortex memory search "<query>" --type episodic  # Episodic-only search
cortex memory add "<fact>"           # Add a semantic fact
cortex memory add "<fact>" --category project --importance 0.9  # Categorized memory

Subcommands

SubcommandDescription
searchSearch memory with hybrid retrieval
addAdd a new semantic memory entry
healthShow memory system health metrics
heuristicsDisplay memory decay and scoring heuristics

Options

OptionDescription
--typeFilter results by memory type: episodic, semantic, reflection, graph, or all (default: all)
--limit, -nMaximum results to return (default: 8)
--categoryCategory filter for add subcommand
--importanceImportance value for add subcommand (0.0–1.0, default: 0.5)
--helpShow help for this command

Memory Tiers

TierPersistenceContent
EpisodicSessionTurn summaries of user+agent exchanges with auto-decay
SemanticLong-termInjected facts and knowledge with hybrid FTS5 + vector retrieval
ReflectionPermanentLLM-extracted behavior patterns from per-turn meta-cognition
GraphLong-termKnowledge graph of entities and relationships
SkillsPermanentProcedural knowledge extracted from multi-step tool usage

Retrieval Algorithm

Query
  → FTS5 keyword search (episodic + semantic tables)
  → cosine vector similarity (via embedding provider)
  → merge + re-score: score × 2^(-age_days / half_life_days)
  → sort descending → top-K results

Embedding Providers

ProviderModelRequirement
OllamaEmbedderConfigurable via OllamaOllama running locally
OpenAIEmbeddertext-embedding-3-smallOpenAI API key required
StubEmbedderDeterministic hashNo external service needed (default)

Examples

# Hybrid search (all memory types)
cortex memory search "project deployment config"

# Semantic-only search
cortex memory search "deployment config" --type semantic

# Episodic-only search
cortex memory search "deployment" --type episodic

# Add a fact to semantic memory
cortex memory add "CortexPrism uses SQLite WAL mode for all databases"

# Add a categorized fact with high importance
cortex memory add "critical bug" --category bugs --importance 0.9