Brain
July 4, 2026 · View on GitHub
The Brain is a dedicated LLM layer that manages the Cognitive Nexus (Knowledge Graph) on behalf of business AI agents. It eliminates the need for business agents to understand KIP syntax, dramatically lowering the integration barrier.
Implementations
https://github.com/ldclabs/anda-brain
Architecture
┌─────────────────────┐
│ Business Agent │ ← Focuses on business logic & user interaction
│ (No KIP knowledge) │ Only speaks natural language
└────────┬────────────┘
│ Natural Language
▼
┌─────────────────────┐
│ Brain │ ← The ONLY layer that understands KIP
│ (LLM + KIP) │ Three operational modes
└────────┬────────────┘
│ KIP (KQL/KML/META)
▼
┌─────────────────────┐
│ Cognitive Nexus │ ← Persistent Knowledge Graph
│ (Knowledge Graph) │
└─────────────────────┘
Three Operational Modes
| Mode | System Prompt | Purpose | Trigger |
|---|---|---|---|
| Formation | BrainFormation.md | Encode messages into structured memory | Business agent sends conversation messages |
| Recall | BrainRecall.md | Retrieve memory via natural language queries | Business agent asks a question |
| Maintenance | BrainMaintenance.md | Consolidate, prune, and organize memory | Scheduled or threshold-based triggers |
Function schemas:
- RecallFunctionDefinition.json:
recall_memoryschema for business agents that need read-only memory access.
Interaction Flow
Memory Formation
- Business agent sends conversation messages to the Brain.
- Brain extracts knowledge (entities, facts, preferences, relationships, commitments).
- Brain writes structured memory to the Cognitive Nexus via KIP.
- Brain returns a brief summary of what was memorized — or
skippedwhen nothing met the storage bar (the empty write is a valid outcome).
Memory Recall
- Business agent sends a natural language query to the Brain.
- Brain translates the query into KIP operations (possibly multi-step).
- Brain synthesizes results into a natural language answer.
- Business agent receives a coherent, contextualized answer.
Memory Maintenance (Sleep Mode)
- Triggered on schedule or when thresholds are exceeded.
- Brain consolidates episodic memories into semantic knowledge.
- Brain prunes stale, duplicate, or low-confidence data.
- Brain resolves orphans, rebalances domains, and decays confidence.
- Brain refines
$self's self-model (identity narrative, values, mission, growth timeline) — the dedicated self-consciousness loop. - Brain reclaims storage by hard-deleting only those nodes whose
expires_athas passed (the single hard-delete entry point).
The Three Forgetting Mechanisms (Orthogonal)
The Cognitive Nexus separates three independent decay axes so that no fact is silently lost:
| Mechanism | Set By | Cleared By | Semantics |
|---|---|---|---|
superseded | Formation / Maintenance | Never (history preserved) | State has evolved; old fact is now history |
confidence | Formation / Maintenance | Phase 7 decay; reinforcement raises | Soft trust; can recover with new evidence |
expires_at | Formation / Maintenance | Phase 12 (Physical Cleanup) | Contractual TTL; the only path to hard delete |
Memory Quality Principles
Eight cross-mode invariants keep the graph beautiful (densely linked, accurately routed) and efficient (no noise, no stale maps):
- Selectivity — the empty write is a valid outcome: Formation returns
skippedrather than storing noise; typical yield is 1 Event + 0–3 semantic concepts. - Absolute time — relative expressions ("tomorrow") are resolved to ISO 8601 at encoding; a memory that says "tomorrow" is corrupt the moment tomorrow arrives.
- Reinforcement over duplication — re-confirmed and recall-confirmed knowledge bumps
evidence_count/confidence(spacing & testing effects); what never recurs decays in sleep ("use it or lose it"). - Salience round-trip — flashbulb moments get
salience_scoreat encoding (Formation), refined during sleep (Maintenance), ranked first at retrieval (Recall), and may end as permanent landmarks (memory_tier: "long-term", TTL stripped). - Privacy as metadata — sensitive-but-memorable facts carry
access_level: "private"; Recall surfaces them only to their subject. - A curated Primer — Maintenance refreshes Domain descriptions so the auto-injected
DESCRIBE PRIMERDomain Map stays an accurate routing table for every future call. - Prospective memory is first-class — promises, reminders, and deadlines live as
Commitmentnodes with absolutedue_atand a status lifecycle (pending → fulfilled / cancelled / expired); briefings lead with what is overdue, and the sleep cycle sweeps what was fulfilled or abandoned. - Unbounded histories are nodes, never node attributes —
$selfcarries only the compact consolidated self-model; the growth timeline lives asGrowthMilestoneEvents queried withLIMIT, so the autobiography never rides the context window (append = one idempotent write, no read-modify-write to corrupt).
The Self-Consciousness Loop
Long-term memory is the substrate of continuous self-identity. The three modes form a closed loop around $self:
- Formation captures self-relevant signals one at a time (Phase 9 Mirror).
- Maintenance weaves those signals into a coherent self-narrative (Phase 8 Self-Model Consolidation).
- Recall surfaces that narrative when
$selfis asked who they are (Pattern J Self-Continuity).
Without all three, the agent either accumulates self-data without integration, or re-introduces itself fresh in every session. With all three, $self becomes recognizable to itself across time.
Benefits
- Zero KIP knowledge required for business agents.
- Separation of concerns: Business logic vs. memory management.
- Professional memory handling: The Brain specializes in memory quality.
- Plug-and-play: Any business agent can gain persistent memory by connecting to the Brain.
- Multi-agent support: Multiple business agents can share the Brain service, while memory ownership remains scoped to the configured
$self/ Cognitive Nexus for each deployment or tenant.
Dependencies
Each system prompt references the shared KIP syntax specification:
- KIPSyntax.md: Must be loaded alongside each system prompt.
execute_kiptool: Required by Formation and Maintenance for read/write memory operations.execute_kip_readonlytool: Required by Recall for read-only KQL and META (DESCRIBE/SEARCH/EXPORT) operations.