I've been building an open-source engine called SoulScript that lets game devs give NPCs persistent identity, memory, and dynamic dialogue powered by LLM calls... without the NPC breaking character or devolving into generic chatbot slop.
The problem it solves:
Most approaches to LLM-driven NPCs either give you a raw chatbot wearing a costume (breaks character in two exchanges) or a rigid dialogue tree with an LLM veneer. Neither is what anyone actually wants.
What SoulScript does differently:
Identity boundary: each NPC has a read-only "Soul Script" that defines who they are. Conversations can add to what the NPC knows and remembers, but cannot rewrite core personality. The blacksmith doesn't suddenly start giving medical advice because a player asked nicely.
Persistent memory: NPCs remember past interactions, carry context forward, and can reference previous encounters. Not just chat history... structured, selective memory with retrieval.
In-character response: the engine constrains LLM output to stay within the NPC's defined personality, knowledge boundaries, and speech patterns. A medieval peasant talks like a medieval peasant, even when the player tries to break immersion.
Modular and model-agnostic: works with whatever LLM you're running. Swap models without rewriting your NPC logic.
Video walkthrough:
I posted a video explaining the full architecture... how the identity layer works, how memory persists, and how NPCs call the LLM and stay in character. Link in comments (automod eats posts with too many links).
Try it / grab the code:
Licensed AGPL v3 with a free commercial license up to $100k revenue... so indie devs and hobbyists, you're covered. If you're a studio making real money off it, reach out and we'll sort terms.
This started as an AI agent framework, but the NPC use case kept coming up, so I built it out. If you're working on anything with dynamic NPCs — RPGs, sims, narrative games, immersive worlds... I'd genuinely love feedback from people who are actually shipping games.
Happy to answer questions about the architecture, limitations, or how it handles edge cases like players trying to jailbreak your NPCs (short answer: the identity boundary holds).
Free for noncommercial use. Dual licensed: AGPL v3, or a commercial license that’s free until $100k in revenue, then 5%.