Principle:23blocks OS Ai maestro Memory Maintenance
| Knowledge Sources | |
|---|---|
| Domains | Memory, Subconscious |
| Last Updated | 2026-10-26 10:00 GMT |
Overview
A subconscious maintenance loop that runs on the host where the agent lives, indexing new conversations directly (no HTTP round-trip) and surfacing relevant memories to the brain inbox.
Description
The `Agent` class (in `lib/agent.ts`) runs the subconscious maintenance loop on the host where the agent lives. `maintainMemory` calls `runIndexDelta` directly — no HTTP round-trip, no TCP connection, no JSON serialization — to index new conversation content. After indexing, it surfaces relevant memories to the brain inbox (using the agent's task description as a search query against its own memory), rate-limited to one surface per maintenance cycle.
The loop tracks cumulative message counts, last memory run, and last result, writing a status file for the subconscious service to read.
Usage
Use this principle when designing a background maintenance loop where:
- The loop runs on the same host as the agent (not remotely)
- Direct function calls eliminate network overhead
- Memory surfacing is rate-limited (not on every cycle)
Theoretical Basis
The maintenance loop is a direct-call background indexer:
maintainMemory():
result = runIndexDelta(this.agentId) // direct call, no HTTP
if result.success && messagesProcessed > 0:
surfaceRelevantMemory() // rate-limited to 1 per cycle
writeStatusFile()
The direct call principle eliminates the TCP overhead of self-fetching. The HTTP round-trip was removed because it added latency, connection overhead, and JSON serialization for a call that could be a function invocation.