· 4 min read · AI

A human-like AI agent in eight hours

A model of the human brain
Photo: Edeh Sophia, CC0 (cropped)

In an eight-hour hackathon I built Bob, a simplified human-like AI agent. He perceives, decides, acts and reflects, one minute at a time. The memory did not work as intended, and I think that is the most useful result.

What Bob is

Bob runs in a loop. He takes in what is happening (from the environment or from me, through an input field). He decides what to do next. He acts. Then he reflects on how it went and stores it in memory. Then the clock moves one minute. Each step is its own module: perception, decision, action, reflection, memory. The backend is Node.js and Express, the frontend is HTML and Tailwind CSS. You can try the demo or read the project page.

Splitting it into modules paid off. I could debug one part at a time.

I was not the first to do this

The loop is not new. Two papers from 2022 and 2023 set the pattern. Chain-of-thought prompting showed that models reason better when they write out their steps. ReAct mixed that reasoning with actions, so the model can think, act, look at the result and think again. That is close to my perceive, decide, act cycle.

The closest cousin is Generative Agents from Stanford. They put 25 AI characters in a small simulated town. The agents record their experiences, turn them into higher-level reflections, and use both to plan. Reflexion also has the agent reflect in words after a failed attempt and keep that note in an episodic memory buffer for the next try.

Calling the modules "perception" and "memory" is also old. Cognitive scientists have built such systems for decades. Soar and ACT-R split a mind into parts like declarative memory (facts) and procedural memory (how to do things). A 2023 paper, CoALA, borrows from that tradition to organise language agents. It describes a short-term working memory plus long-term episodic, semantic and procedural memory.

Why memory was the hard part

My page says the memory module "did not function as intended". Bob became inconsistent. I did not dig into exactly why in eight hours, so I won't pretend I know. But the research explains why it is hard.

A language model only knows what is in its prompt. So memory means choosing what to put back in. Storing things is easy. Choosing is hard.

The Stanford team found that dumping everything in is not an option. In their words, the full memory stream "can distract the model and does not even currently fit into the limited context window." Their fix is to score each memory and fetch only the top few. The score mixes how recent it is, how important it seems, and how relevant it is to the situation now. They also found that raw observations are not enough, and that agents with only raw memory "struggle to generalize or make inferences". That is why they add reflection.

Even when everything fits, models are uneven readers. Lost in the Middle found that performance drops when the useful fact sits in the middle of a long prompt. MemGPT goes another way: it moves data between fast and slow memory, like an operating system does, so the model sees a small, managed window. Its authors later turned it into a company, Letta.

My page lists "relevance-based memory and summarization" as the fix. In hindsight that matches what the Stanford team did. I just did not get there in eight hours.

What I think

This is opinion. Memory, not reasoning, is the weak point of these agents. A model can think well about what is in front of it. Deciding what should be in front of it is a design problem, and design problems need many tries. I would also say "human-like" was too ambitious. I had written that simplifying may work better than copying the human mind, and the papers agree: the useful parts they keep are small. Record, retrieve, reflect.

A fair caution: a demo with one user and a one-minute clock says little about how this works at scale. It was a sketch, and I treat it as one.

Sources

Comments