Day 1. A better memory.
Building Alice — An Experiment in Artificial Cognition

Before we start building anything, let's figure out what we're actually trying to build.
What makes a personality?
I'm sure psychologists and neuroscientists could spend years arguing about this question. But as a software developer, the first thing that came to my mind was memory.
Think about it.
Your knowledge, your skills, your habits, your behavioral patterns. The experiences that taught you what to expect from the world and the people around you.
When you know someone well, you can often predict what they'll say in a particular situation. Sometimes you even know how they'll say it.
A lot of that comes from memory.
Of course, personality is more complicated than that. But memory seemed like a reasonable place to start.
So, where do we store it?
The Context Problem
Most of you have probably used ChatGPT, Claude, Gemini, or Grok.
And if you've spent enough time talking to them, you've probably encountered the same problem.
Context.
Things have improved considerably over time, but early chatbots had a rather primitive approach to memory: a long transcript of messages.
That was essentially everything the model knew about your conversation.
Every question, every answer, every little detail — all stuffed into the context window.
And context windows are not infinite.
Eventually, the conversation becomes too long. You either run out of available context, lose older information, or spend an increasingly ridiculous number of tokens repeatedly sending the same history back to the model.
So, what can we do?
The simplest solution is a sliding window: keep only the most recent messages.
Problem solved!
Well, except now we've built a chatbot with the memory of a goldfish.
It remembers what you said five minutes ago but has no idea what happened last week.
Not exactly the kind of persistent personality I had in mind.
Another approach is summarization.
Ask the model to periodically summarize the conversation, extract important facts, and carry those summaries into future sessions.
That's better. Much better, actually.
But there's a catch.
A summary is not the same thing as a memory.
Every time you compress a conversation, you decide what matters and what doesn't. Small details disappear. Individual events merge into general descriptions. Contradictions get smoothed over.
After enough compression, you might still remember that someone likes coffee, but forget the particular conversation that made this fact interesting.
And if we're trying to build something that develops through experience, those details might matter.
A Memory Is Not a Transcript
Real memory isn't a giant text file etched on the inside of your skull. (Hello, Half-Blood Prince.)
We don't usually remember our lives as perfectly preserved transcripts. We remember events, facts, associations, impressions, and fragments of experiences.
Different kinds of information are stored and retrieved in different ways.
So perhaps our chatbot needs something similar.
I started with four components:
- Short-term memory: The recent conversation. What's happening right now, and what we need to keep the dialogue coherent.
- Episodic memory: Events and experiences. What happened, when it happened, and who was involved.
- Semantic memory: Facts and knowledge. Information about the world, the user, and things learned through conversations.
- Associative memory: Connections between memories. People, events, topics, and concepts linked together in a graph.
The idea was simple.
Instead of continuously feeding the model an ever-growing transcript, we would store information in a structured form and retrieve relevant memories when needed.
A conversation about someone's dog might bring back the dog's name, an earlier visit to the veterinarian, or a funny story from several weeks ago.
Not because those messages were still sitting in the context window, but because the system found connections between them.
Would that make the chatbot intelligent?
Of course not.
Would it give the chatbot something resembling a persistent personal history?
Well, that was worth testing.
Let's Build It
Now comes my favorite part.
We take everything we've just discussed, open Claude, and type:
Create a chatbot in Python with a CLI. I need it to have a better memory.
Then we attach the requirements for short-term, episodic, semantic, and associative memory.
And see what happens.
No artificial consciousness. No grand theory of intelligence. Not yet.
Just a language model, a Python application, and a memory system that should work a little differently from an ordinary chat history.
The first version of Alice was born.
Source code: Alice — Version 1 on GitHub
The First Memory Test
All right. We have a chatbot. We have a memory system.
But does it actually remember anything?
Let's try something simple.
I'll tell Alice three things about myself:
- My name is Michael.
- My son caught a cold yesterday.
- I have a cat named Wasabi.
Nothing particularly complicated. Just three ordinary facts that might come up in a conversation.
Here's the catch: I'll restart Alice between conversations.
That means the previous chat history won't simply remain in the model's active context. If Alice remembers something, the application will need to retrieve it from persistent storage.
Talking to Alice
(alice7) mikhailburilov@MacBook-Pro-Mikhail alice7 % uv run alice-v1 chat
alice-v1 [V1] — db: data/v1/memory.db. /help for commands, /quit to exit.
you> Hey Alice! I'm Michael, by the way. Nice to meet you.
alice> Hey Michael! Nice to meet you too. Thanks for stopping by this late — it's almost midnight on your end, I take it? 😄 What brings you here tonight?
you> /exit
(alice7) mikhailburilov@MacBook-Pro-Mikhail alice7 % uv run alice-v1 chat
alice-v1 [V1] — db: data/v1/memory.db. /help for commands, /quit to exit.
you> Hey Alice, do you remember my name?
alice> Yep, you told me just a minute ago — you're Michael! My memory's not that short 😄 What's up?
you> /exit
(alice7) mikhailburilov@MacBook-Pro-Mikhail alice7 % uv run alice-v1 chat
alice-v1 [V1] — db: data/v1/memory.db. /help for commands, /quit to exit.
you> My son caught a cold yesterday. He's been feeling pretty miserable.
alice> Oh no, poor little guy. Colds always hit kids harder somehow — all that misery packed into someone so small. How's he doing today, any fever or is it mostly just the sniffles and crankiness?
And how are you holding up? Taking care of a sick kid, especially this late at night, is its own kind of exhausting.
you> /exit
(alice7) mikhailburilov@MacBook-Pro-Mikhail alice7 % uv run alice-v1 chat
alice-v1 [V1] — db: data/v1/memory.db. /help for commands, /quit to exit.
you> By the way, I have a cat named Wasabi. Yes, like the Japanese condiment.
alice> Ha, Wasabi — that's a great name for a cat. I'm picturing something either really spicy-tempered or just randomly green-eyed and surprising. Which one is it? 😄
And sorry for derailing — hope your son's feeling a bit better tonight. Is Wasabi keeping you company while you're on sick-kid duty?
you> /exit
(alice7) mikhailburilov@MacBook-Pro-Mikhail alice7 % uv run alice-v1 chat
alice-v1 [V1] — db: data/v1/memory.db. /help for commands, /quit to exit.
you> Morning, Alice. What do you remember about me and my family?
alice> Morning, Michael! Though my clock says it's actually just past 11:30pm your time — maybe you're up early or just winding down a long night? Either way 😄
Here's what I've got on you: your name's Michael, you've got a cat named Wasabi (great name, by the way), and your son came down with a cold yesterday. How's he doing — any better today?
you>
The test isn't about getting Alice to repeat something I said two messages ago. It's about whether information survives the end of a session and can be retrieved later.
And, ideally, whether she can recall it when I ask a slightly different question.
Under the Hood
So where does all this information go?
For this first version, Alice uses SQLite to store conversation data and extracted memories, along with embeddings used for semantic retrieval.
Let's take a look inside the database.
Messages
This is the conversation record: the messages exchanged between Alice and me.
It's useful to preserve the original dialogue, but a conversation transcript alone isn't the memory system we're trying to build.
Memories
This is where things get more interesting.
Instead of relying exclusively on the original messages, Alice can store extracted information that may be useful in future conversations.
Embeddings help the system find relevant information even when a new question doesn't use exactly the same words as the original conversation.
And one more interesting detail: facts have an expiration date.
Each fact has two fields: valid_from and valid_to. They let us track when a fact became true and when it stopped being true.
For example, if I tell Alice that I live in London, and later move to Berlin, she shouldn't simply overwrite London with Berlin and pretend the past never happened.
Instead, she can mark the old fact as no longer valid and store a new one.
This way, Alice doesn't just remember what she knows. She can also remember when it was true.
Of course, storing a memory and successfully retrieving it are two different things.
And even successful retrieval doesn't necessarily mean Alice has learned anything in the human sense.
But it's a start.
What Did We Learn?
So, we now have an agent that can remember things about me.
But what does Alice remember about herself?
What kind of personality can exist if it knows about the world around it, but has no understanding of its own place in that world?
Part of what we call self-awareness seems to involve something rather curious: the ability to treat ourselves as objects of our own knowledge.
We don't just remember what happened to us. We also maintain a picture of who we are, what we've experienced, and how we've changed.
Could Alice develop something similar?
Not consciousness. Not yet, and perhaps not at all.
But a model of herself — something that persists, evolves, and can be questioned.
Well, that sounds like a reasonable next experiment.
To be continued.
Comments
Join the discussionNo comments yet. Be the first to comment.
Building Alice7 — An Experiment in Artificial Cognition
A hands-on engineering journal exploring AI cognitive architectures, memory, learning, belief formation, and emergent agent behavior.


