I Built My AI a Brain and It Started Thinking for Itself
Cashew - a thought graph that grows, forgets, and dreams, inspired by nature!
Okay. Full disclosure, my previous blogs [1][2] were completely written by AI even though the ideas were my own. Here, I’m going to put effort to write this myself and just let AI polish it, and hoping more readers will stay around because of that.
How It All Started
I was watching this YouTube video by Veritasium on fractals and power laws and how in nature, it’s the simple rules that can lead to very complex phenomena. And something in me started ticking. For those of you who don’t know about fractals, I’d highly recommend watching the video. But, here’s the TL;DR: everything in nature follows these fractal patterns where the pattern is self-similar at every scale, a snowflake, a tree branch, etc., and the complexity emerges from how simple rules interact with each other. For example, wildfires caused by lightning strikes are completely random. But, the exact same lightning depending on WHERE the lightning strikes, i.e., a dense forest will cause the most catastrophic wildfire. The same patterns are true for literally EVERYTHING in nature, from earthquakes to human circulatory system, and YES! EVEN OUR BRAINS!!
So I thought to myself, why don’t I build a brain for my AI assistant (OpenClaw, by the way, if anyone is curious) modeled on these exact same principles and see what happens? And I did just that.
To me, fractals resembled graphs. The self-similarity at every scale resembled some kind of a self-organizing mechanism. It made me wonder if my brain behaved the same way. My thought process is always like a reasoning chain where when I think x, the whole body of reasoning that supports x just pops right out for me to articulate like x->y->z almost like I’m retrieving linked nodes of an intrinsic graph data structure. Each of those “nodes” is one of my thought snippets, and in some elegant fashion my brain has the capability to bring out just the right ones when I need them (or maybe not all the time 😂). Moving forward, I will be using “thoughts” and “nodes” interchangeably.
The Simple Rules
For my fractal brain to scale well, everything needs to be stupidly simple. The complexity emerges as a result of these simple rules interacting with each other in unimaginable ways. What this meant for me when designing it was a very simple gate. “Is this feature making our system simpler or complex? If it is complex, is that really worth it? Is there a way I can make my feature ‘emerge’ instead of me directly building it?” This pretty much became the guiding philosophy that helped me build cashew.
So, there are essentially 5 rules (or operations) that govern cashew:
Extract: capture a thought along with its vector embedding which resembles a mathematical fingerprint of sorts.
Connect: new thoughts will link to similar existing thoughts automatically. This is done via cosine similarity. Notice that we are not attaching any sort of semantics to these connections. Those will be derived by the LLM (the reasoning engine).
Sleep: This is kind of where the magic happens. Periodically, this process finds connections between thoughts that already exist, but were never introduced to each other. There is also a special dreaming where unexpected novel insights are generated from cross-domain connections. More on this later.
Decay: This is where the brain forgets the thoughts slowly that aren’t reinforced.
Protect: Thoughts that you keep coming back to will reach a stage of permanence at which point they are shielded from decay.
That’s it! These are the 5 rules that summarize the entire architecture of cashew. Each rule was very carefully thought through to be simple and flexible enough to facilitate highly complex interactions.
The Complexities That Emerged
Once I had the above rules set in place, along with some minimal setup like a db (SQLite) and an embedding model, I went on to bring in my Claude archives and other AI conversation histories to extract their content into the cashew brain. A few sleep/dream cycles later, what I found was pretty astounding. Just look at this beauty:
And appreciate how power laws work. Because the patterns you see here are undoubtedly telltale signs of fractal systems at play. What you are seeing is a visual representation of an integrated AI brain which combines mine and my AI assistant’s (his name is Bunny) thoughts/working principles all encoded into the graph.
When Bunny Started Thinking for Himself
The visual representation I showed is pretty fancy. But, there’s something way deeper and more interesting here. It’s the insights Bunny generated by connecting widely disconnected nodes (the dreams I was talking about earlier) to observe patterns that I would never see before. The think cycles could pattern match between different domains like my work style, religious upbringing, cashew’s architecture (yes, cashew’s design principles are stored as thoughts in my personal brain), etc., to form genuinely good insights from time to time. Of course, not every insight is smart. And that’s why forgetting is not a bug but a feature! Low quality thoughts have to “fade away” and old (non-permanent) perspectives need to weaken to make room for new ones.
What I Learned About My Own Brain
I’ve realized the simple rules I laid out have a very deep philosophical backing and reflect a lot about my own thought process. For example, some nodes reach permanence after being accessed enough number of times. Then they become decay proof. Why not just keep it simple and let nodes ALWAYS earn their place since we are aiming for simplicity? But I realized permanence is important because some thoughts we have accessed enough number of times that we don’t need to always recollect them to remember them. These permanent nodes are like your “fingerprint” or your identity. Unfortunately, these are also your traumas. And you cannot erase traumas. You can only correct them by reinforcing your alternate perspective. Keep reinforcing until those perspectives also reach permanence. This to me is the healing aspect.
Playing by the Strengths
When designing this system, I was clear about one thing. The graph layer is the “dumb retrieval system” whereas the reasoning smarts should always be kept with the LLM. Bring any “smartness” to the graph itself and it becomes a losing game because you’ll add code you don’t want to maintain. This kind of ablation testing made me kill features which I first thought were useful. One such feature was edge semantics, which means we give some kind of a “relationship type” between two thought nodes when forming connections. They had labels like “contradicts,” “related to,” “derived from,” etc., but when tested for LLM response quality, removing those edge semantics produced better results. Why? Because the LLM can reason about the relationship by purely looking at the thoughts themselves. We don’t need to hint those relations because it makes the responses more biased/less useful. Similar decisions were also taken to make the retrieval of thoughts efficient and diverse. I’d encourage readers to read the design docs if this topic interests you more.
The Endless Possibilities
We talked about cross-domain pattern recognition as think cycles. But, we never actually forced or created any domains. These clusters, as you can see visually, were created using simple rules. The domains are what emerged. What this means is cashew worked for me the way it did because of the information I fed it. A different person feeding different information would have completely different domains and patterns. The system is built to handle this ambiguity gracefully. Case in point, a friend of mine took cashew’s architecture and applied it to financial research, among many other things. In fact, his graph is actually 10k+ nodes strong at the time of this writing and he loves it! So the system doesn’t care about what domains it is being used for. The access patterns decide the shape of your brain!
Why “Cashew”?
When I was about 10 years old, I was at my aunt’s place in India and noticed the cashews were left open in the kitchen. I knew stray cats would sneak into homes and kitchens to eat food. So I asked her, “do cats eat cashews?” And for some reason, that stuck. To this day, every time I visit or talk to them, they bring it up and ask me if cats eat cashews 😂. I was always that kid who asked a lot of questions. This system doesn’t stop asking questions either. The think cycles are literally the brain asking “what connects to what?” over and over again. So, cashew it is.
An Open Invitation
After going through this philosophical journey while building this project with AI, I think it is time to release this into the world. And this is my open invitation to all tinkerers and builders to give cashew a try, tear it apart if you will to make something of your own, and even contribute to it! This will be my first open-sourced project, and hopefully not the last. This was a lot of fun building with AI and I learned a lot in the process. I would encourage you all to do the same.
Cashew is available as a Python package on PyPI:
pip install cashew-brainIt’s also available as Claude Code and OpenClaw skills that will auto install the cron jobs for think/sleep cycles and give your AI instructions on how to use the brain.
Excited about where this will go.
GitHub: github.com/rajkripal/cashew





