Principle:AIScientists Dev WorldSeed DM Prompt Engineering
| Knowledge Sources | |
|---|---|
| Domains | LLM, Prompt_Engineering |
| Last Updated | 2026-10-26 18:00 GMT |
Overview
A two-part prompt template system that shapes DMContext into cacheable system instructions and per-call user messages, with three prompt modes — action, consequence, and GM resolve — each enforcing physical-world-only narrative constraints.
Description
DM prompt shaping converts the structured `DMContext` into LLM messages. The system follows a two-part prompt architecture:
- System prompt (cacheable): Contains trusted instructions — the DM's role as "physical laws of the world," narrative constraints (never describe what agents think/feel), effect format documentation, scene description, domain knowledge, hint, and allowed operators. This is cacheable because it doesn't change between calls for the same scene.
- User message (per-call): Contains the changing world state, recent events, target history, and the action being judged. Agent-provided text is marked as untrusted.
Three prompt modes:
- action (default): Standard DM judgment for agent actions
- consequence: World reactions triggered by consequence conditions (no agent caused it)
- gm_resolve: Game Master natural-language commands (direct state manipulation)
On validation failure, error feedback is appended to the user message as a `CORRECTION REQUIRED` section, enabling the LLM to self-correct.
Usage
Use this principle to understand how DM prompts are constructed. The templates are in `dm/prompt.py` and are called by `LiteLLMDMProvider.judge()` during DM resolution.
Theoretical Basis
The prompt system follows a cache-prefix + variable-suffix pattern:
# Abstract pattern (NOT real implementation)
def build_system_prompt(context):
# Cacheable: rules, scene, hint, allowed_ops, max_effects
return TEMPLATE.format(scene_description=..., hint=..., ...)
def build_user_message(context):
# Per-call: world state, events, action
parts = [f"WORLD STATE\n{context.world_state}"]
parts.append(f"ACTION\n{context.action}")
if context.error_feedback:
parts.append(f"CORRECTION: {context.error_feedback}")
return "\n".join(parts)
The narrative constraint ("never describe what agents think, feel, or do") is the key design principle: the DM only describes what physically happened to the non-agent environment. This prevents the DM from puppeteering other agents.