--- id: EL-006 title: "The agent loop: a reference architecture for marketing automation" status: published version: v1.3 series: ams part: 1 tags: [Agents, Claude Code] published: 2026-06-02 updated: 2026-09-18 abstract: >- Marketing teams meet LLMs through a chat window and rarely leave it. This paper describes the agent loop — a bounded cycle of plan, act, evaluate and revise over typed artifacts — and how to implement it with Claude Code so a team can trust, inspect and change it. keywords: [marketing automation, LLM systems] takeaways: - Replace one large prompt with small steps that each own a typed artifact. - Put an eval gate between drafting and human review; allow one revision, then escalate. - Version schemas, rubrics and prompts in the repo so every change is reviewable. references: - 'Anthropic. “Building effective agents.” Engineering blog, 2024.' - 'Yao, S. et al. “ReAct: Synergizing Reasoning and Acting in Language Models.” ICLR, 2023.' - 'Shinn, N. et al. “Reflexion: Language Agents with Verbal Reinforcement Learning.” NeurIPS, 2023.' --- ## Introduction Most marketing teams meet large language models through a chat window. That is a fine place to start and a poor place to stay. This paper describes the [[agent-loop|agent loop]], the architecture I use to turn ad-hoc prompting into a system a team can rely on [1].[^1] The aim is not autonomy for its own sake. It is to move the repeatable work of production — briefs, first drafts, variants, reporting — onto infrastructure that is observable, testable and cheap to change. ::definition{concept="agent-loop"} ## The problem with single prompts The default pattern is one long prompt that researches, outlines, drafts, edits and enforces brand voice in a single call. It demos well and degrades quickly, for three reasons. ### Failure modes - **Drift.** Output quality wanders as inputs vary, and there is no checkpoint to catch it. - **Opacity.** When a draft is wrong, nobody can tell which part of the instruction caused it. - **Coupling.** Changing tone rules risks breaking research or structure, because everything shares one context. Reasoning-and-acting patterns address part of this by interleaving thought with tool use [2], but they do not on their own give a marketing team the seams it needs to review and improve the work.[^2] :::table{caption="Single prompts, prompt chains and agent loops compared on the properties that matter to a marketing team."} | | Single prompt | Prompt chain | Agent loop | | ----------------- | ------------- | ------------ | -------------- | | Debuggability | Low | Medium | High | | Brand consistency | Drifts | Variable | Gated by evals | | Cost to change | High | Medium | Low | | Setup time | Minutes | Hours | Days | ::: ## Architecture The loop is boring on purpose. Each step does one job, produces one [[typed-artifact|typed artifact]], and hands it forward. Figure 1 shows the six steps. :::steps{caption="The agent loop. Each box writes a typed artifact; the eval gate decides whether work advances, revises once, or escalates." highlight="04" footer="Failed evals return to 03 once, then escalate to a person."} 01 | Brief | Structured input 02 | Context | Retrieve & budget 03 | Draft | Subagent writes 04 | Eval gate | Score vs rubric 05 | Revise | One pass max 06 | Review | Human approves ::: ### Typed artifacts Every request is converted into a [[brief-schema|brief schema]] before any agent runs. The schema is small, versioned in the repo, and validated on write. Free text never crosses a step boundary. ```yaml title="briefs/launch-q4.yaml" id: launch-q4 audience: "Ops leaders at mid-market SaaS" goal: "Book demos for the new reporting module" channels: [linkedin, email, blog] voice: brand/voice.md constraints: - "No superlatives" - "Cite one customer metric" ``` ### The eval gate Between drafting and review sits an [[eval-gate|eval gate]]: a rubric-scored check that every draft must pass before a person sees it. Failed drafts get exactly one revision pass, informed by the failing criteria, then escalate [3].[^3] > The goal was never to remove the marketer. It was to delete the busywork between their idea and a publishable draft. ## Implementation with Claude Code In practice each step is a short, non-interactive Claude Code run with a narrow tool allowance. Larger jobs are split across [[subagent|subagents]] that each own one artifact. ```sh title="terminal" $ claude -p "draft 3 LinkedIn posts from briefs/launch-q4.yaml" \ --allowedTools "Read,Write" \ --output-format json > drafts/launch-q4.json $ pnpm eval drafts/launch-q4.json # brand-voice gate ``` ## Results Across the teams I have deployed this with, the most consistent change is not speed but predictability: reviewers stop rewriting drafts and start editing them. Speed follows from that.[^4] ## Limitations & open questions - **Rubric quality caps output quality.** A weak eval gate passes weak drafts with confidence. - **Setup cost is front-loaded.** Schemas and evals take days to write before the first useful draft. - **Open:** how far can escalation be reduced before review quality drops? [^1]: Part 1 of the Agentic Marketing Systems series. Part 2 covers context budgets; Part 3 covers eval gates. [^2]: “Seams” here means places where an artifact can be inspected, cached or replaced without touching the rest of the system. [^3]: One pass is deliberate. Unbounded self-revision tends to converge on bland copy that satisfies the rubric and no reader. [^4]: I report observations rather than benchmarks here; Part 3 includes a measured comparison.