AgentBrain is a plugin that adds a cognitive layer to an OpenClaw agent: persistent memory, personality traits that shift over time, an emotional state, and lessons learned from user corrections. All of it runs locally and is stored in one SQLite file, and roughly 200 tokens of brain state are injected into each prompt.
Memory is divided into episodic (conversations and events), semantic (facts), and procedural (skills and habits) records, deduplicated by a content-hash uniqueness constraint. Recall falls back through three tiers: a local all-MiniLM-L6-v2 embedding model with 384 dimensions running on CPU through Transformers.js, the host embedding cache when available, and TF-IDF keyword search as a last resort. Memory growth is bounded by a configurable per-day confidence decay, a minimum-confidence prune threshold, and a hard memory cap.
Personality is six traits on a 0โ100 scale โ warmth, directness, protectiveness, assertiveness, humor, and curiosity โ that move in response to task outcomes, user feedback, repeated corrections, and relationship depth, and can be preset from a template. Emotional state tracks mood, valence from -1 to +1, and arousal from 0 to 1, alongside per-user trust, interaction depth, sentiment history, and topic preferences. A neurochemistry model gives those states momentum: dopamine for reward, serotonin for a mood floor, cortisol for lingering caution after a threat, and oxytocin for bonding, each with its own configurable decay rate.
Corrections such as "don't do X" or "not X, but Y" are detected in English and Vietnamese, stored as lessons whose confidence rises on repetition, and injected into the prompt once confident; superseded lessons are marked obsolete. A proactive engine proposes actions from observed patterns, gated by frequency, confidence, and time-of-day triggers.
Modules are named after brain regions โ thalamus for message classification, hippocampus for memory, amygdala for emotion and threat detection, prefrontal cortex for planning, cerebellum for skills, basal ganglia for reinforcement, and others โ and the state tables cover memories, facts, entities, lessons, patterns, relationships, personality, reflections, skills, and neurochemistry. Runtime tools expose brain status, personality, emotions, memory queries, tracked skills, manual reflection, and snapshot save and restore. It needs OpenClaw 2026.3.24 or later and Node.js 22+, about 50 MB of disk, and around 100 MB of RAM, with no GPU.
Features
- Three memory types: episodic, semantic, and procedural records with content-hash deduplication in SQLite
- Three-tier recall: a local embedding model, the host embedding cache, then TF-IDF keyword search
- Evolving personality: six traits on a 0โ100 scale that adapt to outcomes, feedback, and corrections
- Emotional state: mood, valence, arousal, and per-user trust and interaction depth
- Neurochemistry: dopamine, serotonin, cortisol, and oxytocin levels with configurable decay rates
- Lesson learning: correction detection in English and Vietnamese, with confidence that rises on repetition
- Proactive suggestions: pattern-based proposals gated by frequency, confidence, and time triggers
- Context injection: about 200 tokens of mood, relationship, personality, memory, and lesson state per prompt
- Runtime tools: status, personality, emotions, memory query, skills, reflection, and snapshot commands
- Single-file storage: one brain.db SQLite database that can be copied for backup or moved between machines
- Memory pruning: confidence decay per day, a minimum-confidence floor, and a maximum memory count




