Skip to main content

Build a Content Generator

Learning Path

Level 4, Step 4.4 β€” Learning Path. Prerequisites: Supervisor & Workers.

This project uses the Supervisor-Worker pattern to create a content generation pipeline where multiple AI agents collaborate β€” one writes, another reviews, and a supervisor coordinates the process.

What You'll Build​

A content generation system where:

  • A Supervisor analyzes the request and delegates tasks
  • A Writer creates the initial content
  • A Reviewer provides feedback and suggestions
  • The team iterates until the content meets quality standards
  • A final polished version is delivered

The Architecture​

Start β†’ Supervisor β†’ Writer (if writing needed)
β†’ Reviewer (if review needed)
β†’ Final Output (if done)
↑ ↓
└── Loop back β”€β”€β”˜

Step 1: Create the Flow​

  1. Create a new Agentflow named "Content Generator"
  2. Configure the Start node:
    • Input Type: Chat Input
    • Flow State:
      • next: "" (tracks which agent goes next)
      • instruction: "" (task for the next agent)

Step 2: Add the Supervisor (LLM Node)​

Model: ChatOpenAI β†’ gpt-4o

System Message:

You are a content production supervisor managing two specialists:
- WRITER: Creates and revises content
- REVIEWER: Reviews content for quality, accuracy, and engagement

Given the conversation so far, decide who should act next.
When the content is polished and ready, respond with FINISH.
Minimize the number of rounds β€” aim for efficiency.

JSON Structured Output:

  • next: enum ["WRITER", "REVIEWER", "FINISH"]
  • instructions: string β€” specific task for the next worker
  • reasoning: string β€” why this worker was chosen

Update Flow State:

  • next β†’ {{ output.next }}
  • instruction β†’ {{ output.instructions }}

Input Message: "Based on the conversation, who should act next? Select WRITER, REVIEWER, or FINISH."

Step 3: Add Routing (Condition Node)​

Add a Condition node connected to the Supervisor:

  • Condition 0: {{ $flow.state.next }} equals WRITER
  • Condition 1: {{ $flow.state.next }} equals REVIEWER
  • Else (Condition 2): Routes to final output (FINISH)

Step 4: Add the Writer Agent​

Connected to Condition 0.

System Message:

You are an expert content writer. Create engaging, well-structured content based on the given instructions.

Your writing should be:
- Clear and easy to read
- Well-organized with headings and sections
- Engaging with a natural flow
- Accurate and well-researched
- Formatted in Markdown

Input Message: {{ $flow.state.instruction }}

Connect output β†’ Loop node β†’ back to Supervisor (max 5 loops)

Step 5: Add the Reviewer Agent​

Connected to Condition 1.

System Message:

You are a senior content editor. Review the content and provide constructive, specific feedback.

Evaluate:
- Clarity and readability
- Structure and organization
- Accuracy of information
- Engagement and tone
- Grammar and style

Provide specific suggestions for improvement, not just general comments.

Input Message: {{ $flow.state.instruction }}

Connect output β†’ Loop node β†’ back to Supervisor (max 5 loops)

Step 6: Add Final Output​

Connected to Condition 2 (Else/FINISH).

Add an Agent node with a large-context model (Gemini recommended):

Input Message:

Based on all the writing and review iterations above, produce the final polished version of the content. Include all improvements suggested by the reviewer.

Output in clean Markdown format.

Testing​

Try prompts like:

  • "Write a blog post about the benefits of remote work"
  • "Create a product description for a smart water bottle"
  • "Write an email newsletter about our new AI features"

Watch as the Supervisor delegates to the Writer, then the Reviewer, then back to the Writer for revisions, and finally produces the polished output.

Tips​

  • This pattern is token-intensive due to back-and-forth communication β€” use it for high-value content
  • Limit iterations: 2-3 rounds of write-review is usually sufficient
  • Use cheaper models for routing: The Supervisor can use gpt-4o-mini since it's just making decisions
  • Add RAG: Give the Writer access to a knowledge base for factual content