The fastest way to make an AI character unreliable is to treat it as a chatbot placed inside a game. A production NPC needs controlled perception, authoritative world state, bounded memory, deterministic action APIs, latency budgets, safety policy, and a fallback when the model is slow or wrong.
The model should propose dialogue and intent. The game engine should own facts, permissions, physics, inventory, quest state, and final actions.

Figure: NVIDIA’s ACE reference flow separates game integration, retrieval and model inference, speech, and character presentation. Source: NVIDIA.
NVIDIA’s current ACE Game Agent SDK architecture combines speech recognition, a small language model, retrieval, and speech generation for on-device Unreal Engine characters. It is a useful reference implementation, but the same control principles apply to cloud models and custom engines.
Define what the model is allowed to invent
Split character output into three classes.
Expressive output
Dialogue wording, tone, emotional reaction, and low-stakes flavor can be generative. Variation is part of the value.
Proposed intent
The model may propose an action such as follow_player, ask_for_item, or warn_about_enemy. The output should use a strict schema with enumerated actions and bounded arguments.
Authoritative state
Quest completion, inventory, damage, navigation, economy, relationships, and world facts belong to deterministic game systems. The model reads a curated view of that state but does not rewrite it directly.
This separation prevents a persuasive sentence from silently becoming a game-state mutation.
Build a runtime control loop
A practical turn follows this sequence:
- Convert voice, text, or gameplay events into normalized input.
- Read current character and world state from the engine.
- Retrieve only relevant lore, memory, and rules.
- Ask the model for structured dialogue and proposed intent.
- Validate the output against policy and current state.
- Execute an allowed action through a narrow game API.
- Render animation, voice, and dialogue.
- Observe the result and update approved memory.
Do not place the entire game database in the prompt. Context should be a derived view assembled for the current decision.
Our analysis of NVIDIA ACE and its Unreal Engine plugins covers the current ASR, local language model, RAG, and text-to-speech stack.
Keep character state structured
Use explicit state instead of asking the model to remember the relationship from conversation history.
{
"character_id": "quartermaster_07",
"role": "fortress quartermaster",
"relationship": { "trust": 0.62, "fear": 0.08 },
"active_goals": ["protect_supplies", "identify_spy"],
"known_facts": ["north_gate_damaged"],
"allowed_actions": ["speak", "trade", "raise_alarm"],
"scene": { "location": "storehouse", "combat": false }
}
The engine validates and updates these fields. The model receives a readable projection and returns proposals against the allowed action set.
Version the schema. Saved games and model prompts must survive content updates without corrupting character behavior.
Use retrieval for facts, not authority
RAG works well for lore, unit descriptions, quest context, and historical events. It reduces prompt size and makes content updates easier.
Retrieval still needs controls:
- Filter by game version, location, quest state, and character knowledge.
- Prevent a character from retrieving facts it should not know.
- Include source identifiers for debugging.
- Limit retrieved text and reject malformed content.
- Separate designer rules from player-authored or modded content.
NVIDIA’s Total War: PHARAOH advisor demonstration uses retrieval to answer questions about units and strategy. That is safer than asking a general model to invent game rules, because the response can be grounded in a curated knowledge base.
Set a latency budget by interaction type
Not every character needs the same response time.
| Interaction | Target behavior | Suitable strategy |
|---|---|---|
| Combat bark | Immediate, short, repeatable | Authored or cached lines |
| Companion reaction | Sub-second to low seconds | Small local model, streaming voice |
| Optional conversation | A few seconds may be acceptable | Local or cloud model with richer context |
| Strategic advisor | Turn-based delay is tolerable | RAG plus stronger reasoning model |
| Background simulation | No direct player wait | Batched or scheduled inference |
Measure tail latency, not only averages. A companion that usually answers in one second but occasionally freezes for ten seconds will feel broken.
Design interruption and fallback. The game should be able to play a neutral authored line, cancel a request, or resume deterministic behavior without waiting for the model.
Choose local, cloud, or hybrid inference
Local inference
Advantages include lower network dependency, stronger privacy, predictable marginal cost, and the ability to run offline. Constraints include hardware variability, memory pressure, model size, installation footprint, and competition with rendering.
The local simulation game AI Society demonstrates the appeal of letting players choose models through Ollama or LM Studio. The trade-off is that developers cannot assume one fixed latency or quality level.
Cloud inference
Cloud models can provide stronger capability and simpler updates, but introduce network latency, recurring cost, service availability, moderation, and data-governance concerns.
Hybrid inference
Use local models for high-frequency reactions and cloud models for optional, high-value interactions. Cache safe reusable results and keep the deterministic fallback independent of both paths.
Bound memory growth
Raw conversation logs become expensive and inconsistent. Store selected events as structured memory with provenance, game time, confidence, and expiration.
Useful memory classes include:
- Persistent authored facts.
- Engine-confirmed relationship changes.
- Short-lived scene observations.
- Player preferences that have consent and retention rules.
- Summaries generated by a model but validated before storage.
Do not allow a model summary to overwrite authoritative state. Keep replay tools so designers can inspect why a memory was selected and how it influenced an answer.
Put policy before the action API
Validate generated output for:
- Schema and allowed action name.
- Current world preconditions.
- Character knowledge and role.
- Cooldowns, cost, and rate limits.
- Age rating and content rules.
- Multiplayer fairness and anti-cheat boundaries.
- Mod or user-generated content provenance.
The model should never call arbitrary engine functions, execute code, or create item identifiers from free text. Map approved intent to an internal command that the engine can reject safely.
Test characters as systems
A dialogue-quality review is not enough. Build automated scenarios for:
- Contradictory player statements.
- Attempts to reveal hidden quests or system instructions.
- Repeated harassment or unsafe content.
- Missing retrieval data and model timeouts.
- State changes between request and response.
- Long sessions and memory saturation.
- Low-end supported hardware.
- Multiplayer attempts to gain unauthorized advantage.
Log the state snapshot, retrieved documents, model version, structured output, policy decision, executed action, and final presentation. Designers need replayable failures rather than anecdotal bug reports.
Model the economics per active player
Estimate cost from turns, not monthly active users alone.
monthly inference cost =
active players
x AI interactions per player
x average input and output tokens
x retry multiplier
x model price
Add speech recognition, text-to-speech, retrieval, moderation, and observability. Then model peak concurrency and abuse cases.
Local inference moves part of the cost to minimum hardware requirements, engineering optimization, and support. It is not free; it changes who pays and where the constraint appears.
Ship a narrow character first
The best initial NPC has a clear role, limited knowledge, a small action vocabulary, and interactions that remain useful when the model falls back.
Start with an advisor, companion, shopkeeper, or simulation character whose actions can be validated. Avoid placing the first generative system at the center of a competitive economy or irreversible main quest.
AI-native game design works when uncertainty is an intentional part of the experience and deterministic systems protect everything that must remain true.


