Pattern: Memory Management

Pattern: Memory Management

Category: Memory Source: FOR-0012 Status: Documented

When to Use

When an agent needs to persist, classify, and retrieve information across interactions or sessions. Essential for any agent that must maintain continuity — remembering user preferences, past decisions, learned corrections, or accumulated knowledge.

How It Works

  • When new information arrives, classify it by memory type:
    • Short-term / Session: Relevant only during the current interaction (conversation buffer)
    • Episodic: Specific events or interactions worth recalling later
    • Long-term / Knowledge: Facts, preferences, or rules that persist indefinitely
  • Store memories with metadata: timestamps, relevance tags, topic categories, recency scores
  • When context window fills up, compress or summarize older memories
  • On each new interaction, retrieve relevant memories from the store
  • Periodically prune stale or redundant memories
  • Optionally update or correct existing memories based on new information

Example

A digital talent acting as a personal assistant for an SMB owner. Short-term memory tracks the current conversation. Episodic memory records that "the client canceled the March meeting and rescheduled to April." Long-term memory stores that "the client prefers email over phone calls" and "their fiscal year ends in June." Each interaction queries relevant memories to personalize responses.

Tradeoffs

Pro Con
Enables conversational continuity across sessions Memory classification errors degrade quality
Personalizes agent behavior over time Storage and retrieval add latency and cost
Reduces repetitive information gathering Stale memories can cause outdated responses
Supports learning from past interactions Privacy concerns with long-term data retention

Factory Usage

  • CLAUDE.md and MEMORY.md: The factory uses file-based memory — project instructions in CLAUDE.md and persisted learnings in MEMORY.md serve as long-term memory for all agents.
  • Decision records (company/decisions/TFD-XXX.md): Episodic memory of strategic decisions made by the factory.
  • STATUS.md: Short-term memory of current factory state, updated as work progresses.