Step 9 — The 3-Round Generation Pipeline
Each brief runs through three LLM rounds — draft, SEO rewrite, editorial polish — orchestrated end to end against the live Messages API. Here's the architecture, the model choice, and the guardrails.
Three rounds
A web-search-grounded first draft straight from the brief. Web search is enabled only in this round (up to 10 uses) so the model can pull current facts and citations before writing.
The draft is rewritten against the competitor intel — their titles, H1s, heading outlines, keyword density, and target lengths. Emits an optimized H1 and a meta-description comment.
A final pass for voice, flow, accuracy, and NIR's safety framing. Output is publication-ready Markdown — the files in the next step.
Model & batch
The pipeline probes claude-fable-5 first and, when it is available, runs on it — falling back to claude-opus-4-8 per item if the probe is gated. Effort is set to high with adaptive thinking.
Each round runs the 15 posts against the live, streamed Messages API with bounded concurrency (4 at a time), rather than an overnight batch job. Round 2 only starts once Round 1 has fully landed, and so on.
The orchestration
Driven by content_supervisor.js; the per-round prompt builders live in lib/prompts.js. Full module map is on the methodology page.
Bugs we fixed (so we don't reintroduce them)
The first attempt surfaced several sharp edges. Each is now handled in code.
[REVIEWER NAME, CREDENTIALS] and [REVIEW DATE]. NIR must replace these with a real reviewing clinician and date before anything goes live.