Skip to main content
Deep Dream is the core consolidation mechanism of CowAgent’s memory system, responsible for distilling scattered daily memories into refined long-term memory and generating dream diaries.

Memory Flow

CowAgent’s memory progresses through three stages from short-term to long-term:
Conversation context (short-term) → Daily memory (mid-term) → MEMORY.md (long-term)

1. Conversation → Daily Memory

When conversation context is trimmed or during the daily scheduled summary, the system uses LLM to summarize conversation content into key events, writing them to the daily memory file memory/YYYY-MM-DD.md. Triggers:
  • Context trimming — Trimmed content is summarized when turn or token limits are exceeded
  • Daily schedule — Automatically triggered at 23:55
  • API overflow — Emergency save of current conversation summary

2. Daily Memory → MEMORY.md (Distillation)

After the daily summary completes, Deep Dream automatically runs distillation:
  1. Read materials — Current MEMORY.md + today’s daily memory
  2. LLM distillation — Deduplicate, merge, prune, extract new information
  3. Overwrite MEMORY.md — Output the refined long-term memory
  4. Generate dream diary — Record discoveries and insights from the consolidation

3. Role of MEMORY.md

MEMORY.md is injected into the system prompt for every conversation, keeping the Agent aware of user preferences, decisions, and key facts. Therefore it must stay concise — Deep Dream targets approximately 30 entries or fewer.

Distillation Rules

Deep Dream follows these consolidation rules:
OperationDescription
Merge & refineCombine similar entries into single high-density statements
Extract newPull preferences, decisions, people, experiences from daily memory
Conflict updateWhen new info contradicts old entries, newer info takes precedence
Clean invalidRemove temporary records, blank entries, formatting artifacts
Remove redundancyDelete old entries already covered by more refined statements

Dream Diary

Each distillation generates a dream diary saved at memory/dreams/YYYY-MM-DD.md, written in a narrative style recording:
  • Duplications or contradictions found
  • New insights extracted from daily memory
  • Cleanups and optimizations performed
  • Overall observations
Dream diaries can be viewed in the Web console under “Memory → Dream Diary” tab.

Manual Trigger

In addition to the automatic daily run, you can manually trigger distillation in chat:
/memory dream [N]
  • N: Consolidate the last N days of memory (default 3, max 30)
  • Runs asynchronously in the background; you’ll be notified in chat when complete
  • Web notifications include clickable links to view MEMORY.md and dream diary
  • Works without Agent initialization — can be used before the first conversation
After first deployment, it’s recommended to run /memory dream 30 once to distill all historical daily memories into MEMORY.md.

Safety Mechanisms

MechanismDescription
Skip on no contentDistillation skipped when no daily memory exists, avoiding empty overwrites
Input dedupIn scheduled tasks, automatically skipped when input materials haven’t changed
Async executionDistillation runs in a background thread, never blocking conversation
Sequential guaranteeIn scheduled tasks, daily flush completes before distillation starts
No fabricationPrompt explicitly constrains consolidation to existing materials only