Overview
The DRIP (Dynamic Retrieval & Intelligent Patterning) Memory System is the cognitive core of the Functor agentic platform.
It goes beyond simple vector storage to provide a bio-inspired, multi-module memory architecture. It actively processes, curates, and evolves memory through 10 specialized modules orchestrated by a central hub.
The Memory System operates as a unified service layer sitting behind the MainOrchestrator. It is accessed either automatically during query processing or manually via specific API endpoints.
System Architecture & Information Flow
Authentication Flow
All access is secured via API Keys. The system supports a dual-key mechanism:
- Static Admin Key: For system-level operations.
- Database Keys: For user/tenant access, hashed and validated against PostgreSQL
api_keystable.
Context Injection: Upon successful validation, the verify_api_key dependency injects a context dict (user_id, project_id, api_key_id) into the request, which flows down to the Orchestrator.
Auto-Invocation & Lifecycle Hooks
A key design principle of DRIP is that memory operations are transparent. Developers interacting with the main /api/v1/query endpoint do not need to manually manage memory.
The "Hook" Mechanism
The MainOrchestrator implements hooks at critical stages of the query lifecycle:
1. Pre-Retrieval Hooks (Context Injection)
- Trigger: Before searching the knowledge base.
- Action:
- Fetches recent Episodes (last 7 days).
- Injects Personalized Context (user preferences).
- Retrieves Short-Term session buffer.
- Result: The query is "enriched" with this context before being sent to the LLM.
2. Retrieval Phase Hooks
- Trigger: During vector/graph search.
- Action: Semantic Memory injects relevant facts and Procedural Memory injects relevant skill definitions into the search results.
3. Post-Response Hooks (Consolidation)
- Trigger: After a successful LLM response.
- Action:
- Episodic Memory: Stores the interaction (Query + Answer) as a new Episode.
- Short-Term Memory: Updates the session buffer.
- Observability: Logs usage metrics.
Comparison: Auto vs Manual
| Operation | Method | Requires Manual API Call? |
|---|---|---|
| Store Chat History | Auto-Invoked (Episodic) | ❌ No |
| Personalize Answer | Auto-Invoked (Personalization) | ❌ No |
| Maintain Session | Auto-Invoked (Short-Term) | ❌ No |
| Prune Old Data | Manual (Pruning Engine) | ✅ Yes (POST /pruning/prune) |
| Manage Tenants | Manual (Tenant Manager) | ✅ Yes (POST /tenants) |
| Define Procedure | Manual (Procedural Manager) | ✅ Yes (POST /procedures) |
Usage Tracking & Observability
To ensure accurate billing and monitoring, a specialized Middleware Patch was implemented.
The Tracking Gap Solution
Standard analytics tracked the Orchestrator, but direct calls to /api/memory/v1/* (e.g., from admin dashboards) bypassed this.Solution: MemoryTrackingMiddleware intercepts all requests to the memory namespace.
Middleware Logic
- Intercept: Catches
GET/POST/PUT/DELETEonv1/memory/*. - Extract: Pulls
user_idandtenant_idfrom the auth context. - Track: Asynchronously calls
usage_tracker.track_event()withevent_type="memory_read"or"memory_write". - Tag: Marks events from dashboards with
is_dashboard_tool=Truefor filtering.
Detailed Module Analysis
Explore individual memory modules:
Episodic Memory
Autobiographical history of user interactions.
Semantic Memory
General world knowledge and facts.
Procedural Memory
Skills, workflows, and 'how-to' knowledge.
Short-term Memory
Attentional working memory for the current session.
Long-term Memory
Consolidated, permanent archive.
Pruning Engine
Forgetting and garbage collection.
Personalization Engine
User preferences and identity modeling.
Memory Observer
Monitoring and metrics.
Multi-Tenant Manager
Data isolation and security.
Rollout Manager
Simulation and planning ('Imagination').