Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Principle:23blocks OS Ai maestro Memory Maintenance

From Leeroopedia
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.

Related Pages

Implemented By

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment