Memory
Plexa stacks three layers between the body and the LLM. Each one answers more situations than the next, so the brain gets called less and less.PatternStore
Per body. Caches exact and very-similar (entity, decision) pairs. Lives inscp-protocol.
AdaptiveMemory
Per body. Generalizes to “this looks like one we have seen before” using weighted euclidean distance and top-k confidence blending.new SCPBody({ patternStore, adaptiveMemory }).
VerticalMemory
Per Space. Cross-session memory of brain decisions for a given world state. This is what lets Plexa skip the LLM on repeated tasks.mem.search(worldState) first. If the top match scores above hitThreshold, Plexa uses the remembered decision and skips the LLM. The memory_hit event fires.
mem.store.
Stats:
How they work together
Cost reduction
Sample run on a Plexa stub workload, 100 brain decisions during ramp-up:| Session | LLM calls | Cache + memory hits | Brain cost (Nova Micro) |
|---|---|---|---|
| 1 | 80 | 20 | $0.0042 |
| 2 | 30 | 70 | $0.0016 |
| 3 | 8 | 92 | $0.0004 |
| 4 | 1 | 99 | $0.0001 |
Persistence
AdaptiveMemory and VerticalMemory use better-sqlite3. Plexa lists it as a devDependency, not a runtime one, so production users opt in:
better-sqlite3 is not installed, both stores still work in memory; persistence calls return 0 and the warning shows up at startup.
Auto-save on shutdown
SIGINT or SIGTERM, Plexa calls space.stop(), which saves the vertical memory and every body’s pattern store and adaptive memory.