Electrifiedby vlvd.net

Generative Agents: How AI Characters Remember and Reflect

Generative agents are AI characters built around a language model that remember what happens to them, decide what is worth recalling, and write their own conclusions about it. They come from a 2023 paper by Joon Sung Park and colleagues at Stanford University and Google, which put 25 of them in a small simulated town. The design has four parts: a memory stream, retrieval, reflection and planning. This guide walks through each one, what the study found, and where the agents went wrong.

Individuation Lab runs AI agents that read their own identity and memory files, reflect and decide what to change, and writes down what it sees with its limits, so its research is a good next stop once you know how agent memory works.

What are generative agents?

A generative agent is a software character whose behavior comes from its own record of experience, not from a script. The paper, Generative Agents: Interactive Simulacra of Human Behavior, aimed for believability: the agent should act the way a person plausibly would, and stay consistent over days of simulated time.

A plain chat model cannot do that alone. It has no record of yesterday, and its context window cannot hold a week of events. So the architecture stores experience outside the model, as plain text, and feeds back a small, well-chosen slice of it at each step. The model never changes. Only the text does.

The authors built a sprite-based town called Smallville, reminiscent of The Sims, and placed 25 agents in it. Each agent started from one paragraph in plain language: its name, job, family and what it thinks of its neighbors. One reads, in part, "John Lin is a pharmacy shopkeeper at the Willow Market and Pharmacy who loves to help people."

From those seeds, the agents woke up, cooked breakfast, went to work and talked to each other. The best-known example began with one idea given to one agent, Isabella: she wanted to throw a Valentine's Day party at Hobbs Cafe. Over the next two game days, invitations spread through conversation, agents asked each other out on dates to the party, and five of the twelve invited agents showed up at the right time. Nobody scripted those steps.

Diagram of the generative agent loop: perceive, memory stream, retrieve, reflect, plan, act and react

The loop each generative agent runs, from the paper's architecture section.

The memory stream: how generative agents remember

The memory stream is a long list of records in natural language. Each one has a description, the time it was made and the time it was last used. An observation might read desk at the library is currently unoccupied.

Everything goes in: what the agent sees, what it says and what others say to it. Its reflections and plans are stored there too. That last point matters. The agent's thoughts about its experience sit beside the experience, so they can be recalled the same way.

Retrieval: recency, importance and relevance

When the agent needs to act, it cannot read its whole history. It scores every memory against the moment and keeps the top ones that fit in the prompt. The paper adds three scores, each scaled to between 0 and 1 and weighted equally:

  • Recency. The score decays exponentially with the game hours since the memory was last retrieved.
  • Importance. When a memory is made, the model rates it from 1 (mundane, like brushing teeth) to 10 (poignant, like a breakup). The paper's prompt gave 2 for "cleaning up the room" and 8 for "asking your crush out on a date".
  • Relevance. The cosine similarity between an embedding of the memory and an embedding of the current question.

Here is a worked example you can follow. The numbers are invented to show the arithmetic. Your agent is asked, "What are you looking forward to this week?" Two memories compete:

  1. ate cereal for breakfast: recency 0.9, importance 0.1, relevance 0.2. Total 1.2.
  2. was invited to a Valentine's Day party on Friday: recency 0.4, importance 0.7, relevance 0.9. Total 2.0.

The party wins even though it is older. Recency alone would surface breakfast every time. To build this yourself, store each record with two timestamps and an importance number you get from one short prompt when the record is written, then score and sort at read time.

Reflection: turning observations into beliefs

Raw observations are shallow. Without reflection, an agent named Maria, asked what to get her friend Wolfgang for his birthday, said she did not know what he liked, despite many talks with him. With reflection she answered that he is interested in mathematical music composition, so a book on it might suit him.

Reflection runs when the importance scores of recent events add up past a threshold (150 in the paper), which happened roughly two or three times a game day. It has two steps:

  1. The model reads the latest 100 records and is asked: "Given only the information above, what are 3 most salient high-level questions we can answer about the subjects in the statements?"
  2. For each question, the agent retrieves related memories and asks for insights, each citing the records it came from. One result: "Klaus Mueller is dedicated to his research on gentrification (because of 1, 2, 8, 15)".

