To design local AI agents that learn and maintain consistency across sessions, we can draw a direct analogy from human cognitive psychology. Rather than treating memory as a single database, we can structure it into four distinct functional zones, each with its own lifecycle, purpose, and rules of engagement.
This architecture—inspired by cognitive frameworks like CoALA (Cognitive Architectures for Language Agents)—allows an agent to scale its context transparently:
1. Working Memory
This is the agent’s immediate focus, the only part loaded automatically at startup. It is kept extremely lightweight (usually a single file of ~100 lines) containing the immediate context of what is happening right now and pointers to where everything else lives. Crucially, it houses the agent’s identity: its core values and personality (SOUL.md) and its facts about the user (USER.md). These files provide behavioral consistency across sessions.
2. Semantic Memory
The agent’s long-term, curated knowledge base. This is where concepts, habits, project notes, and skills live. Rather than loading this entire library, the agent navigates it on demand via progressive disclosure. Semantic memory is dynamic: files that are read often are promoted closer to working memory, while files that gather dust are subject to controlled forgetting.
3. Episodic Memory
The raw, chronological record of what happened—the daily conversational logs. This is highly detailed but full of noise. On its own, episodic memory is too bulky for an agent to read daily. Instead, it serves as the raw material that gets destiled into semantic memory during regular maintenance cycles.
4. Extended Mind (The User’s Workspace)
The user’s shared environment containing active drafts, code repositories, lists, and documents. While the other three zones represent the agent’s internal mind, the user’s workspace represents extended cognition in its purest form. The agent reads and contributes to this space, but the user maintains complete ownership and structure.
By organizing memory into these four zones, we don’t just solve a context window problem. We create an agentic mind that feels cohesive, adaptive, and structurally aligned with how we organize our own thoughts.