Skip to content

refactor: Unified prompt composition, structured log analysis, parallel validator tracing, and intent hydration fixes#34

Merged
sortedcord merged 17 commits into
masterfrom
fix/handoff
Jul 19, 2026
Merged

refactor: Unified prompt composition, structured log analysis, parallel validator tracing, and intent hydration fixes#34
sortedcord merged 17 commits into
masterfrom
fix/handoff

Conversation

@sortedcord

Copy link
Copy Markdown
Owner

This pull request compiles all architectural improvements, refactoring, and fixes implemented in this branch to unify prompt generation, structure logs, add parallel validator checks, and fix entity/dialogue hydration.

1. Unified Prompt Composition and Generic Interfaces

  • Centralized LLM prompt types by relocating PromptComponent and PromptBreakdown from @omnia/voice to @omnia/llm (packages/llm/src/llm.ts).

  • Standardized prompt construction by implementing the generic IPromptBuilder<TArgs> interface across all prompt builders:

    • ActorPromptBuilder (packages/actor/src/actor-prompt-builder.ts) implements IPromptBuilder<[WorldState, Entity]>.
    • IntentDecoderPromptBuilder (packages/intent/src/intent-prompt-builder.ts) implements IPromptBuilder<[WorldState, string, string, Intent[]]>.
    • HandoffPromptBuilder (packages/memory/src/handoff-prompt-builder.ts) implements IPromptBuilder<[Entity, BufferEntry[], Date]>.
    • LLMValidatorPromptBuilder (packages/architect/src/llm-validator-prompt-builder.ts) implements IPromptBuilder<[WorldState, Intent]>.
  • Decoupled prompt composition from LLM execution, providing a consistent and reusable prompt-building architecture across the codebase.

2. Structured Simulation Logging and Reusable Prompt Visualization

  • Replaced fragile regex-based parsing of provider lastCall output in turn-executor.ts and alias-handoff.ts.

  • Introduced structured prompt logging by storing prompt breakdowns as token-labeled JSON component arrays.

  • Added a reusable PromptAnalyzer component (apps/gui/src/components/play/PromptAnalyzer.tsx) that:

    • Renders color-coded prompt sections.
    • Displays System, World, Memory Context, and Candidate Buffers independently.
    • Preserves backward compatibility through legacy string-splitting fallbacks.
  • Refactored both PromptModal and HandoffModal to delegate prompt rendering and visualization responsibilities to PromptAnalyzer, significantly simplifying modal logic.

3. Parallel Intent Validation Logging and Visualization

  • Separated raw intent decoding from the validation pipeline.

  • Preserved decoded intents in LogEntry.decodedIntents, allowing the interface to display model output before validation occurs.

  • Redesigned PromptSwitcher to visually represent the parallel validation architecture:

    • Primary execution flow remains horizontal.
    • Individual validator executions are stacked vertically beneath the main pipeline.
  • Added dynamic validation tabs for each LLM validation execution.

  • Each validation view displays:

    • Prompt token breakdown
    • Model response
    • Validation status
  • Added a dedicated "Bypassed LLM Validation" view to clearly explain scenarios where validation is intentionally skipped, such as dialogue and thought intents.

4. Grammar Preprocessing and Dialogue Preservation

  • Introduced the expandContractions preprocessor (packages/voice/src/contractions.ts).
  • Expands narrator contractions before intent decoding while intentionally ignoring quoted dialogue.
  • Prevents accidental modification of spoken dialogue while improving parser consistency for narration.

5. Hydration Alias Fallback Improvements

  • Updated IntentTag in InteractView.tsx to receive simulation entities during rendering.

  • Improved alias hydration by:

    • Pre-populating alias mappings with every entity's default name.
    • Overlaying player-specific aliases afterward.
  • Ensures unmapped entities resolve to their canonical names (for example, "Bob" or "Bill") instead of the generic placeholder "an unfamiliar figure."

@sortedcord
sortedcord merged commit a8b2d42 into master Jul 19, 2026
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants