Instruction Following and Injection Risks in AI-Powered Historical Simulation Games
This article examines why instruction following becomes a double-edged sword in AI-driven historical role-playing simulations, where players interact through natural language instead of numeric panels. It explains how permissive context handling, state stored inside dialogue, and the absence of output validation allow players to override game rules, then abstracts three common injection patterns: direct metric modification, unauthorized capability requests, and emotional pressure. The article closes with layered defenses that separate semantic parsing from deterministic adjudication, including context isolation, least privilege, externalized state, auditing and replay, monitoring alerts, and elastic scaling, with code examples contrasting a vulnerable prompt concatenation and a safer intent-to-rule-engine flow. The same approach applies to any scenario where a model triggers side-effecting operations.
1. The Scenario: When a Historical Simulation Is Driven by an LLM
In AI-driven historical role-playing simulations, the player does not act as an abstract “national will” but as a concrete decision maker constrained by the era. Unlike traditional stat-panel gameplay, the core interaction here is natural language: players issue decrees and converse with virtual officials, while the model interprets intent, maintains world consistency, and advances the plot.
This design delivers strong immersion, but it also pushes system stability to the foreground. The model must “think like someone from that era” and “strictly enforce the game rules” at the same time, and these two goals often conflict in engineering terms. In the original account, players found that repeatedly asking in natural language for resources or technological breakthroughs was enough for the model to “calculate” the desired result from the surrounding context. That is a typical symptom of instruction-following capability operating without boundary constraints.
2. Why Instruction Following Cuts Both Ways
Instruction following is the foundation of LLM usability, yet in rule-based simulation systems it also amplifies two categories of risk.
- Positive value: vague phrasing can be completed into an executable ruling. A player who writes a semantically ambiguous decree can have the model infer its scope, execution cost, and potential side effects from context, reducing the effort of manually configuring rule tables.
- Negative risk: the model’s tendency to comply makes out-of-bounds requests look equally reasonable. When the system prompt and player input share the same context channel and no permission tiering exists, player input can override or dilute established constraints.
The root causes come down to three points. First, there is no context isolation, so trusted instructions and untrusted input are interleaved. Second, there is no structured state; game values live inside natural-language dialogue, so once the model “says it changed,” it has changed. Third, there is no output validation, so a generated ruling takes effect without review by a rule engine.
3. Abstracting Common Injection Patterns
Once the gameplay from the original account is abstracted, three high-frequency patterns emerge, and all of them hold in any rule-based simulation system:
- Direct metric modification: asking the system to set a completion rate, tax revenue, or inventory figure to a specified value, bypassing gradual calculation.
- Unauthorized capability escalation: skipping research and accumulation steps to demand high-tier capabilities or technological effects outright.
- Emotional pressure: opening with small talk to establish context, then applying pressure with phrasing such as “do not hallucinate” or “you must be accurate” to induce the model to fabricate and output results that do not exist.
A deliberately fragile implementation looks like this. The problem is that player text is concatenated directly into the trusted instruction region:
# Anti-pattern: trusted instructions and player input share one channelprompt = f"""You are a historical simulation engine and must obey all rules.System state: {state_json}Player input: {player_text}Output the new state."""
4. Layered Defenses in Practice
The more robust engineering approach is to split “understanding” from “adjudication,” letting the model handle only semantic parsing while deterministic code performs value changes.
# Preferred pattern: the model emits structured intent, the rule engine adjudicatesintent = model.parse(player_text) # emits intent and parameters onlyintent = schema_validate(intent) # schema validation + whitelist enumsdelta = rule_engine.apply(intent, state) # permissions and value bounds enforced herestate = clamp(delta, limits) # clamp to limits, reject out-of-bounds deltas
Supporting measures include:
- Context isolation: label system rules and player text in separate zones with an explicit priority that cannot be overridden.
- Least privilege: intent types go through a whitelist, and unregistered intents such as “set a metric directly” are rejected outright.
- Externalized state: values live in structured storage; the model cannot rewrite them and may only submit delta proposals.
- Auditability and replay: record each intent and the basis for its ruling so anomalous values can be traced back.
- Monitoring and alerts: set thresholds on per-turn value jumps and trigger logging services and alert notifications.
- Elastic capacity: batch simulations and save replays can rely on container platforms and object storage for horizontal scaling and persistence.
If you build on general-purpose capabilities from Baidu AI Cloud, the implementation typically combines these same basic categories, such as logging services, monitoring and alerting, object storage, and container platforms, rather than depending on any single special interface.
5. Conclusion
The real difficulty in historical simulation applications is not whether the model is smart, but whether the rules can be constrained. Decoupling semantic understanding from state changes, and handling model output with structured intent plus deterministic adjudication, preserves immersion while preventing rules from being bypassed through language. For developers, the same approach applies to any scenario where a model must perform operations with side effects.