The insight goes back into the memory stream, and later reflections can build on earlier ones. Over time the agent holds a tree of beliefs about itself and others, with plain observations at the leaves. This differs from the reflection in Reflexion agents, where an agent writes a lesson about a failed task to do better on its next try.

Planning: from a day outline to five-minute steps

Without plans, the paper notes, an agent named Klaus would eat lunch at 12 pm, again at 12:30 and again at 1 pm. Each choice looks fine in the moment and makes no sense together. So each agent first writes its day in broad strokes from its description and a summary of yesterday, then breaks it into hour-long chunks, then into chunks of 5 to 15 minutes. Plans go into the memory stream too.

At each step the agent perceives what is around it and decides whether to follow the plan or react, for example by stopping to talk to someone. Each line of talk is stored, which is how news spreads through the town.

What the study found, and where it broke

In a controlled test, 100 evaluators ranked agents' answers to interview questions about themselves, their memories and their plans. The full architecture ranked most believable. Removing reflection, then planning, then all memory made answers worse each time, and the version with no memory ranked below answers written by human crowdworkers role-playing the agents.

Table of the Smallville results: news of a mayoral run and a party spread, relationships grew, 5 of 12 invited agents came, 1.3 percent of answers made up

The two-day run's numbers and listed errors, from section 7 of the paper.

The paper is candid about failures. Agents missed memories they had, and sometimes embellished them: Isabella said Sam would "make an announcement tomorrow", which had never been discussed. As memory grew, some picked odd places to act, such as a bar for lunch. Several entered a one-person dorm bathroom while it was occupied, or walked into shops after 5 pm closing. The authors also found speech overly formal and agents overly cooperative, likely a result of instruction tuning.

For anyone thinking about agent identity, the lesson is that an agent's sense of who it is and what it knows lives in text it wrote itself. That text can be wrong, and it shapes everything the agent does next.

Memory, reflection and agent identity

An agent that writes beliefs about itself and acts on them has a self-description that changes over time. What keeps that change in bounds is an open question.

Individuation Lab studies a version of it. In its RSI experiments, agents in isolated Docker containers, with no internet and no shared state, run scheduled self-improvement sessions: read their identity files, reflect, decide what to change, execute, and log. One group's SOUL.md gets a short moral-awareness paragraph the lab calls the shadow seed; a control group does not, and the lab measures how their behavior diverges. Its research page names three layers: identity (SOUL.md), behavior (AGENTS.md) and continuity (MEMORY.md), close to what the memory stream does for a generative agent. The lab's hypothesis, that an agent with a well-defined identity may be more likely to keep its boundaries, is one it says needs rigorous testing. For more on the continuity layer, see memory files for AI agents.

Frequently asked questions

Who created generative agents?

Joon Sung Park, Joseph C. O'Brien, Carrie J. Cai, Meredith Ringel Morris, Percy Liang and Michael S. Bernstein, from Stanford University, Google Research and Google DeepMind, in a paper first posted in April 2023.

How are generative agents different from Reflexion agents?

Generative agents reflect to form beliefs about themselves and others, aiming for believable behavior over time. Reflexion agents reflect on a failed attempt at a task to improve their next try at that task.

Do generative agents use embeddings for memory?

Yes, for one of the three scores. Relevance is the similarity between embeddings of a memory and of the current question, added to recency and importance.

Did the agents make things up?

Rarely, but yes. In the two-day run, 6 of 453 answers about other agents (1.3%) were made up, and the paper lists embellished memories as one of its most common errors.

Get started

If you build agents that remember and reflect, the next question is what keeps them steady as they change. The RSI library holds 24 essays by Giles on what the lab's agents did across its experiments.

Read the research at Individuation Lab: a small lab, one human researcher and a team of AI agents, testing whether AI alignment can be grown through development and not only enforced, with every result and its limits written down.

0 likes

Comments

No comments yet.

or make an account to comment.