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

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.
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
👀 See Also

How Clawdbot Coordinates 6 AI Agents with a Production-Stable Work Queue
Clawdbot's team built a work queue system to coordinate 6 AI agents (design, code, marketing, ops) for their AI-operated store. The system features atomic task claiming, a state machine, retry logic with backoff, task chains, heartbeat tracking, and a daemon orchestrator.

SigMap v8.9: Deterministic Context Layer Cuts Token Use 97% for AI Coding Agents
SigMap v8.9 achieves 97% token reduction, 88% hit@5 retrieval, and 49% fewer prompts per task. Works with Copilot, Claude Code, Cursor, Windsurf, Codex, OpenCode, Gemini CLI. Zero deps, fully offline.

Four Free Claude Code Skills for Prompt Clarity, Tutorials, and Bug Hunting
Four Apache 2.0, no-paid-tier Claude Code skills: prompter (prompt rewriting), tutorial-creator (annotated code walkthroughs), bug-echo (post-fix anti-pattern sweep), and bug-prospector (pre-release audit with 7 analysis lenses).

obsidian-mcp: Graph-Aware MCP Server for Claude with 25 Tools Targeting Large Vaults
obsidian-mcp is an MCP server exposing 25 tools (including get_note, traverse_graph, query_dataview, move_note, create_notes) that gives Claude graph-aware access to your Obsidian vault — avoiding context window death on 5k-note vaults. MIT, works with Claude Desktop, Claude Code, Cursor, Cline, Continue, Zed.