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

AI Code Review Benchmark: Claude, Gemini, Codex, Qwen, and MiniMax Compared
A benchmark tested five AI models on 15 Milvus pull requests with known bugs. Claude detected 53% of bugs in raw mode, while adversarial debate between models increased detection to 80%.

Swarm Orchestra v2 Plugin Adds Inter-Agent Messaging to Fix Claude Code Agent Team Chaos
Swarm Orchestra is a plugin that addresses Claude Code's experimental TeamCreate feature, which can spawn runaway agents. Version 2 adds inter-agent messaging via a PreToolUse hook and self-configuration via a /teammate skill.

AI Ate the Translation Layer: The Org Chart After Agents
Ajey Gore argues AI didn't replace job titles — it ate the translation task. The middle of the org chart (engineering managers, scrum masters, tech leads) is shrinking as agents convert requirements to code directly.

MephisQuiz: Free Scenario-Based Quiz Platform for Engineering Role Assessment
An SRE professional built MephisQuiz, a free quiz platform with 860+ scenario-based questions across 4 engineering role tracks. The platform uses adaptive difficulty, provides topic-by-topic breakdowns, and was developed using Claude AI as a pair programmer.