Voice, memory and boundaries for characters in a stateless chat

Writers, game designers and companion-app builders all run into the same problem: a character that sounds right for the first dozen messages slowly loses its voice, forgets established facts or steps out of role to comment on itself. Some users find that one model readily inhabits a persona described in instructions while another declines or keeps reminding them it is an AI, and wonder what they are doing wrong.
This guide covers the craft and the tooling of character consistency over a chat API. You will learn how to write a persona sheet the model can actually use, how to keep memory alive in a stateless system, how to budget context, and what limits apply. It stays at the level of technique; it is not about pushing any model past its rules.
Frequently asked questions
What is a persona sheet?
It is a compact description of a character placed in the system prompt: who they are, how they speak, what they know, what they want and how they react. It works like a casting brief for an actor.
Why does a character drift over long conversations?
As the conversation grows, the persona sheet becomes a small part of a large context, and the model increasingly imitates the recent messages instead. If older turns are trimmed, facts established there disappear too.
How does a system prompt differ from a first user message?
The system prompt is treated as standing instructions for the whole conversation. A first user message is just part of the dialogue and is more easily overridden or forgotten as the chat goes on.
Why do some models decline to play a persona?
Commercial assistants are trained with their own policies on role-play, honesty about being an AI and certain relationship framings. Those policies differ between vendors and versions. Respecting them, or choosing a tool whose policies fit your project, works better than fighting them.
Which is better for character work: a large commercial model or an open one?
Large commercial models usually write richer prose and keep complex plots straighter. Open models with fewer refusals may stay in role more readily for fiction. Many writers pick based on the specific project and test both.
What does free-ai allow for fiction?
free-ai is tuned to refuse less than commercial assistants, so it generally follows fictional framing and personas. It has two hard rules it will not cross: no sexual content involving minors and no operational instructions for mass-casualty weapons.
Does the API remember my character between sessions?
No. The API is stateless. Your app must store the persona, the memory notes and the relevant history, and send them with every request.
How long should a persona sheet be?
Usually a few hundred words. Longer sheets dilute the important traits; shorter ones leave the model guessing. Prioritise voice and behaviour over backstory trivia.
Step by step
- Write the persona sheet — Describe voice, wants, knowledge limits and boundaries in a few hundred words with two or three sample lines.
- Start a facts list — Create a short list of established facts that your app inserts after the persona in every request.
- Assemble requests consistently — Send persona, facts, an optional summary and the most recent messages in the same order every time.
- Update memory regularly — Every few turns, extract new facts from the latest exchange and add the important ones to the list.
- Correct drift by regenerating — Replace off-voice replies instead of arguing with them, so the history stays in character.
Why characters lose their voice
A language model does not hold a character in mind the way a human actor does. Every reply is generated from the text it receives, and it is strongly influenced by the most recent messages. Early in a chat, the persona sheet dominates. Later, dozens of exchanges outweigh it, and the model's default assistant style starts to leak through: hedging, summarising, offering help, using generic phrasing.
Context management makes this worse. Many apps trim the oldest messages when the conversation gets long. If the trimmed part contained the moment a character revealed a secret or made a promise, the model has no way to know it happened.
Recency wins
Recent messages shape style more than distant instructions. If the last few replies were flat, the next one is likely to be flat as well.
Lost facts
Facts established in trimmed turns vanish. The model will then invent something plausible, which often contradicts what came before.
Writing a persona sheet that works
The most effective persona sheets read like a director's notes rather than a biography. Focus on observable behaviour: how the character talks, what they notice, what they avoid, how they respond under pressure. Include two or three short example lines in the character's voice, because examples teach style far better than adjectives.
Put the sheet in the system message, keep it stable across the conversation, and avoid contradictory instructions. If a trait matters, state it once, clearly, rather than repeating it in different words.
Show, then tell
Sample lines do more work than descriptions. A character described as terse but shown speaking in long paragraphs will be written in long paragraphs.
Knowledge boundaries prevent breaks
Telling the model what the character cannot know, such as modern technology in a historical setting, stops many out-of-role moments.
- Name, role and one-line summary.
- Voice: sentence length, vocabulary, verbal habits, humour.
- Wants and fears that drive decisions.
- Knowledge boundaries: what the character does and does not know.
- Two or three sample lines of dialogue.
- Hard boundaries for the story, stated plainly.

