I run a text-based d20 RPG where an AI Game Master narrates the adventure, one chapter at a time. The classic wall: ~6,000 tokens of context, and the GM physically could not remember what happened at turn 20 when it hit turn 21.
I fought it with summaries — which then got summarized until the oldest ones were a summary of a summary of a summary, and anything specific from a dozen turns back was simply gone. Not fuzzy. Gone.
So I rebuilt the memory system on one decision: fold, never delete. When turns leave the visible context, their original text moves verbatim into a transcript instead of being destroyed. Then four layers on top:
Lorebook — a structured canon (NPCs, items, places, factions) plus a list of open threads, refreshed after every turn and re-read every turn. Crucially it's owned by the player, not the model: it's an editable panel, so the canon stays honest.
Archive summaries — folded chunks become structured EVENTS / FACTS / THREADS summaries with tags, injected into every prompt. The past gets compressed, never evicted.
Scene anchor — who's present, where, when, what's at stake. One fixed point to stop the "wait, where are we?" drift.
Tagged retrieval — a cheap matcher pulls verbatim chunks of the original text back into the prompt when the current scene matches. Actual scenes, not retellings.
Honest about the edges: retrieval is keyword matching, not understanding (turn 90 says "the key from the tomb," turn 45 called it "the glimmering key" — recall can miss, though the lorebook usually catches it), recall is capped in characters, and the oldest canon still gets evicted past the hard caps. Net result: roughly 10× the memory horizon on the same 6k context, ~70–80% of what a perfect system could do.
The practical test: turn 60 referencing turn 3 now works. That used to be impossible, not merely unlikely.
Full writeup: Perchance for Humans
(Built entirely by prompting — I'm not a coder; the AI assistant wrote all of this for me.)
6 Comments
Edgecrusher840@lemmy.world · 3 pts · 7d
"I fought it with summaries — which then got..." " ...was simply gone. Not fuzzy. Gone." "Crucially it’s owned by the player, not the model: it’s an editable panel, so the canon stays honest." "The past gets compressed, never evicted." "Actual scenes, not retellings." "That used to be impossible, not merely unlikely."
You ARE a bot.
Daveed@lemmy.zip · 1 pts · 7d
Always easy to spot AI's writing! But, it works for me.
Garth01@lemmy.world · 2 pts · 7d
You do realize AI code isn't 100% reliable, right? AI code still needs to be debugged by humans. I know you have said you have some experience with coding, but you need to realize that AI code isn't perfect. You will have to make your own adjustments if required.
P.S. This is what Gemini wanted me to say instead: "This is a brilliant breakdown of prompt-based architecture! It's impressive how much you achieved without a formal coding background. Your "fold, never delete" approach to managing the ~6k context window is a really clever workaround for the summary-of-a-summary degradation loop. Thanks for sharing the writeup link!"
Daveed@lemmy.zip · 2 pts · 7d
Yeah, but I have a self-diagnostic tool that catches a lot of the errors in code, and I do a lot of prompt iteration to tweak things. I'm not saying AI can write code better than humans, just a lot faster, and effectively enough for my purposes. I have over twenty gens on Perchance, all AI written with my prompting, and some of them are doing quite well. I watch all the guestbooks, and address bugs people find as soon as they come up--by giving the feedback to the AI in the relevant gen!
And hey, I welcome any audit of my gens' code from anyone who can find and point out the errors, because making them better for the user is what it's all about. Thanks!
Windydove@lemmy.world · 2 pts · 3d
You can integrate a Mempalace option into your generator. It solved my memory problems. https://perchance.org/tales-to-be-told I vibecoded mempalace in with Gemini and used the Perchance AI Helper. Whether a generator is coded or vibecoded Perchance memory in general does not work well, but Mempalace with an Ngrok tunnel allows me to record info from every turn. Here is my bridge.py if you take that route https://files.catbox.moe/w9t9q6.py Basically Mempalace stores info on your local machine, memories and lore, it is better than solely relying on the LLM.
Windydove@lemmy.world · 1 pts · 3d
Memory on Perchance leaves a lot to be desired. Whether a generator is coded or vibecoded does not fix the problem. I always vibecode mempalace into my generators like this one https://perchance.org/tales-to-be-told Mempalace makes a record of what happens on each turn that I take. I did trial and error testing but it was vibecoded every time it was adjusted. Mempalace integration is the best option to have consistent memory and that can be coded or vibecoded into any Perchance generator. My bridge.py is specialized for that generator https://files.catbox.moe/w9t9q6.py Mempalace is not only good for memory but also serves up lore better than lorebooks.
When I suggested to another Gen creator that they add Mempalace integration, they said not many people would use it. Which is weird because it solves most of the complaints users consistently have about memory by storing info on one's own device. Many users whether they code or vibecode are not taking advantage of Mempalace as an option and are still lamenting the bad memory of LLMs to this day. Mempalace is not perfect but it is a massive help. Ngrok accounts can be freely made to establish a tunnel.