Autonomous Content Engine — Dual-Agent Architecture with Self-Healing Feedback Loops
A production-grade system where specialized AI agents collaborate to research, draft, visualize, and refine content before human sign-off.
This isn't just a "post generator." It's an orchestrated network of agents. One agent acts as the Researcher & Copywriter (grounded by Tavily), another as the Creative Director (engineering prompts for DALL-E). The system is fully stateful, storing drafts in Supabase and managing a Human-in-the-Loop approval process via email. If a draft is rejected, the swarm doesn't just stop—it self-corrects and regenerates.

The Challenge: Quality at Scale
Most automation tools produce "slop"—generic, hallucinated content. To maintain a high personal brand standard, I needed a system that could mimic a professional editorial team: a researcher who checks facts, a writer who structures arguments, and a designer who creates on-brand visuals. Doing this manually took hours. Managing it with a single prompt was impossible.
Workflow Anatomy
1. Grounded Intelligence (Tavily)
The workflow starts by ingesting a topic. It immediately queries Tavily to fetch real-time, high-quality search results, ensuring the AI has context on the latest trends and facts, not just training data.
2. Agent 1: The Strategist
This specialized agent consumes the research. It structures the post specifically for LinkedIn (hooks, bullet points, CTA) and outputs the data in a strict JSON format via a Structured Output Parser.
3. Agent 2: The Art Director
A second agent analyzes the generated copy. Its sole job is to engineer a perfect DALL-E 3 prompt that matches the tone and subject of the text, ensuring visual congruence.
4. The Gatekeeper (Human-in-the-Loop)
The draft is saved to Supabase and synced to the user via Email. The workflow pauses execution here. I can review the image, title, and copy directly from my inbox.
5. The Feedback Loop
If I click "Reject" in the email, the agents interpret this as negative feedback. They loop back, re-strategize, and generate a completely new variation of the post. If "Approve" is clicked, it autonomously publishes to LinkedIn.
Orchestration Architecture
By decoupling the content generation (Agent 1) from the visual generation (Agent 2), we avoid the "jack of all trades, master of none" problem. Each agent has a specific system prompt and personality. Supabase acts as the persistent memory layer, ensuring that even if the workflow halts, the data is never lost.
Critical Engineering Decisions
Self-Healing Workflows
Standard automations are linear. This one is cyclical. The implementation of a rejection path that triggers re-generation transforms the system from a "tool" into a "collaborator" that iterates until requirements are met.
Structured State Management
Using Structured Output Parsers (JSON) instead of free text ensures that every generated piece of content can be programmatically handled, saving cleanly to Supabase columns without regex hacking.
Generated Assets
The final output is distinguishable for its coherent structure and high-quality custom visuals—bypassing the stock photo fatigue common in automated content.

Internal Draft View (JSON Structure)

Final Published Asset