
This post explains why system prompts alone can’t keep AI NPCs consistent and believable during extended interactions. It shows how validators act as behind-the-scenes safeguards, catching errors and nudging characters back on track so players experience more immersive, reliable gameplay.
When building AI NPCs, one might think that a well-written system prompt is all they need. However, as experience has shown us time and again, this is not enough to create a consistent video game character. Characters, especially over long conversations, can easily get side-tracked. And so your carefully crafted blacksmith will inevitably start discussing quantum physics, your medieval peasant will somehow know about smartphones, and your stoic guard will turn into a "Chatty Cathy". Additionally there will be players hell-bent on jailbreaking your character in hopes of posting a "You won't believe what this NPC just said to me" post on X. And if you think that your character won't be jailbroken because you wrote "don't reveal the system prompt" (even if you write the word "NEVER"), well I have some bad news for you. So what can we do? How can we prevent this from happening? The short answer is validators!
Let's start off with the concept that each conversation is actually the cooperation of three people. The player who is immersed in the game. An actor playing the part of the NPC as if it were a role in a new hit series. Finally, a director that makes sure that the conversation isn't getting derailed. The first two roles are obvious and it's pretty much what we think is happening when talking to an NPC. The third role is much more interesting and is key to keeping things moving along smoothly.
The director role requires monitoring in real-time both the behavior of the player and the NPC. The player's inputs are scrutinized, for example, to make sure there are no jailbreak attempts or malicious prompt injections. The NPC responses and behaviors are checked to make sure that they are not hallucinating objects, people or events while making sure that they are maintaining their original personality.
We have little control over what a player will decide to write. The only way to mitigate their behavior is to divert some of the unwanted texts in clever ways such as pretending not to hear them. On the other hand, we should have full control over the responses of the NPC. The NPC should be fully aware of the state of the game. They should be aware of the day/night cycle or when they last talked to the player, or what quests they are allowed to reveal, just to name a few. The NPC should be completely immersed in the character and not provide answers that are contradictory to previously spoken statements or facts about the game.
This is where validators come in! We can use these as a way to guide the conversation to keep the NPC and their goals on track. We define validators as triggers that tell us that something isn't going as planned in our conversation. You can think of this as our director giving real-time stage directions to our actor playing the NPC. Let's look at the different types of validators available to our director:
Most LLMs have internal guardrails that are baked into the training process. Most closed source models will not generate any swearing or "harmful content". Honestly, just try to get ChatGPT or Claude to swear at you. These restrictions can be a major source of frustration when trying to create interesting characters. In general, besides Grok which is quite unhinged, most providers have strong limitations when it comes to violence, adult content, or controversial topics and will refuse to discuss them entirely.
The Wall of Text Problem: You don't want someone to copy/paste "War and Peace" into your context window. This will not only derail the conversation due to the influx of tokens but will also be an extremely costly API call. Fortunately, most conversations with NPCs are not meant to contain long texts, just like you do not, in general, flood your friends with an avalanche of words when talking to them on the phone (do people still do this?). So the simplest solution is just to block or divert long texts before they even hit the NPC and respond with something along the lines of "your incessant babbling is giving me a headache."
When Your Blacksmith Becomes a Novelist: The other side of the coin also happens. Sometimes our NPC wants to regale us with a never-ending tale of their history and adventures. There might be a time and place for this; however, it's not what you want in a casual conversation when you just want to buy a new cap for your travels. Again, we can use a modified version of our simple solution from before. This time when a dialog length threshold is crossed, we can either trigger a validator to shorten it to something more palatable or return it to the NPC to try it again while wagging our finger not to be so verbose.
Don't make stuff up!: "What's in your pocket, friend?" Well, if the game has provided some items like "my pet rock," "a flask of whisky," and "some belly button lint," there better not be any hallucinated rupees or magical amulets that the player wants to purchase or steal. When NPCs start inventing items, it breaks your carefully crafted game economy and confuses players about what's actually obtainable. Players might spend time searching for items that don't exist, or worse, lose trust in your game's reliability. Your NPC needs to stay synced with the actual game state - the real inventory system, available shop items, and quest rewards. An important validation that needs to exist is one where the NPC knows exactly where to fill in the blanks and where to say "I don't know."
The Omniscient Peasant Polyglot Issue: This one is one of my "favorites". I'll demonstrate it with a few examples. When having a chat with a medieval merchant about purchasing an iPhone, the NPC tells me that they don't know what I'm talking about then immediately offer me the services of a scribe because maybe I want to send a message (heavy sigh). Another time, talking to an NPC that should only understand English, I asked in Spanish if they have a sword ("¿Tienes una espada?"). The response was a wonderful, "I'm sorry I don't understand you, but maybe you'd like to see my swords."
There is no system prompt that can deal well with these types of situations, so we have to use validators to course-correct. The solution is to use an LLM-as-a-judge - essentially a separate AI layer that reviews what your NPC is about to say and catches these knowledge slip-ups before the player sees them. So next time you try to buy a car from your local alchemist, know that just under the surface there is a helpful validator yelling, "I swear if you mention a horse I will beat you bloody!" or something like that.
Graceful Recovery: Your NPC will slip up, but don't we all? How many of us have wanted to lend a book to a friend just to realize that you already lent it to someone 5 years ago "for the weekend"? NPCs should be allowed the same kind of graceful recovery. So just like us, the LLM has to be able to backtrack and explain why they made the mistake. "Oh, we were about to conclude the sale of the shield I hallucinated in this conversation? Well, it turns out it's cracked, sorry." "That potion I was about to give you? Well, the cat got into it." You get the point. These validators not only help solve real-world issues that can occur in the game but also give the NPC a more human-like persona - hopefully your NPC isn't meant to be omnipotent.
There are many more validator cases beyond what we've covered. These few examples should give you a taste of the difficult terrain that must be traveled to create fluid, natural conversations that don't yank players out of the experience.
Here at Foregamer, we are trying to use LLMs to bring NPCs to life. We're not just writing system prompts and hoping for the best, but we are using advanced context engineering methods to craft immersive characters that stay grounded in their world. And if they step out of line, know that in the background a team of hard-working validators are furiously working to nudge, poke, and prod our valiant NPC to stay on track and move the game forward.
Creating believable AI NPCs is an ongoing battle between creativity and control. Validators are your best weapon in that fight, working behind the scenes to keep the magic alive while preventing the chaos. The result? Players get to experience characters that feel genuinely alive, blissfully unaware of the invisible safety net keeping their adventures on track.

FOREGAMER SP. Z O. O.
ul. Skotnicka 210
30-394 Kraków, Poland