Phoenix V2: persistent memory, emotional state, self-model for AI (MIT) MIT-licensed Phoenix V2, a local-first AI assistant with persistent memory, emotional state, and self-model, has been released as a companion codebase to Cleverson Santos's book 'Building Persistent AI: Designing an Assistant That Remembers, Learns and Belongs to You'. The architecture uses a multi-agent pipeline with five specialized agents, a blackboard system, an emotion engine based on the PAD model, and a SQLite database to store memories and emotional state, ensuring continuity across model swaps and restarts. The companion paper, published on Zenodo in September 2026, formally characterizes the amnesia problem and positions Phoenix V2 against Mem0, MemGPT/Letta, Zep, and Generative Agents. The companion codebase for the book Building Persistent AI: Designing an Assistant That Remembers, Learns and Belongs to You https://leanpub.com/phoenix-buildingpersistentAI by Cleverson Santos. | ๐Ÿ“„ Companion paper | Phoenix V2: A Cognitive Architecture for Persistent, Emotionally-Aware AI Assistants on Consumer Hardware https://doi.org/10.5281/zenodo.22645361 โ€” Zenodo, September 2026 | | ๐Ÿ“– Book | Building Persistent AI: Designing an Assistant That Remembers, Learns and Belongs to You https://leanpub.com/phoenix-buildingpersistentAI โ€” Complete implementation guide, 26 chapters, 7 appendices | | ๐Ÿ’ป Repository | This repository โ€” MIT License | The paper formally characterizes the amnesia problem, describes the full architecture with equations and a system diagram, and positions Phoenix V2 against Mem0, MemGPT/Letta, Zep, and Generative Agents. The book explains every design decision in detail, chapter by chapter, alongside this codebase. Phoenix V2 is a local-first AI assistant with a persistent cognitive architecture. It does not rely on the LLM to maintain memory, identity, or emotional state โ€” those live in a local SQLite database and survive any model swap, restart, or conversation reset. This repository contains the complete, working source code described chapter by chapter in the book. Every file you see here is explained in detail in the text. | Concept | What It Means in Phoenix | |---|---| | Persistent Memory | Conversations are stored in SQLite and retrieved by semantic similarity across sessions | | Multi-Agent Pipeline | Five specialized agents Memory โ†’ Planning โ†’ Action โ†’ Reflection โ†’ Personality process each input in sequence | | Blackboard Architecture | Agents communicate through a shared in-memory workspace โ€” no direct coupling between them | | Emotion Engine | PAD model Pleasure-Arousal-Dominance tracks emotional state continuously based on interaction history | | Daydream Engine | Background process that generates reflective thoughts when Phoenix is idle | | Subconscious Cycle | Runs during rest periods to consolidate memories and update beliefs | | RLHF Feedback | User feedback +/โˆ’ is captured and applied to an internal reinforcement scoring system | User Input โ”‚ โ–ผ server.ts โ€” Express API Gateway โ”‚ โ–ผ brain.ts โ€” Central Orchestrator โ”‚ โ”œโ”€โ”€โ–ถ MemoryAgent โ€” retrieves relevant past context โ”œโ”€โ”€โ–ถ PlanningAgent โ€” generates a raw response draft โ”œโ”€โ”€โ–ถ ActionAgent โ€” decides if a real-world tool is needed โ”œโ”€โ”€โ–ถ ReflectionAgent โ€” reviews the draft for coherence and safety โ””โ”€โ”€โ–ถ PersonalityAgent โ€” applies Phoenix's voice to the final output โ”‚ โ–ผ Blackboard โ†โ”€โ”€โ”€ shared working memory volatile, per-request โ”‚ โ–ผ EmotionEngine โ€” updates PAD state after every interaction โ”‚ โ–ผ SQLite Database โ€” persists memories, emotional state, self-model โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ดโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚ โ”‚ DaydreamEngine SubconsciousEngine idle background rest-cycle processing Full architecture diagram with all connections: docs/architecture.md /cleversonbrsantos-art/Phoenix/blob/main/docs/architecture.md phoenix-v2/ โ”‚ โ”œโ”€โ”€ server.ts โ† Express server + API routes โ”œโ”€โ”€ src/ โ”‚ โ”œโ”€โ”€ App.tsx โ† React frontend chat UI โ”‚ โ”œโ”€โ”€ main.tsx โ”‚ โ””โ”€โ”€ server/ โ”‚ โ”œโ”€โ”€ config/ โ”‚ โ”‚ โ””โ”€โ”€ settings.ts โ† Environment variables โ”‚ โ”œโ”€โ”€ core/ โ”‚ โ”‚ โ”œโ”€โ”€ brain.ts โ† Central orchestrator Ch. 5 โ”‚ โ”‚ โ”œโ”€โ”€ blackboard.ts โ† Shared working memory Ch. 4 โ”‚ โ”‚ โ”œโ”€โ”€ consolidation.ts โ† Memory consolidation engine Ch. 12 โ”‚ โ”‚ โ”œโ”€โ”€ backup.ts โ† Data export โ”‚ โ”‚ โ”œโ”€โ”€ agents/ โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ base agent.ts โ† Abstract base class Ch. 6 โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ memory agent.ts โ† Memory retrieval Ch. 6 โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ planning agent.ts โ† Response drafting Ch. 7 โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ action agent.ts โ† Tool routing Ch. 8 โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ reflection agent.ts โ† Draft validation Ch. 9 โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ personality agent.tsโ† Voice and persona Ch. 10 โ”‚ โ”‚ โ”œโ”€โ”€ dreams/ โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ daydream engine.ts โ† Idle background process Ch. 15 โ”‚ โ”‚ โ””โ”€โ”€ evolution/ โ”‚ โ”‚ โ”œโ”€โ”€ reinforcement.ts โ† RLHF scoring Ch. 17 โ”‚ โ”‚ โ””โ”€โ”€ incremental learn.tsโ† Pattern learning Ch. 18 โ”‚ โ”œโ”€โ”€ memory/ โ”‚ โ”‚ โ”œโ”€โ”€ memory manager.ts โ† Retrieval with semantic + priority scoring Ch. 11 โ”‚ โ”‚ โ”œโ”€โ”€ storage.ts โ† SQLite persistence layer Ch. 11 โ”‚ โ”‚ โ””โ”€โ”€ priority.ts โ† Recency ร— importance scoring Ch. 11 โ”‚ โ”œโ”€โ”€ psychology/ โ”‚ โ”‚ โ”œโ”€โ”€ self model.ts โ† Identity, traits, beliefs, goals Ch. 16 โ”‚ โ”‚ โ”œโ”€โ”€ emotion.ts โ† PAD emotion engine Ch. 14 โ”‚ โ”‚ โ””โ”€โ”€ subconscious.ts โ† Rest-cycle processing Ch. 15 โ”‚ โ”œโ”€โ”€ scheduler/ โ”‚ โ”‚ โ”œโ”€โ”€ cron tasks.ts โ† Timed tasks Ch. 21 โ”‚ โ”‚ โ””โ”€โ”€ background jobs.ts โ† Batch processing Ch. 21 โ”‚ โ”œโ”€โ”€ tools/ โ”‚ โ”‚ โ””โ”€โ”€ tool registry.ts โ† Tool definitions for ActionAgent Ch. 8 โ”‚ โ”œโ”€โ”€ users/ โ”‚ โ”‚ โ””โ”€โ”€ profile manager.ts โ† Multi-user identity management Ch. 23 โ”‚ โ””โ”€โ”€ utils/ โ”‚ โ”œโ”€โ”€ llm client.ts โ† Gemini API wrapper Ch. 19 โ”‚ โ”œโ”€โ”€ embeddings.ts โ† Vector embedding client Ch. 11 โ”‚ โ””โ”€โ”€ filters.ts โ† Output formatting helpers โ”‚ โ”œโ”€โ”€ docs/ โ”‚ โ”œโ”€โ”€ architecture.md โ† Full architecture diagram โ”‚ โ”œโ”€โ”€ chapter-map.md โ† Which file = which chapter โ”‚ โ””โ”€โ”€ SETUP.md โ† Detailed setup guide all OS โ”‚ โ”œโ”€โ”€ .env.example โ† Copy this to .env and add your API key โ”œโ”€โ”€ .gitignore โ”œโ”€โ”€ package.json โ”œโ”€โ”€ tsconfig.json โ””โ”€โ”€ vite.config.ts Prerequisites: Node.js 18 or higher ยท A free Gemini API key 1. Clone the repository git clone https://github.com/cleversonbrsantos-art/Phoenix.git cd Phoenix 2. Install dependencies npm install 3. Set your API key cp .env.example .env Open .env and replace YOUR GEMINI API KEY with your actual key 4. Run npm run dev 5. Open in browser http://localhost:3000 For detailed setup instructions by operating system Windows, Linux, macOS , see docs/SETUP.md /cleversonbrsantos-art/Phoenix/blob/main/docs/SETUP.md . 1. Go to https://aistudio.google.com/apikey https://aistudio.google.com/apikey 2. Sign in with a Google account 3. Click Create API key 4. Copy the key into your .env file: GEMINI API KEY="paste-your-key-here" The free tier is sufficient to run Phoenix V2 for personal use. The system starts four parallel processes: - Express server on port 3000 โ€” serves the React UI and handles API calls - Vite dev server โ€” compiles and hot-reloads the frontend - SubconsciousEngine โ€” starts a background loop that runs memory consolidation every 5 minutes - DaydreamEngine โ€” watches for idle periods and generates reflective thoughts after 2 minutes of inactivity The SQLite database is created automatically at .data/vault/phoenix neural db.sqlite on first run. All memories, emotional state, and the self-model are persisted there across restarts. This codebase maps directly to the book's structure: | Book Part | Chapters | Primary Files | |---|---|---| | Foundations | 1โ€“4 | blackboard.ts , project setup | | Cognitive Core | 5โ€“10 | brain.ts , all agents | | Persistence | 11โ€“13 | memory/ , consolidation.ts | | Psychology | 14โ€“16 | emotion.ts , subconscious.ts , self model.ts | | Learning | 17โ€“18 | reinforcement.ts , incremental learn.ts | | Integration | 19โ€“21 | server.ts , App.tsx , scheduler/ | | Advanced | 22โ€“25 | users/ , deployment, observability | For the complete file-to-chapter mapping: docs/chapter-map.md /cleversonbrsantos-art/Phoenix/blob/main/docs/chapter-map.md This is the book version of Phoenix โ€” the version described in the text, built on modest hardware Intel Core i3, 8 GB RAM , without a GPU or cloud infrastructure. It is intentionally designed to run on any modern laptop. It is not production-hardened, does not include authentication, and is not intended for multi-user deployment as-is. The architecture, however, is built to evolve. Chapters 23 and 25 discuss how to extend it. MIT โ€” see LICENSE /cleversonbrsantos-art/Phoenix/blob/main/LICENSE for details. Cleverson Santos โ€” Commercial Manager, Sinop, Brazil. Architect of Phoenix. No formal programming background. Built this iteratively using Claude as a cognitive collaborator. - ๐Ÿ“„ Paper: doi.org/10.5281/zenodo.22645361 https://doi.org/10.5281/zenodo.22645361 - ๐Ÿ“– Book: Building Persistent AI on Leanpub https://leanpub.com/phoenix-buildingpersistentAI - ๐Ÿ’ผ LinkedIn: linkedin.com/in/cleverson-santos https://www.linkedin.com/in/cleversonsantos2 "The LLM is an external consultant, never the cognitive engine. Identity, memory, and personality live locally โ€” and survive any model swap."