Retrieve
Concept
The memory module provides an advanced, task-centric long-term memory system.
Its core objective is to enable agents to learn from experience, avoid repeating mistakes, and continuously improve their task completion abilities.
Core Functions
-
Memory storage and retrieval
- Core unit: Memories exist as Memo objects, each containing an insight (an insight, skill, or information that helps complete a task) and an optional associated task.
- Vector database: Uses PostgreSQL with the pgvector extension as the underlying vector database. When storing a Memo, the module uses an LLM (in
_prompter.py) to generate multiple "topics" for the insight or task, and stores the vector representations (Embeddings) of these topics in the database, mapped to the corresponding Memo. - Intelligent retrieval: When an agent receives a new task, the module first generalizes the task description, then generates query topics for the generalized task, and retrieves candidate Memos from the database through vector similarity.
-
Multi-stage LLM filtering and verification
- This is a key feature that ensures the retrieved memories are highly relevant.
- Task generalization: Before retrieval, an LLM (prompter.generalize_task) is used to remove irrelevant details from the task description, capturing the core of the task.
- Memory validation: After retrieving candidate Memos, the LLM (prompter.validate_insight) is called again to determine whether each insight is truly helpful for the current specific task, thereby filtering out irrelevant memories.
Component

-
Layered Architecture: The system is divided into application layer, integration layer, core control layer, language model interaction layer, and memory storage layer from top to bottom. This layered design ensures clear responsibilities for each part, achieving high cohesion and low coupling. The tool and evaluation layer provides support for the core control layer.
-
Core Process:
- Task Reception: Everything begins with a user initiating a task to the agent at the application layer.
- Memory Invocation: The agent interacts with the MemoryController (main controller) through the Teachability adapter.
- Intelligent Processing: The MemoryController is the brain of the system, coordinating the Prompter (for LLM calls), MemoryBank (for memory access), and Grader (for answer evaluation) to intelligently process tasks, retrieve memories, or learn from failures.
- Result Feedback: After processing, relevant memories or insights are returned through the Teachability adapter, enhancing the agent's context and helping it complete tasks more effectively.