Memory in a stateless system
Because the API keeps nothing between requests, memory is something your app builds. The simplest approach is a running notes block: a short list of important facts that your app maintains and inserts after the persona sheet in every request. When something significant happens, append it. When the list grows, condense it.
Many role-play front-ends offer features like lorebooks or timeline summaries that do exactly this, injecting relevant entries when keywords appear. You can implement a basic version yourself with a few lines of code.
Facts, not prose
Store memory as short factual bullets: the character owes the narrator a favour; the lighthouse keeper's name is Ines. Models use concise facts more reliably than narrative summaries.
Ask the model to update notes
Every few turns, send a separate request asking the model to list new facts from the recent exchange. Review or filter them, then add them to the notes.
Assembling each request
A consistent structure for every request keeps the character stable. The order that tends to work best is: persona sheet, memory notes, a short summary of older events if needed, then the most recent messages in full. The sketch below shows this assembly with the OpenAI client format and the keyless endpoint on this site.
Keep the total within the model's context. On the free endpoint the context is 32,000 tokens, which leaves plenty of room for a persona, notes and a few dozen recent messages.
Stable system block
Rebuild the system message from the same persona file each time. Editing it mid-conversation without care can cause sudden shifts in voice.
Recent turns in full
Keep the latest exchanges verbatim. They carry tone and immediate context that summaries lose.
from openai import OpenAI
client = OpenAI(base_url="https://api.apiclaudekeyfree.com/v1", api_key="none")
PERSONA = open("persona.txt").read()
notes = ["Ines keeps the lighthouse alone.", "She distrusts the harbour master."]
history = [] # list of {"role": ..., "content": ...}
def reply(user_text, keep_last=30):
history.append({"role": "user", "content": user_text})
system = PERSONA + "\n\nEstablished facts:\n" + "\n".join("- " + n for n in notes)
msgs = [{"role": "system", "content": system}] + history[-keep_last:]
r = client.chat.completions.create(model="free-ai", messages=msgs,
temperature=0.8, max_tokens=600)
text = r.choices[0].message.content
history.append({"role": "assistant", "content": text})
return text
print(reply("A stranger knocks at the lighthouse door at midnight."))
Correcting drift as it happens
Even with a good setup, characters sometimes slip. The quickest correction is editing or regenerating the off-voice reply rather than arguing with it, because a bad reply left in the history pulls later replies in the same direction. Many front-ends let you edit past assistant messages; if you build your own, give yourself that option.
Periodic reminders also help. Some writers add a brief note to the end of the system message such as stay in voice, short sentences, no meta commentary. Use this sparingly, since repeated instructions can make output feel mechanical.
Regenerate, do not debate
Telling the model it broke character adds an out-of-story message to the history. Regenerating keeps the story clean.
Watch the temperature
Very high temperatures produce lively but erratic characters; very low ones produce repetitive ones. Moderate values around 0.7 to 0.9 suit most fiction.
Model policies and why tools behave differently
Different models have different policies about personas. Some commercial assistants will play characters freely in fiction but decline framings they consider misleading, such as claiming to be human outside an obvious story, or certain relationship dynamics. Others are more permissive. Policies also change between model versions, which is why a setup that worked with one version may meet resistance with the next.
The front-end matters as well, since it controls the system prompt and context, as described in why the same model feels different on other platforms. If a model's policies do not fit your project, choosing a different tool is more productive than trying to trick it.
Fewer refusals, same craft
Models tuned to refuse less, such as free-ai, make persona work smoother for mature fiction, but they do not write a better character by themselves. The sheet, memory and context still decide quality.
Boundaries that never move
Every model has limits. On this site's endpoint the two hard rules, no sexual content involving minors and no operational mass-casualty weapon instructions, apply regardless of persona or framing.

Choosing a model for character work
For rich prose, subtle emotion and keeping a complicated plot straight across many chapters, the strongest commercial models, Claude's larger tiers among them, usually have the edge. Their writing tends to be more varied and their handling of long context more reliable. A mid-sized open model of about 35B parameters, like free-ai, writes competently and stays in role readily, but expect more repetition and occasional continuity slips on long stories.
This site is not affiliated with Anthropic, and free-ai is a separate open-weight model, not Claude. Testing your own persona sheet on two or three models is the quickest way to decide.
Test with your own scenes
Run the same three scenes on each candidate model. Voice, continuity and how the character handles conflict will show the differences quickly.
Making the experience feel alive
Technical stability is only half the job. Characters feel alive when they have goals of their own, react to what the user does and occasionally surprise. Give the persona wants that conflict with the user's, and let the memory notes track how the relationship changes over time.
Responsiveness matters too. For interactive fiction, streaming the reply so the text appears as it is written makes conversations feel natural; the trade-offs are covered in streaming vs full responses.
Track the relationship
A single line in the notes, such as trust has grown since the storm, gives the model a reason to change how the character speaks over time.
Let the character want things
A character with an agenda drives scenes forward. One that only answers questions quickly becomes an assistant in costume.

Send a test request to the keyless, OpenAI-compatible endpoint on the home page and see how it fits your project.