Skip to main content
Store user preferences persistently so your AI assistant remembers them across sessions.

Use Case

An AI assistant that helps users with coding tasks. It should remember:
  • Preferred programming languages
  • Editor settings
  • Notification preferences
  • Timezone

Implementation

Store Preferences

from memoclaw import MemoClaw

client = MemoClaw()

# After learning user preferences in conversation
preferences = [
    ("Prefers TypeScript over JavaScript", 0.9),
    ("Uses VS Code with Vim extension", 0.8),
    ("Prefers dark mode", 0.85),
    ("Timezone is PST", 0.95),
]

for pref, importance in preferences:
    client.store(
        content=pref,
        importance=importance,
        memory_type="preference",
        namespace="user-prefs"
    )

Recall on Session Start

# At the start of each session
memories = client.recall(
    query="user preferences for coding assistant",
    namespace="user-prefs",
    limit=10
)

# Build context for the assistant
context = "\n".join([
    f"- {m.content}" 
    for m in memories.memories
])
print(f"User preferences:\n{context}")

Update When Changed

# When user explicitly updates a preference
client.update(
    memory_id="existing-memory-id",
    content="Now prefers React over Vue",
    importance=0.9
)

Memory Types

Use memory_type: "preference" for user preferences. This gives them a 180-day half-life, meaning they persist for a long time but eventually decay if not reinforced.

Next Steps