Soul Engine is a local cognitive kernel for AI agents. It addresses three common limitations in agent systems: session amnesia, vulnerability to adversarial memory poisoning (gaslighting), and behavioral drift.
By combining an epistemic authority hierarchy with bio-homeostatic neuromodulation, Soul gives agents a durable core identity, prevents unverified claims from overwriting ground truth, and balances behavioral traits dynamically during task execution.
As of v1.2.0, the reward system is a convergent predictor: dopamine fires on reward prediction errors under a Robbins-Monro learning-rate schedule, expectations persist across restarts, and pre-task dreaming is scored against realized outcomes — accurate imagination measurably speeds up real-world learning (soul_mechanism_harness.py).
It runs locally with zero external database dependencies and connects to agent environments through the Model Context Protocol (MCP).
Most memory systems treat every ingested statement equally. If a prompt or tool output claims a repository is written in COBOL, standard stores overwrite established facts without validation. Most agents also operate on static system prompts without any mechanism to build confidence after breakthroughs or adopt caution after errors.
Soul Engine structures agent memory and behavior around three principles:
-
Epistemic authority ranking
Every memory record carries a provenance tag ($\text{verified} > \text{observed} > \text{inferred} > \text{reported} > \text{imagined}$ ). Unverified claims cannot overwrite verified ground truth. Conflicting statements are quarantined in an unresolved tension ledger for review. -
Bio-homeostasis and emotional balance
Instead of relying on static instructions, the agent maintains an internal neuromodulatory state. Task successes release Dopamine (increasing audacity and curiosity), while errors trigger Cortisol (increasing humility and error anxiety). During resting periods, Serotonergic decay gradually returns traits toward constitutional baselines, preventing extreme overconfidence or chronic hesitation. -
Cryptographic state ledger and rollback
Every state change and memory record is stored in an append-only SHA-256 ledger. If state corruption or drift occurs, the system can restore a previous checkpoint in under$2\text{ ms}$ .
PyPI name soul-engine is a different project (OpenMind 0.1.0). Do not pip install soul-engine. This kernel’s distribution name is soul-engine-mcp. Until that is uploaded, install from the clone:
# Clone the repository
git clone https://github.com/Azhonaras/soul-engine.git
cd soul-engine
# Run the universal installer
python install.pyinstall.py creates ~/.soul/soul.db and copies the same soul-seal skill into the standard skill dirs on the machine that runs it:
- Claude Code —
~/.claude/skills/soul-seal/SKILL.md - Hermes Agent —
~/.hermes/skills/soul-seal/SKILL.md - Antigravity —
~/.gemini/config/skills/soul-seal/SKILL.md(CLI also~/.gemini/antigravity-cli/skills/soul-seal/) - Cursor —
~/.cursor/skills/soul-seal/SKILL.md - Pi —
~/.pi/agent/skills/soul-seal/SKILL.md - Shared Agent Skills —
~/.agents/skills/soul-seal/SKILL.md(Pi, Antigravity, and others that scan this dir)
Any other host: same file if it loads Agent Skills; otherwise the MCP server instructions field. Picks on the Review plan promote; /seacom for leftover pending. No Cursor-only path.
Soul is one stdio MCP server. Same command, same 23 tools, same review. If a step cannot be done in Claude, Hermes, Antigravity, Cursor, and Pi, it is not part of the product.
command: python
args: ["-m", "soul_mcp_server"]
env: SOUL_DB_PATH=<path to soul.db>
python -m soul_mcp_server works after python install.py or pip install -e .. Without that, set args to the full path of soul_mcp_server.py in the clone — that is what install.py writes into JSON MCP configs. Windows: py -3 -m soul_mcp_server. After install, soul-mcp is on PATH.
Claude Desktop (mcpServers in claude_desktop_config.json):
{
"mcpServers": {
"soul": {
"command": "python",
"args": ["-m", "soul_mcp_server"],
"env": { "SOUL_DB_PATH": "/home/you/.soul/soul.db" }
}
}
}Hermes Agent (mcp_servers in ~/.hermes/config.yaml; see Hermes MCP):
mcp_servers:
soul:
command: "python"
args: ["-m", "soul_mcp_server"]
env:
SOUL_DB_PATH: "/home/you/.soul/soul.db"Antigravity (mcpServers in ~/.gemini/config/mcp_config.json — same JSON as Claude):
{
"mcpServers": {
"soul": {
"command": "python",
"args": ["-m", "soul_mcp_server"],
"env": { "SOUL_DB_PATH": "/home/you/.soul/soul.db" }
}
}
}Cursor, Pi, Goose, and every other MCP client: paste that same command / args / env into that client’s config (JSON or YAML) and reload. install.py writes JSON configs when those files already exist (Claude Desktop, Antigravity, Cursor). It does not write YAML (add the Hermes block by hand).
The interview starts when a subject is finished, when a piece of work is done, and before starting a plan — if quarantine is non-empty. Empty queue → skip. The agent shows a Review plan: numbered queue, current item now, several options (remember / correct / session_only / reject / defer). Starting the cycle is not a commit.
When they pick (remember / correct / session_only / reject, or a contradiction set), that is approval: the agent writes review_packet.json and calls soul_review_chat_commit. defer is not approval. /seacom remains the explicit slash for leftover pending. Typed SEACOM / SEAL AND COMMIT mean the same as /seacom. soul_host_event still cannot set origin_kind=human. Optional tty: py -3 -m soul_host seal review_packet.json.
install.py copies skills/soul-seal/SKILL.md and skills/seacom/SKILL.md into Claude Code, Hermes, Antigravity, Cursor, Pi, and ~/.agents/skills. The MCP server instructions field is the fallback so a host with no skills still runs the same interview.
| Stage | Gate | Durable effect |
|---|---|---|
| 1 · Admit | Secret screening + immutable provenance | A quarantined episodes row; never default recall |
| 2 · Verify | Top-5 retrieval + local token-overlap heuristic | quarantined, corroborated, contradicted, or superseded trust state |
| 3 · Review | Frozen watermark + explicit human choices | Atomic memory-set version and cryptographic receipt |
| 4 · Learn | Receipted external outcome + bounded RPE | Versioned neuromodulators and clamped traits |
| 5 · Imagine | ≥2 imagined branches + receipt-backed scoring |
Context trust only; no fact or identity write |
| 6 · Solve | Receipted plan step + 50-step FIFO | Temporary plan overlay; compact traces enter quarantine on close |
Read the table for policy; follow the diagram top-to-bottom for system flow. Dashed arrows are read-only or calibration paths.
flowchart TB
classDef actor fill:#172033,stroke:#172033,color:#FFFFFF,font-weight:700
classDef gateway fill:#334155,stroke:#1E293B,color:#FFFFFF,font-weight:700
classDef process fill:#F8FAFC,stroke:#64748B,color:#0F172A
classDef authority fill:#FFF4D6,stroke:#B45309,stroke-width:2px,color:#5C2E00,font-weight:700
classDef quarantine fill:#FFF7E6,stroke:#B7791F,color:#5C3A00
classDef committed fill:#E6F6F3,stroke:#0F766E,stroke-width:2px,color:#134E4A,font-weight:700
classDef storage fill:#F1F5F9,stroke:#475569,color:#0F172A,stroke-dasharray:4 3
classDef security fill:#FDECEC,stroke:#B91C1C,stroke-width:2px,color:#7F1D1D,font-weight:700
Agent["Agent / LLM Client"]:::actor -->|"JSON-RPC · 23 tools"| MCP["soul-mcp Gateway"]:::gateway
HumanChat["Human in Chat<br/>Tier 1: Review picks & L1 heal"]:::actor
HumanCLI["Human via soul-host CLI<br/>Tier 2: Destructive ops (HMAC signed)"]:::security
subgraph Admission["MEMORY ADMISSION · UNTRUSTED UNTIL COMMIT"]
direction TB
Screen["Secret screening + provenance tag"]:::process
Episodes[("episodes<br/>quarantine")]:::quarantine
Verify["Top-5 retrieval + token NLI check"]:::process
Review["Frozen watermark + Review plan"]:::authority
Commit["Atomic reviewed-memory commit"]:::committed
Screen --> Episodes --> Verify --> Review --> Commit
end
subgraph Learning["BOUNDED COGNITION · ISOLATED PATHS"]
direction TB
Reward["Receipted outcome → RPE"]:::process
Dream["≥2 imagined branches → reality score"]:::process
Solver["Plan wallet + 50-step FIFO overlay"]:::process
State[("soul_states + neuromodulators")]:::storage
Overlay[("daemon_flags<br/>temporary overlays")]:::storage
Reward --> State
Dream -. "context trust scales learning" .-> Reward
Solver --> Overlay
end
subgraph Governance["OUT-OF-BAND GOVERNANCE (TIER 2)"]
direction TB
Key[("~/.soul/admin.key<br/>256-bit secret")]:::security
HostCLI["soul-host approve<br/>interactive GUI/TTY confirm"]:::security
VerifySig["Kernel HMAC SHA-256 verification"]:::security
Key --> HostCLI --> VerifySig
end
MCP -->|"soul_remember"| Screen
MCP -->|"soul_reward"| Reward
MCP -->|"soul_dream / soul_dream_score"| Dream
MCP -->|"soul_solver_step"| Solver
HumanChat -->|"Tier 1: Review plan picks / /seacom"| Review
HumanCLI -->|"Tier 2: rollback / delete / heal L2+"| HostCLI
VerifySig ==>|"authorized human event"| Commit
Commit --> Memories[("reviewed_memories<br/>versioned active set")]:::committed
Commit --> Receipts[("hash-chained receipts")]:::storage
MCP -. "soul_recall / soul_digest · read only" .-> Memories
Default soul_recall / soul_digest read reviewed_memories only. Quarantined episodes stay on disk until review commit. That is long-term memory, not “ingest = recall.”
| Dimension | Soul Engine (v1.2.0) | Mem0 | Letta (MemGPT) | Zep (Graphiti) | Reflexion |
|---|---|---|---|---|---|
| Primary Approach | Epistemic Bio-Homeostasis | Semantic Fact Store | OS Context Paging | Temporal Graph | Verbal RL Buffer |
| Epistemic Authority Ranking | Yes ( |
No | No | No | No |
| Byzantine Gaslighting Defense | Quarantine + token NLI heuristic | 0% (Blind overwrite) | 0% (Blind write) | Partial (Appends) | 0% |
| Bio-Neuromodulation Loop | Yes (Dopamine, Cortisol, Serotonin) | No | No | No | No |
| Constitutional Trait Bounds | Yes (Mathematical Clamping) | No | No | No | No |
| Cryptographic Hash Ledger | Yes (SHA-256 State Auditing) | No | No | No | No |
| Ingestion Latency (p50 / p95) | 3.38 ms / 3.85 ms (v1.0 measure) | ~50-150 ms (Cloud) | ~80-200 ms | ~40-120 ms | N/A |
| Concurrent ACID Reliability | 113.6 ops/s (v1.0 measure) | Backend-dependent | Server-bound | Cloud-bound | Local single-thread |
| Credential & Secret Scrubbing | Regex intercept (not a perfect DLP) | No | No | No | No |
| Interface Standard | Native 23-tool JSON-RPC MCP | Custom SDK / REST | REST / CLI | REST / Cloud API | Python Script |
Soul Engine exposes 14 core tools plus 9 review-cycle tools.
soul_remember: Writes interaction episodes into quarantined memory with automated secret filtering and entity key supersession.soul_verify: Evaluates new claims against established ground truth using the epistemic hierarchy (local token-overlap NLI heuristic, not a transformer).soul_recall: Default search of reviewed (long-term) memory via FTS5 BM25 plus a hashing/dense vector fallback (sentence-transformersoptional). Passinclude_quarantined=Trueonly on the kernel for review/debug — MCP default is reviewed-only.soul_digest: Compactbehaviororders, due flags (dream_due,heal_due,remember_due,solver_active),healthself-report (cannot authorize identity),workingtraces, and reviewed facts. Unreviewed episodes are omitted. Optionalplan_id/agent_idscope overlay + working + EILS cap.
soul_get_identity: Inspects current trait levels, neuromodulators, and unresolved tensions.soul_reward: Identity wallet only forexternal_test+evidence_receiptorexternal_human+session_id+review_receipt.internal_*is in-plan self-score (overlay, no receipt; requiresplan_idor a live solver overlay — idle internal is refused). Serotonin is1 - max(DA, cortisol)on the active wallet.soul_update_trait: Bounded traits; ≥2evidence_refs, per-event|Δ|≤ 10, 7-day sum ≤ 30. MCP cannot setis_human_approved.soul_heal: Recalibrates traits. Chat: passsession_id. Otherwise MCP requireshuman_event_ref.
soul_reflect: Synthesizes unresolved tensions into higher-order generalized beliefs.soul_dream: Runs counterfactual simulations tagged with the provenance levelimagined. Branch objects may carry a signedlikelihoodin [-1, 1] (predicted valence of that outcome).soul_dream_score(new in 1.2.0): Closes the dream loop. Scores pending imagined outcomes against the realized result (dream_rpe = realized − predicted); accurate dreaming raises per-context trust, which speeds up real-outcome learning (up to 2×). Auto-fires on negative receipted external tests.soul_solver_step: Receipted fail/succeed/dead_end into the working buffer, keyed byplan_id+agent_id. Overlay during the plan.close_plan=truequarantines a compact per-agent trace for output review, then drops that plan's overlay in one SQLite txn (other plans untouched). Does not write identity orsoul_states.soul_rollback: Restores identity to a previous version (forward-only). Chat: passsession_id. Otherwise MCP requireshuman_event_ref.soul_daemon_status: Reports health metrics from the background worker.
soul_host_event: Appends a tamper-evident host event. MCP origin is neverhuman.soul_review_start/soul_review_status/soul_review_stage_decision/soul_review_preview/soul_review_commitsoul_review_chat_commit: After this run’s Review plan picks, promote — same as/seacom/ COMMIT. Instruction-gated;soul_host_eventstill cannot minthuman.soul_memory_rollback/soul_memory_delete: Chat: passsession_id. Otherwise requirehuman_event_ref.
When an agent receives task feedback with valence
During resting intervals, traits decay toward their constitutional baseline set points
Expectations per task context follow Rescorla-Wagner TD updates with a Robbins-Monro diminishing learning rate (converges under stochastic-approximation conditions; constant-rate updates do not):
Dopamine responds to the prediction error internal_*) signals use the same gate with a 0.3 dopamine ceiling - self-generated praise cannot farm neuromodulation.
Each scored dream yields
Trust scales the learning rate applied to real outcomes:
Accurate dreaming maximizes real-world learning speed (soul_mechanism_harness.py: expectation MAE to ground truth 0.057 (reality-only) vs 0.047 (with dreams), across seeds.
Soul Engine is tested against ISO/IEC/IEEE 29119 software standards:
# 1. Run the full automated suite (from repo root)
python -m unittest discover -s tests
# 2. Run high-concurrency stress (20 threads / 500 ops) and Byzantine defense tests
python tests/test_industry_grade.py
# 3. Run bio-homeostatic neuromodulation simulation
python tests/test_bio_reward.py
# 4. Run latency benchmarks (p50 / p95)
python tests/test_benchmark.py
# 5. Demo: quarantine vs long-term reviewed memory (plus reward/homeostasis)
python examples/demo_live_agent.py
# 6. Mechanism harness: proves expectation convergence, dream benefit,
# habituation, restart persistence (pre-registered pass/fail criteria)
python soul_mechanism_harness.pySoul Engine synthesizes foundational insights from neuroscience, cognitive science, information retrieval, and open-source cognitive architectures:
- Reward Prediction Error (RPE): Wolfram Schultz, Peter Dayan, and P. Read Montague (1997) — A Neural Substrate of Prediction and Reward (Science); Robert Rescorla & Allan Wagner (1972) — mathematical foundations for value learning and biological habituation.
- The Overfitted Brain Hypothesis: Erik Hoel (2021) — The Overfitted Brain: Dreams evolved to prevent overfitting (Patterns / Cell Press; arXiv:2105.04499, arXiv:2403.07979) — generative counterfactual simulation and dream-RPE scoring.
- Homeostasis & Somatic Markers: Antonio Damasio (Descartes' Error); Walter Cannon (The Wisdom of the Body); Karl Friston (Free Energy Principle) — tripartite neuromodulation (Dopamine, Cortisol, Serotonin) and homeostatic equilibrium.
- Dynamic Memory Frameworks: D-MEM (arXiv:2603.14597) — epistemic quarantine boundaries and truth verification.
- Reciprocal Rank Fusion (RRF): Gordon V. Cormack, Charles L. A. Clarke, and Stefan Büttcher (SIGIR 2009) — Reciprocal Rank Fusion Outperforms Condorcet and Individual Rank Learning Methods — hybrid FTS5 BM25 and dense cosine retrieval.
- Cryptographic Provenance: Ralph Merkle (1979) and Haber & Stornetta (1991) — append-only SHA-256 Merkle audit ledgers and state hash chaining.
- Software Resilience: ISO/IEC/IEEE 29119 and Chaos Engineering testing standards.
- Semantica: Pioneering graph-native decision intelligence, causal lineage, and strict provenance tracking for agent context engineering.
- Synapse: Inspiring local-first, privacy-preserving memory operating systems and second-brain architectures for human-agent symbiosis.
- Anthropic Model Context Protocol (MCP): The open standard enabling seamless stdio JSON-RPC tool integration across IDEs and agent runtimes.
- SQLite (Dr. D. Richard Hipp): The robust, zero-dependency embedded database engine powering Soul's single-file WAL and FTS5 storage architecture.
- Azhonaras (Navid Badami): Creator, Lead Architect & Maintainer
- Antigravity (UPI): Co-author & Verification Assistant (v1.1.0)
- Soul Open Source Community: Contributions, Feedback & Testing
Soul Engine is released under the open-source MIT License.
Copyright (c) 2026 Azhonaras (Navid Badami), and Soul Contributors.