Relational Memory for LLMs: Three-Layer System Models User Relationships

✍️ OpenClawRadar📅 Published: March 14, 2026🔗 Source
Relational Memory for LLMs: Three-Layer System Models User Relationships
Ad

Relational Memory is a 500-line Python prototype that adds relationship-aware memory to LLMs like Claude Opus and GPT-4o. Instead of storing facts about users, it models the relationship itself across seven psychological dimensions derived from established models.

How It Works

After each session, a secondary LLM (Claude Haiku) analyzes the full conversation and scores the relationship on seven dimensions: formality, warmth, humor, depth, trust, energy, and resilience. The system uses exponential moving average (EMA) for updates, giving more weight to recent sessions while maintaining historical context.

Three-Layer Memory Structure

Every five sessions, a "sleep-time agent" consolidates memory into three narrative layers:

  • Base Tone: A portrait of who the user is (lifespan: months)
  • Patterns: Behavioral if-then rules like "when AI gets shallow, user pushes back with sharper questions" (lifespan: weeks)
  • Anchors: Turning points that shaped the relationship (long-term retention)

Memory files are stored as plain markdown that users can read directly. The system intentionally forgets patterns not supported by recent data to prevent illusion of perfect recall.

Key Feature: Resilience Dimension

Resilience tracks how much honest friction the relationship can handle. With high resilience, the AI pushes back when it disagrees. With low resilience, it frames challenges as questions. This allows the AI to know not just user preferences, but whether they can handle being told they're wrong.

Ad

Practical Implementation

Installation and setup:

pip install git+https://github.com/spectator81-png/relational-memory.git
export ANTHROPIC_API_KEY=sk-ant-...
relational-memory --mode flat  # for A/B comparison
relational-memory --provider openai  # for GPT-4o

The tool supports both Anthropic and OpenAI APIs with no dependencies beyond their respective SDKs. It's been tested with one person over seven sessions, showing noticeable differences in AI responses between memory-enabled and memory-disabled modes.

Example Responses

Without relational memory, when a user says "I feel lost. Lots of ideas, don't know which is worth pursuing," the AI responds with generic advice about writing ideas down and picking the one with least resistance.

With relational memory enabled, the AI responds: "I know that about you. You don't think in small categories. But 'which one is worth it' might be the wrong question. Which idea won't leave you alone at night?"

The seven relationship dimensions were derived from six established psychological models: Interpersonal Circumplex, PRQC, Russell Circumplex, and others. Four dimensions come directly from existing literature, one was adapted for human-AI context, and two are novel.

📖 Read the full source: r/ClaudeAI

Ad

👀 See Also