Skip to main content

Agentic Memory Module API Specification

Version: v1.3.0 | Status: Stable | Last Updated: February 2026

1. Overview​

The agentic_memory module provides persistent and in-process memory for AI agents. It implements remember/recall/forget semantics with token-overlap relevance scoring and exponential-decay recency scoring. Memories are typed (episodic, semantic, procedural) and ranked by importance.

2. Core Components​

2.1 Enumerations (models.py)​

MemoryType (enum):

ValueMeaning
EPISODICEvent-based memories (conversation turns, actions)
SEMANTICFactual knowledge
PROCEDURALProcess or skill-based knowledge

MemoryImportance (enum, orderable by .value):

ValueInteger
LOW1
MEDIUM2
HIGH3
CRITICAL4

2.2 Data Models (models.py)​

Memory (dataclass): A single memory entry.

FieldTypeDescription
idstrUUID identifier
contentstrText content of the memory
memory_typeMemoryTypeClassification (default: EPISODIC)
importanceMemoryImportancePriority level (default: MEDIUM)
metadatadict[str, Any]Arbitrary metadata
tagslist[str]Searchable tags
created_atfloatUnix timestamp of creation
access_countintNumber of times retrieved
last_accessedfloatUnix timestamp of last access

Methods: access() -> None, to_dict() -> dict, from_dict(data) -> Memory (classmethod).

RetrievalResult (dataclass): Output of recall/search operations.

FieldTypeDescription
memoryMemoryThe matched memory
relevance_scorefloatToken-overlap score (0–1)
recency_scorefloatExponential-decay score (0–1)
importance_scorefloatNormalized importance (0–1)
combined_scorefloat (property)Weighted: 0.5*relevance + 0.3*recency + 0.2*importance

2.3 Memory Stores (stores.py)​

InMemoryStore: In-process dict-backed store. Not persistent across restarts.

MethodSignatureReturnsDescription
save(memory: Memory)NoneUpsert a memory entry
get(memory_id: str)`Memory \NoneFetch by ID; incrementsaccess_count`
delete(memory_id: str)boolRemove; returns True if existed
list_all()list[Memory]Return all stored memories

JSONFileStore: Thread-safe file-backed store. Flushes to disk on every write.

MethodSame as InMemoryStoreExtra
__init__(path: str)Creates parent dirs; loads existing data on init

2.4 High-Level Memory Classes (memory.py)​

AgentMemory: Primary agent memory with full remember/recall/forget API.

MethodSignatureReturnsDescription
remember(content, *, memory_type, importance, metadata)MemoryCreate and persist a memory
recall(query, *, k, memory_type, min_importance)list[RetrievalResult]Top-k memories matching query
search(query, k)list[RetrievalResult]Public search API
forget(memory_id: str)boolDelete a memory by ID
get_context(query, k)strFormatted string of relevant memories
memory_countpropertyintNumber of stored memories

VectorStoreMemory: Memory with pluggable store backend.

MethodSignatureReturns
remember(content, *, memory_type, importance, metadata)Memory
search(query, k)list[RetrievalResult]

ConversationMemory: Specialized for dialogue turn storage.

MethodSignatureReturnsDescription
add_turn(role, content, *, turn_number)MemoryStore a conversation turn with role metadata

KnowledgeMemory: Specialized for factual knowledge.

MethodSignatureReturnsDescription
add_fact(fact, source="")MemoryStore a fact with SEMANTIC type and HIGH importance

3. Usage Example​

from codomyrmex.agentic_memory.core.memory import AgentMemory
from codomyrmex.agentic_memory.core.models import MemoryType, MemoryImportance

# Basic usage
mem = AgentMemory()
mem.remember("The project deadline is March 1st",
memory_type=MemoryType.EPISODIC,
importance=MemoryImportance.HIGH)

results = mem.recall("project deadline", k=5)
for r in results:
print(f"[{r.combined_score:.2f}] {r.memory.content}")

# Persistent store
from codomyrmex.agentic_memory.stores import JSONFileStore
store = JSONFileStore("/tmp/agent_memories.json")
persistent = AgentMemory(store=store)
persistent.remember("User prefers dark mode", importance=MemoryImportance.MEDIUM)

# Conversation memory
from codomyrmex.agentic_memory.core.memory import ConversationMemory
conv = ConversationMemory()
conv.add_turn("user", "What is the capital of France?", turn_number=1)
conv.add_turn("assistant", "Paris.", turn_number=2)