How to give your AI a persistent personality across sessions
A language model doesn't remember who it is. It only knows what you send it this turn, so a lasting identity has to be something your system rebuilds, every time.
Short answer: AI models keep nothing between requests, so a persistent personality has to come from your system. Store the character's identity outside the chat, send it again on every turn, keep the agent's memories in a separate store it can write to, and don't give it any way to edit its own identity.
A model API call has no past, which is also why AI forgets what you said. Between requests, nothing about your character is kept unless you store it and send it again. The memory features in consumer chat apps are that same trick, done for you.
That's good news. It means identity is an engineering problem, and you control the inputs. You need to decide what gets sent, in what order, and what is allowed to change. Here are the seven decisions that matter most.
1. Decide what can never change
Most failed personas never made this decision. Everything sits in one prompt or one memory store, so everything is equally open to change. Sort your character into two groups:
| Identity | Experience | |
|---|---|---|
| Contains | Values, boundaries, voice, origin, how it makes decisions | Events, user preferences, project notes, journal entries |
| Who writes it | You, the creator | The agent, as it goes |
| How it changes | Rarely, and on purpose | Constantly, including pruning |
| If they conflict | Identity wins | Gets reinterpreted or dropped |
A quick test for any fact: if this were deleted, would the agent be a different character, or just one who'd forgotten something? The first belongs in identity, the second in experience.
2. Store them separately
Separation has to be enforced by the system, not requested in a prompt. "Never change your core values" is only a request. An agent with no way to write to its identity store is a guarantee.
The SoulScript Engine calls this dual-FAISS memory: one search index for soul scripts, another for the memory vault. You don't need FAISS for the idea to work. Two tables with different write permissions do the same job. What counts is that the agent's write path only reaches one of them.
3. Rebuild the prompt on every turn
Don't rely on identity surviving in the chat history. Assemble it fresh for each request, most important material first, so nothing depends on what happened earlier in the conversation:
# A sketch: search(), core_prompt and the like stand in for your own storage.
def build_request(agent, history, user_message, history_budget=30_000):
system = "\n\n".join([
agent.core_prompt, # always sent, in full
agent.identity.search(user_message, k=5), # relevant soul script sections
agent.pinned_knowledge, # always-on facts
agent.memories.search(user_message, k=5), # relevant experience
])
# Walk backward from the newest message and stop when the budget runs out.
recent = []
for message in reversed(history):
if len(message["content"]) > history_budget:
break
history_budget -= len(message["content"])
recent.insert(0, message)
return system, recent + [{"role": "user", "content": user_message}]
Notice what the budget applies to: chat history gets cut, identity doesn't. A chat of a thousand messages sends the same core prompt as a chat of one.
4. Pin what must always be there
Semantic search retrieves what looks similar to the current message, and that creates a trap. A user who slowly steers a character toward a boundary may never use words resembling that boundary, so the section that matters is never retrieved.
So split identity by how it's delivered:
- Always sent: a short core prompt with who it is, its voice, and its non-negotiable boundaries.
- Retrieved when relevant: the deep material, such as formative memories, detailed protocols and backstory.
Keep the pinned part short. Everything in it costs tokens on every turn, and a shorter list of rules is easier to follow than a long one.
5. Be strict about what gets saved
Writable memory is how identity leaks back in. The agent's own summaries return later as facts, so a few rules go a long way:
- Record events, not self-descriptions. "User asked me to review their contract on Tuesday" is safe. "I've grown more cautious" is a change of identity disguised as a memory.
- Attribute claims. Store "the user says I promised them X", not "I promised X". Otherwise anyone can write your character's history by asserting it.
- Add a date and source so stale or dubious entries can be found and pruned.
- Label memories on the way in. Present them as retrieved context, and state that identity takes priority when they conflict.
Treat anything that came from a user or a web page as untrusted input. A saved memory is effectively a future prompt, so it deserves the same caution as any other prompt injection risk.
6. Version the identity
Keep identity files in version control, or hash each section, so you can answer "what changed since it last felt right?". In the engine, a manifest records a SHA-256 hash for every soul script section and can list what was added, removed or changed.
7. Let it grow, with you holding the pen
A character that can never change gets flat, and it's the most common objection to all of the above. Growth and stability are compatible once you split them into two speeds:
- Fast: experience accumulates on its own. The agent knows you, remembers shared history, and adapts how it applies its values.
- Slow: real changes to identity are reviewed. If the agent's journal keeps returning to a new lesson, read it and decide whether to promote it into the soul script yourself, then re-run your tests.
People work a little like this. Your week changes what you know much faster than it changes who you are. The review step is what makes the difference between growth and drift: growth is a change you chose.
A checklist
- Identity and experience are in separate stores.
- The agent has no way to write to identity.
- The prompt is rebuilt on every turn, identity first.
- Non-negotiable boundaries are pinned, not left to retrieval.
- History is trimmed before identity ever is.
- Memories are dated, attributed and prunable.
- Identity files have version history.
- Tests run after every identity, memory-system or model change. (Here's how to build them.)
Retention isn't consciousness. All of this makes a character consistent. It doesn't settle any deeper questions about what the system is, and it's better not to imply otherwise to your users.
