How We Built LangChain’s Paid Media Agent

LangChain described how it built its Paid Media Agent, which it has open-sourced, in a post covering the architecture, context design and engineering lessons behind the system.
The agent is a long-running agent that lives in Slack. Every Monday it combines ad-platform data with lead and pipeline data from LangChain's warehouse, then posts a summary and a branded PDF for each platform explaining what changed, why, and what the team should do next. The team can tag it in a thread to ask follow-up questions about campaigns, costs or pipeline, and it can propose new keywords, targeting changes, ad copy or new search campaigns based on a playbook and encoded judgement.
LangChain said paid advertising was started in January to reach prospects not covered by its organic pipeline, with a goal of scaling to five paid channels in six months. Reported results include paid media going from 0 to 20% of marketing pipeline in six months; cost per qualified lead falling 30% from June to August while monthly spend rose about 60%; LinkedIn CPL 40% lower than in January; about $5K per month saved by bringing analysis and reporting in-house instead of using an agency; and an early reporting workflow becoming about 40x cheaper and 13x faster, with runtime dropping from 18 minutes to 85 seconds.
The agent uses LangChain Deep Agents as its harness, with a LangSmith Sandbox as an isolated microVM per run providing a 32 GB disk and a shell. Software includes pandas, DuckDB, openpyxl, WeasyPrint and Jinja2, alongside six skills and a nineteen-page wiki stored in Markdown. Baking software and the wiki into a snapshot reduced average startup time by 10 seconds, LangChain said.
Context is split into five layers: system prompt, skills, wiki, live tools (218 calls) and deterministic code. Source-of-truth rules place media activity such as spend, impressions and clicks in ad platforms and downstream outcomes such as leads, opportunities and pipeline in the warehouse. LangChain said about 10% of Google spend was missing from its warehouse because some video campaigns lack keywords, and that Meta could report a conversion but the warehouse better identified what it was.
A tool catalog exposes over 200 ad-platform tools through search, read and run tools, with campaign writes going through a separate approval-gated path; the first turn dropped to about 12,000 tokens, which LangChain said was 4x cheaper than loading every schema at the same judged quality. A webinar on the agent is scheduled for September 23 at 11am Pacific.
Based on reporting from the original publisher. Visit the source for full context and later updates.
Publisher excerpt
How LangChain built a paid media agent to analyze campaign performance, optimize ads, propose changes, and turn marketing data into action.