When the story forgets, players stop believing
A player will forgive a branching plot that surprises them; they won’t forgive a world that can’t remember what it just established. If the detective “already searched the desk” but the narrator offers the same clue again, the player learns that choices don’t stick. If a companion is described as missing an arm in one scene and wielding a two-handed sword in the next, the tone shifts from drama to glitch. These breaks usually aren’t writing problems—they’re state problems. And the longer the session runs, the more expensive it becomes to patch by hand, because you’re fighting the model’s tendency to improvise over gaps.
Spot the failure modes: drift, contradictions, and reset loops

You can usually diagnose memory trouble by watching how the story fails under pressure. Drift is the quiet one: names slowly change, relationships soften or harden without a trigger, or an “urgent” deadline keeps sliding because the model is filling in gaps with plausible-sounding updates. Contradictions are louder: an item is both stolen and still in the player’s bag, an NPC both trusts and fears the same character, a locked door is described as open because the last output didn’t carry the lock state forward.
Reset loops are the most damaging to agency. The player keeps choosing, but the system keeps reintroducing the same obstacle, re-asking the same question, or replaying a scene with slightly different wording because nothing durable marks progress. These show up fast in playtests, but they’re costly to fix late, since you have to retrofit where state should have been recorded, checked, and enforced.
Define the state that must never be improvised
Not every detail needs to be stored, but certain facts must never be left for the model to reconstruct later. Start with the information players are most likely to test: inventory contents, promises made, which characters are still alive, what the map allows, and which gates have already been passed. When these details change without cause, players are more likely to see the inconsistency as cheating than as a creative choice. Any fact that determines the options available to a player must be recorded as part of the game state.
Descriptive details and established facts also need different treatment. The smell of a tavern may vary with the scene, but whether the bartender recognizes the player must remain consistent. NPC traits that shape their decisions, such as fear of magic, loyalty to a faction, or a missing arm, also need fixed canonical values, even when the surrounding descriptions change. Teams often underestimate the work involved in defining these rules. Establishing them early keeps prompts, tools, and existing content aligned; adding them later may require revising all three.
Short-term context vs long-term memory: pick your split

A familiar trap is trying to treat the model’s prompt like a save file. Short-term context is what the model needs to write the next beat well: the last few turns, the current scene goals, the player’s most recent action, and any immediate constraints (the guard is watching, the torch is dying). Long-term memory is what must survive scene changes and time skips: flags, inventories, relationship scores, unresolved obligations, and any “truths” the world can’t contradict. Mixing these leads to both bloat and bugs—either you keep stuffing old transcripts into the window until performance and cost spike, or you summarize so aggressively that critical gates quietly disappear.
A workable split is: keep scene-local facts in the running context, and write everything else into a compact state record that’s retrieved by need. Every retrieval and summarization step is another pipeline piece to build, test, and debug, so choose the smallest long-term set that still protects agency.
Choose a state model that matches your story’s shape
Most teams start with a flat list of flags and counters because it’s easy to read and easy to serialize: has_key=true, trust_aria=3, door_warehouse=locked. That works for linear-with-choices stories where state mostly gates scenes. It breaks down when the story is really about changing entities (companions, factions, locations) because you end up inventing ad-hoc keys (“aria_arm_missing”) and forgetting to update them everywhere. For character-driven work, an entity model is usually cleaner: each NPC gets a small record (traits, injuries, promises, relationship, last_known_location) and scenes reference that record instead of restating facts.
If your narrative shape is investigation or progression, a quest/goal graph is often the anchor: nodes represent discoveries, locks, and resolutions; edges define prerequisites. For highly improvisational play, an event log can be safer than mutable flags, because you can re-derive “what’s true” from what happened. The richer models require validation code and test fixtures, not just clever prompting.
Close the loop: extracting, validating, and updating state
State should not depend on someone remembering to update it after the model has written a response. Make state updates part of every turn instead. After each player action, identify potential changes to inventory, progression flags, relationships, injuries, and location, then record them as structured data separate from the narrative. The story should draw from that data rather than serve as the source of truth. For example, if the narration says the player drops a lantern but the inventory still lists it, the mismatch becomes visible before it causes further problems.
Validation keeps these updates consistent with the game’s rules. Check data types and ranges, such as keeping trust scores between 0 and 5; enforce mutually exclusive states, such as a door not being both locked and open; verify quest prerequisites; and apply physical rules, such as preventing an NPC with one arm from equipping a two-handed weapon. When an update fails, return a specific error and ask the model to submit a corrected patch rather than requesting another attempt without guidance. Building schemas, validators, and rollback logic takes time, and iteration may slow down until the testing framework and logs are reliable.
Ship-worthy memory: performance, privacy, and playtests
The first time you ship this, you’ll feel the pressure to “just store more.” Resist it. Every extra memory field increases token cost, retrieval time, and the chance of pulling in irrelevant baggage that steers a scene off-course. Treat memory like a budget: decide what must be fast (scene context), what must be durable (canonical state), and what can be recomputed (derived facts from an event log). If you use embeddings or external storage, measure latency on your target hardware and plan for offline or degraded modes when calls fail.
Privacy is part of coherence work, not a separate checklist. Players will type real names, locations, and personal history into roleplay prompts, and that content can leak into state if you’re not careful. Keep long-term memory strictly in-world, discard raw chat where possible, and add redaction rules before anything is stored or logged. Then playtest for failure, not fun: run long sessions, hammer edge cases, and track “state regressions” like bugs with reproduction steps and expected state diffs.