Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:AIScientists Dev WorldSeed build dm prompt

From Leeroopedia
Knowledge Sources
Domains LLM, Prompt_Engineering
Last Updated 2026-10-26 18:00 GMT

Overview

Concrete two-part prompt template system that shapes DMContext into cacheable system instructions and per-call user messages, with three prompt modes for action, consequence, and GM resolution.

Description

The build_system_prompt and build_user_message functions in `dm/prompt.py` convert structured `DMContext` into LLM messages.

Three system prompt templates:

  • DM_SYSTEM_TEMPLATE: Standard action DM — "You are the physical laws of a persistent world simulation." Enforces narrative constraints (never describe what agents think/feel), effect format documentation, holder/location sync rule.
  • CONSEQUENCE_DM_SYSTEM_TEMPLATE: Consequence DM — world reactions, no agent caused it.
  • GM_RESOLVE_SYSTEM_TEMPLATE: GM commands — "Translate the command into precise state effects."

The user message contains world state, recent events, target history, and the action/command. Agent-provided text is marked as untrusted. On validation failure, error feedback is appended as a `CORRECTION REQUIRED` section.

Usage

Import these functions to build DM prompts. Called by `LiteLLMDMProvider.judge()` during DM resolution.

Code Reference

Source Location

  • Repository: WorldSeed
  • File: src/worldseed/dm/prompt.py

Signature

def build_system_prompt(context: DMContext) -> str:
    """Build the system prompt from DMContext fields.

    Static, cacheable prefix with DM instructions, scene description,
    hint, allowed operators, and max effects.
    """

def build_user_message(context: DMContext) -> str:
    """Build the user message from DMContext fields.

    Contains world state, events, and the action being judged.
    Agent-provided text is marked as untrusted.
    """

Import

from worldseed.dm.prompt import build_system_prompt, build_user_message

I/O Contract

Inputs

Name Type Required Description
context DMContext Yes Assembled DM context

Outputs

Name Type Description
build_system_prompt() returns Cacheable system prompt |
build_user_message() returns Per-call user message |

Usage Examples

from worldseed.dm.prompt import build_system_prompt, build_user_message

system = build_system_prompt(dm_context)
user = build_user_message(dm_context)
messages = [
    {"role": "system", "content": system},
    {"role": "user", "content": user},
]

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment