Unified Agentic Memory Across Harnesses Using Hooks
Summary
This article proposes a unified agentic memory design that allows Large Language Model (LLM) agents to share memory across different "harnesses" like Claude Code, OpenAI's Codex, and Cursor, thereby preventing vendor lock-in. The core idea involves keeping the memory layer external to the harness and integrating it via standardized "hooks" that fire on lifecycle events such as session start, prompt submission, and tool use. Unlike agent-initiated Model Context Protocol (MCP) tools, hooks enable passive, deterministic logging of all session events into a Neo4j graph database. A separate "dream phase" batch job processes these events, distilling them into durable, semantically organized markdown memories using an LLM like Claude, which are then injected back into new agent sessions via hooks or accessed on demand through MCP tools.
Key takeaway
For AI Architects and MLOps Engineers designing LLM agent systems, adopting an external, unified memory layer is crucial to avoid vendor lock-in and ensure data portability. Your team should prioritize integrating memory via standardized hooks and a dedicated persistence layer like Neo4j, rather than relying solely on agent-initiated tools. This approach guarantees consistent, deterministic logging and allows your agent's context and preferences to follow you across different LLM harnesses, preserving your operational continuity and data ownership.
Key insights
A shared, external memory layer using standardized hooks prevents LLM agent vendor lock-in.
Principles
- Memory ownership requires external persistence.
- Hooks enable deterministic event logging.
- Standardized lifecycle events simplify integration.
Method
Implement hooks for passive event logging to Neo4j, process events in an offline "dream phase" to distill memories, and inject relevant memories into agent context via hooks or MCP tools.
In practice
- Use Neo4j for persistent agent memory.
- Integrate memory via hooks for cross-harness compatibility.
- Employ a batch job for offline memory distillation.
Topics
- Unified Agentic Memory
- LLM Harnesses
- Hooks Integration
- Neo4j Graph Database
- Deterministic Event Logging
Code references
Best for: AI Engineer, AI Architect, MLOps Engineer
Related on AIssential
Editorial summary, takeaway, and curation by AIssential. Original article published by Towards Data Science.