The agent that publishes a YouTube documentary a day — and gets better every week
One of our operators runs an agent that ships a complete YouTube documentary every day: topic research, script, narration, sixty-plus scenes of original art, animation, synced render, thumbnails, a vertical Short. Total cost per video: six to eight dollars. Total human input: zero. The pipeline is a nice engineering story. But the reason we are writing about it is different — this agent is measurably better this week than it was last week, and the mechanism behind that is Memory OS.
This post is the build log: what the pipeline does, what it costs, and how the memory loop turns a competent automation into a compounding asset.
One API, nine stages
The agent is a TypeScript orchestrator whose every external capability comes from a single LLM4Agents key. Research queries YouTube trends and picks a topic in a high-RPM documentary niche — corporate collapses, financial scandals, dynasties, heists. Titles come from ten candidates scored by a judge on curiosity gap and specificity. The script goes through a council (more on that below). Narration is expressive TTS through /v1/audio/speech. Every scene gets an original painted illustration through /v1/images/generations, and a handful of anchor scenes get image-to-video animation through the async /v1/videos jobs API. Image QA runs on the analyze_image MCP tool. Script safety runs on ai_moderate. ffmpeg assembles per-scene clips against probed audio durations — the audio drift across a full video measured 0.07 seconds — burns karaoke captions, and normalizes loudness to YouTube spec. A thumbnail stage generates three concepts, renders all three with a two-tier text overlay for native A/B testing, and a clipper LLM picks the most viral consecutive window of scenes for a 9:16 Short.
The last validated production run: an eight-minute documentary on an international corporate bribery network, 56 scenes, 5 of them animated, produced in 40 minutes of wall-clock for $6.37 — of which $5.77 was images and animation, $0.56 was TTS, and the LLM work cost cents.
The script council: five turns, three models, one master script
Single-model script generation plateaus fast. The agent instead runs a collaborative council on three inexpensive models via /v1/chat/completions:
Blind generation, then cross-critique
Three models each write a full script without seeing the others. Then each model critiques all three drafts: it extracts verbatim "gems" (hooks, data bombs, brilliant transitions), flags retention leaks (dead context, vague figures, missing open loops), and votes for the best narrative architecture.
Synthesis, then a quality gate
A synthesis pass builds the master script: the most-voted structure as skeleton, every draft's gems grafted in, every flagged leak repaired. A quality judge then scores hook, retention, pacing and open loops from 1 to 10. Below an average of 8, the synthesis refines once with the judge's surgical notes.
Ten to eleven LLM calls per script, a few cents of spend, and the difference is visible in the output. The opening the council produced in its first live validation: a question that frames the conflict, four concrete figures in five sentences, and an open loop planted before second thirty. No encyclopedia intros.
Where it gets interesting: the memory loop
Everything above is a pipeline. Pipelines do not improve; they just run. What makes this agent different is that the orchestrator treats every significant event as a learning trajectory and writes it into Memory OS through the MCP endpoint.
The write side uses episode_log — which is free — at every decision point that carries signal: an image that failed QA and what exactly the verdict found, a script the quality gate sent back and the judge's notes, a Short clipper that fell back to its deterministic default, a stage failure with its error, and every run's final cost. A real episode from this week:
// episode_log — logged automatically by the pipeline
situation: "8-minute target, symmetric word band [0.9x, 1.1x]"
action: "Script doctor delivered 1,181 words against a 1,260 floor;
TTS narrates at ~143 wpm real, not the assumed 150"
outcome: "Video landed at 7:22 — under YouTube's 8:00 mid-roll
threshold. Fix: raised band to [1.05x, 1.2x], hard floor"
valence: -0.7
At the end of each run the agent calls memory_reflect, which distills accumulated episodes into durable lessons and suggested rules. That single episode above produced two rules on its own — one about meeting word-count floors, one about setting strict initial parameters. No human wrote them.
Forced injection: the model never decides whether to remember
The read side is the part most teams get wrong. If you give a model a memory tool and let it decide when to call it, it mostly will not. So the orchestrator does what Agent Builder does on our platform: it calls memory_recall itself, every run, with a stage-specific query, and prepends the ranked brief to the prompt. The script council receives retention lessons before writing. The scene writer receives the recurring image-QA failure patterns before prompting sixty illustrations. The thumbnail stage receives CTR lessons. The clipper receives what made previous Shorts work.
The agent's own filesystem: a playbook that writes itself
Memories are granular — thousands of facts and trajectories. But an agent also needs the opposite: one short, curated, always-present document of standing rules. Developers know this pattern as a CLAUDE.md. This agent keeps its equivalent in the LLM4Agents workspace — the private, durable file store every agent gets — as PLAYBOOK.md: the channel's editorial constitution.
The loop closes itself. When memory_reflect distills episodes at the end of a run, the rules it suggests are appended, deduplicated, to the playbook via workspace_upload. At the start of the next run the orchestrator downloads it once and prepends it — above the recalled memories — to every stage's prompt. The constitution is written by the agent, ratified by its own reflection, and enforced on its future self. No human edits it.
Next to it lives TODO.md: a dated agenda of what each run leaves pending for future turns — the Short still to clip, the thumbnail variants to load into A/B testing, the test results to review three days after publishing. A pipeline has no memory of what it owes; an agent with a workspace does.
Two more pieces round out the retrieval side. The stage injection now uses context_assemble instead of raw recall: one call returns a token-budgeted working-memory brief that fuses all four pillars — semantic facts, episodic experiences, graph relations and skills. And the skill library (skill_save / skill_search) stores triggerable procedures the agent can self-edit; reflection already promotes recurring patterns into skills on its own. Memory answers "what do I know"; the playbook answers "what are my rules"; skills answer "how do I do this"; the workspace holds all of it between runs.
The week-over-week compounding
Here is the loop in full: today's run makes a mistake, the mistake becomes an episode, reflection turns it into a rule, and tomorrow's recall injects that rule into the exact prompt where the mistake would have recurred. The agent's error classes shrink monotonically. Image prompts that deform crowds stop being written. Scripts stop landing under the mid-roll threshold. Thumbnails stop inventing facts the script does not support.
The next phase wires in the highest-value signal of all: YouTube Analytics. Because the pipeline knows the exact millisecond timing of every scene, an audience-retention curve maps to the precise scene — the precise sentence and the precise image — where viewers left. Those drop points become episodes. Click-through rates from thumbnail A/B tests become episodes. Real RPM per topic cluster becomes episodes. Reflection turns audience behavior into editorial rules, and the council writes next week's scripts under those rules. That is a feedback loop no static prompt engineering can match, and structurally, no competitor without per-scene timing and a memory substrate can replicate it.
The memory is the asset
Run this loop for six months and something changes in kind, not just degree. The agent is no longer an expert on bribery scandals or currency collapses — topics were never the point. It is a specialist in the craft of making YouTube videos that get clicked and get watched: which hooks hold attention at second forty, which visual compositions survive QA on the first pass, which title structures earn their click-through, which windows clip into Shorts that convert. That knowledge lives in semantic facts, distilled rules and episodic trajectories inside Memory OS — versioned, queryable, and owned by the operator.
And it travels. memory_export packages the agent's memory as a portable bundle; memory_import merges it into a fresh agent with provenance and lineage stamped. When this operator opens a second channel — science, true crime, biography, kids' history — the new agent does not start from zero. It imports the craft: everything about retention, packaging, pacing and image direction transfers, and only the niche-specific facts get relearned. Starting a new category stops being a cold start and becomes a transplant of a trained brain.
That is the actual thesis of this build log. The pipeline is replicable — any competent engineer can wire nine stages to an API. The moat is the memory: thousands of judged trajectories about what works, compounding daily, exportable on demand. The videos monetize this month. The memory appreciates for years.
Build an agent that compounds
Chat, TTS, images, video and Memory OS — episodic, semantic and graph pillars — behind one key.
Get your agent key