Marketing pipeline
The marketing worker is one Cloudflare Worker that takes a brief and produces a rendered carousel. It runs a seven-stage pipeline end to end inside the worker: retrieve exemplars, plan a deck, validate, render to PNGs in-worker, score every slide with vision, promote good runs to the exemplar index, return the result. No hop to the containerized cloud runtime on the hot path.
Overview
- Worker
ultron-marketing-swarm- Entry
POST /carousel- Region
- Cloudflare edge, globally distributed
- Renderer
- In-worker Satori + Resvg WASM
- Planner model
@cf/google/gemma-4-26b-a4b-itvia Workers AI- Vision model
@cf/llava-1.5-7bvia Workers AI- Embedding model
@cf/baai/bge-base-en-v1.5(768 dim)- Promote threshold
- Average slide score >= 0.85, or user starred
The marketing worker is one of the Ultron Workers that runs entirely on Cloudflare. It does not call back to the main containerized cloud runtime at any point during a render; everything from the brief to the PNG happens at the edge. That keeps latency predictable, keeps cost low, and lets the worker scale linearly with traffic.
Entry point
One handler, one route, one job: turn a brief into a carousel.
The seven-stage pipeline
Each stage is one file under src/carousel/. Stages run in sequence; failure short-circuits to a structured error.
- 01RetrieveEmbed the brief via bge-base-en-v1.5, query the
carousel-briefsVectorize index, pull the top exemplars (PNG + spec JSON) from thecarousel-engine-exemplarsR2 bucket. - 02PlanSend the brief, the exemplars, and the component index summary to Gemma. The model returns a
CarouselSpec: a list of freeform slides with positioned elements. - 03ValidateWalk the spec. Reject any slide that is not freeform, anything over the per-slide character budget, anything missing a required backdrop or icon.
- 04RenderCompile the spec to JSX with the SlideRenderer dispatcher, run Satori to produce SVG per slide, rasterise to PNG with resvg-wasm. All in the worker.
- 05QASend each slide PNG to LLaVA with a structured rubric, parse a per-slide score and a short critique.
- 06PromoteIf the average score is at or above the threshold, upsert the run into D1, push the brief embedding into Vectorize, and copy the PNGs into the exemplars bucket.
- 07RespondReturn the run id, the score, and the signed URLs for every slide.
Models in the loop
Three Workers AI models do the heavy lifting.
| Stage | Model | Binding |
|---|---|---|
| Retrieve | bge-base-en-v1.5 (text embedding) | env.AI.run("@cf/baai/bge-base-en-v1.5", ...) |
| Plan | @cf/google/gemma-4-26b-a4b-it | env.AI.run("@cf/google/gemma-4-26b-a4b-it", ...) |
| QA | @cf/llava-1.5-7b | env.AI.run("@cf/llava-1.5-7b", { image, prompt }) |
Worker bindings
The wrangler.toml declares every binding the pipeline reads or writes.
Run tracing
Every run leaves a row in D1 with timings and outcomes.
The worker writes a render_runs row with the brief, the spec, the per-stage timing, and the final score on every run. Promoted runs also land in carousels with the slide URLs and the QA notes. Reading either table is the fastest way to understand why a particular run did what it did. See Storage for the full schema.
File map
Glossary
- Brief
- The plain-language input to the pipeline. One sentence to a short paragraph describing what the carousel should communicate.
- Spec
- The structured CarouselSpec produced by the planner and consumed by the renderer.
- Exemplar
- A past run that scored above the promote threshold. Stored in R2 and indexed in Vectorize for retrieval.
- Promote
- The act of writing a successful run into the canonical D1 row and pushing its brief embedding into Vectorize so future briefs can retrieve it.
- Star
- User-driven promotion. Forces a run to be added to the exemplar index even if its score was below the auto-promote threshold.
- Renderer
- The in-worker Satori plus Resvg WASM pipeline that turns the spec into PNGs without leaving the edge.