Skip to Content

Memories

The MemoriesResource provides direct access to memories — listing, filtering, stats, episodes, and consolidation.

Access

user = client.for_user("user-123") memories = user.memories

Methods

list(**kwargs)

List memories with optional filtering.

memories_list = memories.list(limit=50, category="work") for memory in memories_list: print(f"[{memory.type}] {memory.content} (importance: {memory.importance})")
ParameterTypeDefaultDescription
owner_idstr | NoneNoneFilter by owner
limitint50Number of results
offsetint0Pagination offset
categorystr | NoneNoneFilter by category (e.g. "personal", "work")
typestr | NoneNoneFilter by type (e.g. "fact", "concept")

Returns: MemoryList — iterable of Memory objects

direct(**kwargs)

List direct memories (high-confidence facts explicitly stated by the user).

direct = memories.direct(category="preferences") for m in direct: print(m.content)
ParameterTypeDefaultDescription
owner_idstr | NoneNoneFilter by owner
limitint50Maximum number to return
categorystr | NoneNoneFilter by category

Returns: MemoryList

derived(**kwargs)

List derived memories (AI-synthesized insights from combining multiple memories).

derived = memories.derived(limit=10) for m in derived: print(f"{m.content} (derived from: {m.derived_from})")
ParameterTypeDefaultDescription
owner_idstr | NoneNoneFilter by owner
limitint50Maximum number to return

Returns: MemoryList of DerivedMemory objects (includes derived_from and derivation_reason)

get(memory_id)

Get a specific memory by ID.

memory = memories.get("memory-uuid") print(memory.content) print(memory.type) # "fact", "concept", etc. print(memory.category) # "personal", "work", etc. print(memory.importance) # 0.0 to 1.0 print(memory.source) # "direct" or "derived" print(memory.created_at) print(memory.metadata)

Returns: Memory (or DerivedMemory if derived)

Memory model fields

FieldTypeDescription
idstrUnique identifier
contentstrThe memory text
typestrMemory type (fact, concept, etc.)
categorystr | NoneCategory (personal, work, etc.)
importancefloatImportance score (0.0–1.0)
sourcestrSource: "direct" or "derived"
created_atdatetimeWhen the memory was created
updated_atdatetimeWhen the memory was last updated
metadatadict | NoneOptional metadata

delete(memory_id)

Soft-delete a memory.

memories.delete("memory-uuid")

stats()

Get memory statistics.

stats = memories.stats() print(f"Total: {stats.total_memories}") print(f"Direct: {stats.direct_memories}") print(f"Derived: {stats.derived_memories}") print(f"Relationships: {stats.relationships}")

Returns: MemoryStats

episodes(**kwargs)

List temporal episodes (time-windowed memory groups).

episodes = memories.episodes(limit=10) for ep in episodes: print(f"Episode {ep.id}: {ep.entity_count} entities") print(f" {ep.start_time}{ep.end_time}") if ep.summary: print(f" Summary: {ep.summary}")
ParameterTypeDefaultDescription
owner_idstr | NoneNoneFilter by owner
limitint20Maximum number to return
start_timedatetime | NoneNoneFilter by start time
end_timedatetime | NoneNoneFilter by end time

Returns: EpisodeList of Episode objects

create_episode(entity_ids)

Create a new episode from a list of entity IDs.

result = memories.create_episode(["entity-1", "entity-2", "entity-3"])

Returns: EpisodeList with created episodes

consolidate(dry_run, threshold_percentile)

Run adaptive forgetting on memories.

# Preview changes report = memories.consolidate(dry_run=True) print(f"Would soft-delete: {report.entities_soft_deleted}") # Run for real report = memories.consolidate(dry_run=False, threshold_percentile=25.0) print(f"Status: {report.status}") print(f"Memory reduction: {report.memory_reduction_pct}%")
ParameterTypeDefaultDescription
dry_runboolTruePreview changes without making them
threshold_percentilefloat30.0Percentile below which to soft-delete

Returns: ConsolidationReport with fields status, dry_run, entities_evaluated, entities_soft_deleted, entities_hard_deleted, memory_reduction_pct

Last updated on