HyperAIHyperAI

Command Palette

Search for a command to run...

Unified agentic memory across harnesses using hooks

A central debate in the AI coding landscape is shifting from which model is best to which scaffolding, or harness, best supports it. A harness defines the agent loop, tool definitions, context management, and memory that transform a raw large language model into a functional product. Examples include Cursor, Claude Desktop, and others. While these tools offer power, committing to a specific harness often creates vendor lock-in, particularly regarding memory. If an agent's memory resides within a closed ecosystem, switching tools incurs high costs as that history is lost. To solve this, a unified agentic memory architecture has been proposed where the memory layer exists independently of any single harness. This approach uses standard hooks to connect different coding agents, such as Claude Code, OpenAI's Codex, and Cursor, to a shared persistent store like Neo4j. While Model Context Protocol servers allow agents to query external systems, they rely on the model to decide when to initiate a query. This consumes model attention and requires the agent to know the precise moment to request data. In contrast, hooks offer passive, deterministic logging. These are shell commands triggered automatically by lifecycle events, including session start, user prompt submission, tool usage, and session end. Unlike agent-initiated actions, hooks run programmatically without requiring the model's decision-making. Crucially, these hooks maintain a standardized interface across major providers, receiving JSON payloads on standard input and emitting JSON on standard output to inject context. The architecture consists of three layers. First, the online hook layer passively logs every event into a graph database, creating a complete audit trail of the session. Second, an offline dream phase runs periodically as a batch job. It reads accumulated events, uses an LLM to distill them into durable, semantic markdown memories, and updates the store. This ensures memories are merged rather than appended, keeping them current and concise. Third, the injection layer utilizes the standardized hooks to load relevant profile information and context into the system prompt at the start of a new session or when a user prompt is submitted. This design allows a user to switch between different agents, such as moving from Cursor to Claude Code, without losing their agent's understanding of their preferences, projects, or workflow. The memory layer sits below the harnesses, ensuring ownership remains with the user rather than the tool provider. While hooks provide deterministic context injection, the system can also integrate Model Context Protocol tools to allow agents direct read-write access to the memory graph on demand. The project demonstrates that by separating memory from the harness, developers can build a portable agent ecosystem. The same two Python scripts manage events for all three clients, requiring only minimal shell wrappers for integration. This approach eliminates the need to start from zero when changing tools, as the agent's accumulated knowledge follows the user seamlessly across platforms. Source code for this implementation is available publicly, illustrating a practical path toward vendor-independent AI agents.

Related Links

Unified agentic memory across harnesses using hooks | Trending Stories | HyperAI