Why I Built an AI Agent with17 Brain Regions (And What I Learned)
Most AI agents are stateless tools. You give them a prompt, they give you an answer, and then... they forget everything.
That bothered me. So I spent18 months building MeshCtx — an open-source AI agent platform that mimics how the human brain actually works.
The Problem with Stateless Agents
Every time you talk to ChatGPT or Claude, it's starting from scratch. No memory consolidation. No learning from mistakes. No self-improvement.
I wanted something different. I wanted an agent that could:
- Remember and consolidate memories like humans do during sleep
- Modify its own behavior based on experience
- Coordinate multiple "brain regions" for complex tasks
The17 Brain Regions
Inspired by neuroscience, I mapped cognitive functions to agent modules:
| Brain Region | Agent Function |
|---|---|
| Prefrontal Cortex | Planning & Goal Setting |
| Hippocampus | Memory Consolidation |
| Amygdala | Emotional Processing |
| Cerebellum | Motor Coordination |
| Wernicke's Area | Input Comprehension |
| Broca's Area | Output Generation |
...and11 more regions, each handling specific cognitive functions.
Self-Modifying Code
The most controversial feature: the agent can rewrite its own logic at runtime. Inspired by Quine programs and genetic programming, the SelfRewriter module can:
- Analyze its own performance
- Generate code modifications
- Test changes in a sandbox
- Apply successful modifications
# The agent can modify its own prompts and logic
rewriter.analyze_performance(metrics)
suggestion = rewriter.generate_modification()
if rewriter.test_in_sandbox(suggestion):
rewriter.apply(suggestion)
Memory That Consolidates
The SDM (Sparse Distributed Memory) system doesn't just store vectors. It:
- Creates emotional weightings for memories
- Consolidates important memories over time (like sleep)
- Forgets irrelevant information naturally
- Links related memories across sessions
What I Learned
- Biology has good patterns — Evolution spent millions of years optimizing these architectures
- Self-modification is scary but powerful — With proper sandboxing, it works
- Memory is more than storage — Consolidation and forgetting are features, not bugs
- Open source matters — AGPLv3 ensures the community can build on this
Try It Yourself
MeshCtx is free forever for personal use:
pip install meshctx
meshctx init
GitHub: https://github.com/LucyAndLuna2023/meshctx
What brain regions would you add to an AI agent? Let me know in the comments.
Top comments (0)