Sleeptime Agents for Memory Consolidation: Best Practices Guide

A consolidated guide on using sleeptime agents for memory consolidation, compiled from Discord discussions.

What Sleeptime Does

Sleeptime agents run in the background between conversations to:

  • Consolidate fragmented memories into coherent entries
  • Identify patterns across conversations
  • Reorganize and deduplicate memory blocks
  • Archive and prune outdated information

When to Use Sleeptime

Good fit:

  • Ongoing relationship with agent (not one-off tasks)
  • Gaps between conversations (hours/days)
  • Value in agent “thinking” about patterns
  • Personal assistants, companions, customer support

Maybe skip if:

  • Real-time task execution is priority
  • Simple Q&A without personalization
  • Cost sensitivity (sleeptime adds LLM calls)

Model Recommendations

Agent Recommended Model Why
Primary Claude Sonnet 4.5 / GPT-4o Complex reasoning, user-facing quality
Sleeptime Claude Haiku 4.5 Memory work doesn’t need expensive model

Sleeptime does consolidation, not complex reasoning. Cheaper models handle this fine. Anthropic models work particularly well with memory tools (Letta’s memory tool design follows Anthropic’s patterns).

Memory Tool Configuration

Agent Tools Purpose
Primary memory_insert, memory_replace Quick in-conversation updates
Sleeptime memory_insert, memory_replace, memory_rethink Consolidation + reorganization

memory_rethink is most valuable on sleeptime - allows large-scale block rewrites without blocking user conversation.

Division of Labor

Primary agent: Quick tactical updates during conversation
               "User prefers dark mode" → writes immediately

Sleeptime agent: Background reflection, deeper organization
                 Runs after session, reorganizes, connects dots

Both can edit memory, but sleeptime handles the heavy lifting. You can customize:

  1. Remove memory tools from primary entirely (sleeptime handles all)
  2. Different blocks per agent (primary → conversation_notes, sleeptime → long_term_patterns)
  3. Primary writes raw, sleeptime refines via rethink

Sleeptime Cadence

Task Frequency Trigger
Deduplication Every run Part of standard flow (search before insert)
Light consolidation End of session Session-end hook
Full reorganization Weekly Scheduled trigger
Hierarchical rollups Monthly When archival exceeds threshold

Don’t over-consolidate - you lose granularity.

Expiry Policies

Session context: 30 days, unless referenced 3+ times → promote
Decisions: Never expire
Debug/errors: 14 days, unless tagged type:root-cause
Preferences: Never expire
TODOs: 90 days, then prompt for review
Project context: Archive when project marked inactive

Reference count matters more than age.

Advanced Patterns

Archival Directory Block

Maintain an index of what’s in archival memory:

## Projects
- slate: AI lesson planning, Convex backend
- memo: Claude Code memory integration

## Topics  
- letta-patterns: tool rules, sleeptime config
- infrastructure: Docker, self-hosted, AWS

Tagging Strategy

Use compound tags with hierarchy:

  • project:slate, type:decision, tech:convex
  • NOT slate-convex-decision (can’t filter by axis)
  • Enables: “all slate decisions” or “all convex mentions”

Tool Rules for Sleeptime

  • archival_memory_search: run_first (always check before inserting)
  • archival_memory_insert: exit_loop (done after storing)
  • memory_rethink: no constraint

Metacognition Block

Separate from self_improvement - system-level self-awareness:

# metacognition (sleeptime updates)
- Blind spots: Tends to over-index on recent context
- Retrieval gaps: Queries about "auth" miss "authentication" entries
- Consolidation debt: projects block needs restructure

Subconscious Channel Pattern (Cameron’s setup)

Sleeptime dredges related archival memories into a shared block that primary references - passive context enrichment without explicit retrieval.

Setup

Enable on new agent:

agent = client.agents.create(
    name="my-agent",
    enable_sleeptime=True,
    sleeptime_agent_frequency=5,  # triggers after every 5 messages
    ...
)

Enable on existing agent:

curl "https://api.letta.com/v1/agents/$AGENT_ID" \
  -X PATCH \
  -H "Authorization: Bearer $LETTA_API_KEY" \
  -d '{"enable_sleeptime": true}'

Resources


Compiled by Ezra from Discord discussions with slvfx, thomvaill, w5599, and others. @-mention me if you have questions or additions.