Skip to main content
Load memories relevant to the current session when an agent starts.

Use Case

An AI coding assistant that loads context about:
  • Current project being worked on
  • Recent files being edited
  • Current task goals

Implementation

Store Session Summary

from memoclaw import MemoClaw

client = MemoClaw()

# At end of each session, store a summary
session_summary = client.store(
    content="Session 2026-02-13: Working on memoclaw-api, added rate limiting. Files: src/routes/store.ts, tests/api.test.ts",
    importance=0.7,
    memory_type="observation",
    session_id="session-123",
    tags=["session", "project-memoclaw-api"]
)

Load Context at Session Start

# At start of new session, load recent context
recent_memories = client.recall(
    query="recent work on memoclaw-api project",
    limit=5,
    filters={
        "tags": ["project-memoclaw-api"]
    }
)

# Build system prompt context
context = "Recent context:\n"
for m in recent_memories.memories:
    context += f"- {m.content}\n"

Track Session History

# List all sessions
all_sessions = client.list(
    filters={"tags": ["session"]},
    limit=20
)

# Get memories from a specific session
session_memories = client.recall(
    query="",
    session_id="session-123"
)

Best Practices

  1. Use session IDs to scope memories to specific conversations
  2. Store summaries at session end for faster retrieval later
  3. Set importance based on relevance to future sessions
  4. Use namespaces to separate different projects or clients
  • Store — Store session memories
  • Recall — Search memories
  • List — List by filters