Pipeline Overview
EnrichedContentState object. This state carries the template configuration, style profile, dynamic parameters, research findings, draft content, edited content, formatted output, SEO metadata, and publishing context through the entire pipeline.
Agent Responsibilities
Planner
The planner receives the template, style profile, topic, and user inputs. It produces a structured content plan: content strategy, structure approach, key messages, research priorities, audience insights, and estimated sections with word counts. The planner’s research priorities become the search queries for the researcher. Its structure approach guides the writer’s section organization. The planner uses Claude Haiku for speed — planning should complete in under 5 seconds.Researcher
The researcher takes the planner’s research priorities and executes web searches via Tavily. Each priority becomes a search query. Results are deduplicated, filtered by domain preference, and structured intoResearchFindings with primary insights, statistical evidence, expert quotes, and verified source URLs.
Standard tier runs up to 3 search queries concurrently. Premium tier runs up to 5. The researcher uses asyncio.gather with a thread pool executor for parallel search execution.
All downstream agents receive the structured sources as a numbered reference list. The writer cites them using [N] markers. The formatter and publisher preserve these citations verbatim.
Call Writer
The call writer is a lightweight coordination agent that bridges the research and writing phases. It extracts planning outputs and research findings, builds comprehensive writing instructions, and stores them in the sharedwriting_context. It also sets template-specific coordination flags (e.g., require_executive_summary for business proposals, require_code_examples for technical documentation).
Writer
The writer is the primary content generation agent. It builds a multi-layered system prompt from the template configuration, style profile, banned words list, grammar requirements, temporal accuracy rules, word count directives, citation rules, behavioral directives from dynamic parameters, and style enforcement blocks. The writer uses Claude Sonnet 4 on Standard tier and Claude Opus 4 on Premium tier. It produces the initial draft, runs regex-based AI-tell removal on its own output, and appends a verified references section for research-backed content. If the editor determines the draft is under the word count target, the writer is re-invoked with an expansion prompt that aggressively targets the shortfall. Standard tier allows up to 2 expansion attempts. Premium allows up to 3.Editor
The editor validates content quality through multiple gates: word count enforcement, readability scoring (Flesch Reading Ease), AI-tell detection, and generation contract validation. It runs an LLM editing pass to improve clarity, flow, and grammar while preserving word count. If readability falls below the style profile’s policy threshold, the editor performs a single rewrite pass focused on sentence simplification. If the rewrite still doesn’t meet the threshold, the generation fails with an explicit error rather than silently degrading. On Premium tier, the editor pauses execution and presents suggestions to the user for human-in-the-loop review before the content moves to formatting. The editor’s AI-tell detection threshold is 5 — if the writer’s output still contains more than 5 AI-tell patterns after the writer’s own cleanup pass, the generation is rejected.Formatter
The formatter applies platform-specific formatting, removes any remaining AI tells via both LLM and regex passes, validates citation integrity for research content, and strips hallucinated author-year citations that the LLM may have introduced. For research papers and white papers, the formatter validates that all inline[N] citations correspond to actual sources in the verified reference list and that no fabricated author-year citations were introduced during formatting.
SEO
The SEO agent optimizes content for search engines without compromising readability. It extracts target keywords from user inputs or derives them from the topic, determines search intent (informational, commercial, transactional, navigational), and runs an LLM optimization pass with keyword density analysis and readability scoring. The SEO agent produces meta titles, meta descriptions, keyword density reports, and an overall SEO score. Content must achieve a minimum SEO score of 0.7 to proceed.Publisher
The publisher finalizes the content without modifying it. It runs quality validation (checking for placeholders, minimum word count, section structure), calculates engagement predictions, and sets the final publishing context with metadata, timestamps, and quality scores. The publisher deliberately does not run an LLM pass — the formatter’s output is treated as the final body. This prevents the publisher from accidentally summarizing or rewriting content that has already passed through the full quality pipeline.State Flow
TheEnrichedContentState accumulates data as it moves through the pipeline:
| After Agent | Key State Fields Set |
|---|---|
| Planner | planning_output, research_plan |
| Researcher | research_findings (insights, sources, evidence) |
| Call Writer | writing_context (instructions, coordination flags) |
| Writer | content, draft_content |
| Editor | edited_content, expansion_attempts, status |
| Formatter | formatted_content |
| SEO | seo_analysis, seo_optimization |
| Publisher | final_content, publishing_context |
Error Handling
Every agent follows a fail-fast pattern. If an agent cannot complete its task — missing prerequisites, API failures, quality gates not met — it raises aRuntimeError with an ENTERPRISE: prefix. The workflow halts immediately and the error propagates to the status endpoint.
No agent produces fallback content, mock data, or degraded output. If the researcher finds no sources, it raises an error. If the editor detects too many AI tells, it rejects the content. If the writer’s output is under the word count target after all expansion attempts, the generation fails with a clear message explaining the shortfall.