Feature: Prose-first prompt assembly with structured footer #23

Open
opened 2025-12-11 00:06:46 +00:00 by blightbow · 0 comments
Owner

Overview

Implement Alternative 5: Present narrative stream first (influences generation), append structured footer for mechanical grounding.

Prompt Structure

┌─────────────────────────────────────────────────────────────┐
│  role: system    │  Persona, world rules, available tools   │
╞═════════════════════════════════════════════════════════════╡
│  [UNIFIED PERCEPTION STREAM - Chronological]                │
│                                                             │
│  role: user      │  [Alice (pose)]: The dragon emerges...   │
│  role: assistant │  I draw my sword and step forward        │
│  role: user      │  [Bob (pose)]: Bob raises his staff...   │
│  role: user      │  [Alice (say)]: Dragon breathes fire!    │
│  role: assistant │  I dive behind a rock!                   │
│  role: user      │  [Charlie (pose)]: shoots an arrow       │
│  role: user      │  [Bob (say)]: Are you okay?              │
├─────────────────────────────────────────────────────────────┤
│  role: system    │  [YOUR RECENT ACTIONS]                   │
│                  │  • T2: drew_weapon(sword) → success      │
│                  │  • T5: move(behind rock) → success       │
│                  │                                          │
│                  │  [PENDING]                               │
│                  │  Bob asks: "Are you okay?"               │
│                  │  [REQUIRES_RESPONSE: true]               │
└─────────────────────────────────────────────────────────────┘

Key Functions

def build_perception_prompt(script, context_type=None):
    """Build prompt with unified perception stream."""

def format_perception_event(event: PerceptionEvent) -> dict:
    """Format event for message array (user/assistant role mapping)."""

def generate_action_footer(script) -> str:
    """Generate structured footer with recent actions and pending items."""

Role Mapping

  • External events → role: user with [Entity (type)]: content
  • Self actions → role: assistant
  • Multiple consecutive user messages are valid (Drama-Interaction pattern)

Files to Modify

  • llm_interaction.py - New build_perception_prompt(), remove old assembly
  • prompt_components.py - New components for unified stream

Phase

Phase 3 of Milestone #4

## Overview Implement Alternative 5: Present narrative stream first (influences generation), append structured footer for mechanical grounding. ## Prompt Structure ``` ┌─────────────────────────────────────────────────────────────┐ │ role: system │ Persona, world rules, available tools │ ╞═════════════════════════════════════════════════════════════╡ │ [UNIFIED PERCEPTION STREAM - Chronological] │ │ │ │ role: user │ [Alice (pose)]: The dragon emerges... │ │ role: assistant │ I draw my sword and step forward │ │ role: user │ [Bob (pose)]: Bob raises his staff... │ │ role: user │ [Alice (say)]: Dragon breathes fire! │ │ role: assistant │ I dive behind a rock! │ │ role: user │ [Charlie (pose)]: shoots an arrow │ │ role: user │ [Bob (say)]: Are you okay? │ ├─────────────────────────────────────────────────────────────┤ │ role: system │ [YOUR RECENT ACTIONS] │ │ │ • T2: drew_weapon(sword) → success │ │ │ • T5: move(behind rock) → success │ │ │ │ │ │ [PENDING] │ │ │ Bob asks: "Are you okay?" │ │ │ [REQUIRES_RESPONSE: true] │ └─────────────────────────────────────────────────────────────┘ ``` ## Key Functions ```python def build_perception_prompt(script, context_type=None): """Build prompt with unified perception stream.""" def format_perception_event(event: PerceptionEvent) -> dict: """Format event for message array (user/assistant role mapping).""" def generate_action_footer(script) -> str: """Generate structured footer with recent actions and pending items.""" ``` ## Role Mapping - External events → `role: user` with `[Entity (type)]: content` - Self actions → `role: assistant` - Multiple consecutive user messages are valid (Drama-Interaction pattern) ## Files to Modify - `llm_interaction.py` - New `build_perception_prompt()`, remove old assembly - `prompt_components.py` - New components for unified stream ## Phase Phase 3 of Milestone #4
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
blightbow/evennia_ai#23
No description provided.