System Design 8 min read • Published October 2026

Inside the MythMaker Dual-Pass Engine: Decoupling Prose from State

Why single-pass JSON generation degrades writing quality, and how a decoupled creative/analytical pipeline unlocks frontier model storytelling.

When developers first connect an LLM to a database, their initial instinct is simple: ask the model to return both the story text and the database updates in a single JSON payload. It looks clean, requires only one API call, and seems cost-efficient.

In practice, single-pass JSON story generation is a disastrous engineering bottleneck.

1. The Cognitive Flaw: Attention Dispersion

Transformer models rely on self-attention mechanisms to balance sentence rhythm, literary subtext, and vocabulary. When you force a model into JSON mode (e.g., {"story_markdown": "...", "state_diff": {...}}), the neural network must simultaneously calculate:

  • Emotional resonance and dialogue pacing.
  • Syntax token boundaries, quotes, and JSON string escaping.
  • Structural state diff tracking.

This causes attention dispersion. To avoid syntax failures and token truncation, frontier models like DeepSeek-V3, GPT-4o, and Claude instinctively compress their prose into sterile narrative summaries. Scenes that deserve vivid sensory dramatization are reduced to bullet-point-like prose.

2. The Solution: Decoupled Dual-Pass Architecture

MythMaker completely decouples the writing process into two specialized roles:

Pass A: The Creative Director / Literary Novelist

Pass A receives the cached Master Bible prefix and the chapter's DOC Beat Contract. It outputs pure Markdown prose with zero JSON formatting. The model can write 1,500 to 2,000 words with full dialogue depth, sensory immersion, and natural tension.

Pass B: The Objective World Observer

Immediately after Pass A finishes, the generated markdown is forwarded to Pass B at a low temperature (0.1). Pass B acts strictly as an analytical auditor, extracting newly introduced entities, locations, character health/emotional changes, and immutable historical events into clean JSON.

3. DeepSeek-V3 Prefix Caching Economics

Because our default engine is centered around DeepSeek-V3, Dual-Pass is not only better—it is astonishingly cheap. DeepSeek features native prefix context caching.

By keeping the Master Bible byte-identical at the beginning of the prompt, Pass A achieves a 75% KV cache hit rate. Writing an entire 10-chapter novelette (~20,000 words of rich literary fiction) costs approximately $0.02 to $0.05 in total API tokens.

Dual-Pass is also completely model-agnostic: whether using DeepSeek-V3 today or Claude 3.5 Sonnet / Gemini Pro tomorrow, decoupling creative prose from analytical state extraction guarantees maximum quality.

MythMaker AI Engineering Team
Architecting narrative state machines and multi-chapter literary engines for EmeraldSoft.
View Research Methodology