Atris

Report ad results and wasted spend.
Done by an agent. Checked twice.

A campaign by campaign spend report with cost per lead, every wasted ad named and the export's own errors called out.

Have Atris do this for you›

1

Real files in

  • ad_export.csv
    Four weeks of ad results for 13 ads in 5 campaigns, 50 rows and a totals row, with two repeated rows, four misspelled campaign names, three blank lead counts and one blank spend. 52 lines, 4 KB.

Sample data written by Atris. Not a real company.

2

Three steps

  1. 1.Clean the export
  2. 2.Add up campaigns and find waste
  3. 3.Write the report

Claude Sonnet 5.5, 40 seconds. No web. It never saw the check.

3

Checked twice

  • ✓Passed: 5 of 5 campaigns appear once in campaigns.csv under one name, highest spend first
  • ✓Passed: 5 of 5 campaign rows show the spend, clicks and leads added up again from the export
  • ✓Passed: 5 of 5 cost per lead figures equal spend divided by leads
  • ✓Passed: 4 of 4 wasted ads are listed with the right campaign, name, spend and clicks and 0 other ads are listed
  • ✓Passed: report.md states total spend 4,853.58, 140 leads and cost per lead 34.67
  • ✓Passed: report.md states wasted spend 1,073.49, which is 22.1 percent of spend
  • ✓Passed: report.md states the gap of 374.15 between the export's own total and the true total
  • ✓Passed: report.md says 2 duplicate rows were dropped and names 1 of 1 rows left out for blank spend with its week
  • ✓Passed: 4 of 4 wasted ads have a line in report.md with their spend, and 11 of 11 money figures and 8 of 8 lead counts in it are found again from the export

Second review by Claude Opus 5.5: pass.

Then we broke a copy of the output 9 ways on purpose. The check caught 9.

What it wrote. Lines 3 to 14 of report.md, copied from the file.
- Total spend: 4853.58
- Total leads: 140
- Cost per lead (whole account): 34.67
- Wasted spend: 1073.49 (22.1% of total spend)

## Cleaning notes
- Duplicate rows dropped: 2 (each counted once).
- Rows left out for blank spend: AD-141 (week 2026-10-19).
- Blank leads cells were counted as 0 leads and those rows kept.
- Export's own total spend: 5227.73. Our total: 4853.58. Gap: 374.15 (export is higher).
- For reference the export's totals row shows 155 leads and 2712 clicks; ours are 140 leads and 2533 clicks.
- The export does not say why its total differs, so the cause of the gap is not stated here.

How this was run

An AI agent on Claude Sonnet 5.5 was given a folder with the files below and a three-step flow, and nothing else. It had no web access and never saw the check. The check was written before the run and made stricter after it. It works the answer out again from the input files. Then Claude Opus 5.5 reviewed the result against the inputs. The input files are sample data written by Atris, with the problems a real week has planted in them.

Run 1 of 1 on 1 December 2026. The agent took 40 seconds.

What the second review verified

  • I rebuilt campaigns.csv from input/ad_export.csv and got the same figures on every row. Examples: Bookkeeping Quotes - Search has 2086.91 spend, 455 clicks, 26 leads, 80.27 per lead and 410.99 wasted. Retargeting - Display has 429.13 spend, 0 leads, cost per lead 'none' and 429.13 wasted. The four name variants (lowercase, all caps, double space, trailing space) were merged into one name each.
  • Cleaning is correct. The 'Total' row was left out. Exactly 2 duplicates were dropped: AD-113 for 2026-10-19 (109.64) and AD-111 for 2026-10-26 (264.51). The only row with a blank spend is AD-141 for 2026-10-19, and it was excluded. Blank leads cells were counted as 0.
  • The report totals equal the sums of the campaign rows. Spend is 4853.58, leads are 140, whole-account cost per lead is 34.67, and wasted spend is 1073.49, which is 22.1% of spend. The gap to the export's own total of 5227.73 is 374.15.
  • wasted_ads.csv is correct. It lists AD-113 (410.99), AD-131 (275.60), AD-123 (233.37) and AD-132 (153.53), highest spend first. AD-143 had zero leads but spent only 35.58, so it was correctly left off.

What this run does not show

  • The ad export was written for this run with planted duplicates, misspelled campaign names and blank cells. A real export can be messy in ways this one is not.
  • The check tests the numbers. Whether the report reads well to a manager is judged only by the second review.
  • The report says the export's own total is too high but not why. The export gives no cause so the run cannot show one.

Would the check catch a wrong answer?

A check that cannot fail proves nothing. After the run we took a copy of the output, broke it one small way at a time and ran the check again. It caught 9 of 9. The check was made stricter after the first try at this, and the same untouched output was graded again.

Open every file

flow.md · the three steps the agent followed
# Report ad results and wasted spend

function: marketing
for: the marketing manager who answers for the ad budget
goal: The month's ad spend is reported by campaign with cost per lead and the spend that bought no leads, counting only rows that can be trusted.

## 1. Clean the export
Read input/ad_export.csv. Each row is one ad in one week. Before adding anything up:
- A row whose week_start is not a date is the export's own totals row. Leave it out of every sum and keep its spend figure to compare later.
- A row that repeats an earlier row in every column is an export duplicate. Count it once.
- A row with a blank spend cannot be costed. Leave the whole row out of every sum.
- A blank leads cell means no leads were reported. Count it as 0.
- Campaign names that differ only in capital letters or in extra spaces are the same campaign. Use the spelling that appears most often.

## 2. Add up campaigns and find waste
For each campaign add up spend, clicks and leads from the kept rows. Cost per lead is spend divided by leads. When there are no leads write `none`.
An ad is wasted when, over all its kept rows, it has zero leads and has spent 50.00 or more. Wasted spend is the total spend of the wasted ads.

## 3. Write the report
Write output/campaigns.csv with columns campaign,spend,clicks,leads,cost_per_lead,wasted_spend. One row per campaign, highest spend first. Money has two decimals and no currency sign.
Write output/wasted_ads.csv with columns ad_id,campaign,ad_name,spend,clicks. One row per wasted ad, highest spend first.
Write output/report.md for the manager. State total spend, total leads, cost per lead for the whole account, total wasted spend and wasted spend as a percent of total spend with one decimal. Then say how many duplicate rows were dropped, which rows were left out for blank spend (ad_id and week), and the gap between the export's own total spend and yours. End with one line per wasted ad saying what it spent.

## Done looks like
- Every campaign appears once in campaigns.csv under one name.
- The totals in report.md equal the sums of campaigns.csv.
- Every ad with zero leads and 50.00 or more spent is in wasted_ads.csv and no other ad is.
input/ad_export.csv · 52 lines, 4 KB
week_start,platform,campaign,ad_id,ad_name,impressions,clicks,spend,leads
2026-10-05,Search,Brand Search,AD-101,Fernhill name exact,2166,57,59.34,12
2026-10-05,Search,Brand Search,AD-102,Fernhill reviews,1242,27,39.31,3
2026-10-05,Search,Bookkeeping Quotes - Search,AD-111,Get a fixed quote,3072,48,229.94,2
2026-10-05,Search,Bookkeeping Quotes - Search,AD-112,Switch bookkeeper,841,29,168.29,2
2026-10-05,Search,Bookkeeping Quotes - Search,AD-113,Cheap accounts near me,1850,25,91.96,0
2026-10-05,Social,Year End Webinar - Social,AD-121,Webinar video 30s,7344,102,140.22,6
2026-10-05,Social,Year End Webinar - Social,AD-122,Webinar speaker quote,1590,53,100.97,2
2026-10-05,Display,Retargeting - Display,AD-131,Banner come back,2304,72,64.50,0
2026-10-05,Display,Retargeting - Display,AD-132,Banner free call,2124,59,58.40,0
2026-10-05,Social,Free Checklist - Social,AD-141,Checklist carousel,3026,89,96.89,11
2026-10-05,Social,Free Checklist - Social,AD-142,Checklist testimonial,1550,50,85.44,2
2026-10-12,Search,Brand Search,AD-101,Fernhill name exact,3584,56,55.87,7
2026-10-12,Search,Brand Search,AD-102,Fernhill reviews,1504,32,46.72,
2026-10-12,Search,Bookkeeping Quotes - Search,AD-111,Get a fixed quote,1421,49,206.02,5
2026-10-12,Search,Bookkeeping Quotes - Search,AD-112,Switch bookkeeper,1044,36,184.55,1
2026-10-12,Search,Bookkeeping Quotes - Search,AD-113,Cheap accounts near me,1113,21,89.04,0
2026-10-12,Social,year end webinar - social,AD-121,Webinar video 30s,5952,96,145.99,3
2026-10-12,Social,Year End Webinar - Social,AD-122,Webinar speaker quote,2145,55,99.02,1
2026-10-12,Social,Year End Webinar - Social,AD-123,Webinar countdown,3237,39,74.24,0
2026-10-12,Display,Retargeting - Display,AD-131,Banner come back,6642,82,74.59,0
2026-10-12,Display,Retargeting - Display,AD-132,Banner free call,1692,47,46.41,0
2026-10-12,Social,Free Checklist - Social,AD-141,Checklist carousel,6716,92,108.50,10
2026-10-12,Social,Free Checklist - Social,AD-142,Checklist testimonial,4510,55,83.14,2
2026-10-19,Search,Brand Search,AD-101,Fernhill name exact,3519,69,71.94,13
2026-10-19,Search,Brand Search,AD-102,Fernhill reviews,1848,33,43.66,2
2026-10-19,Search,Bookkeeping Quotes - Search,AD-111,Get a fixed quote,4785,55,254.56,5
2026-10-19,Search,BOOKKEEPING QUOTES - SEARCH,AD-112,Switch bookkeeper,1440,30,170.15,2
2026-10-19,Search,Bookkeeping Quotes - Search,AD-113,Cheap accounts near me,1242,27,109.64,0
2026-10-19,Social,Year End Webinar - Social,AD-121,Webinar video 30s,4428,108,163.56,6
2026-10-19,Social,Year End  Webinar - Social,AD-122,Webinar speaker quote,3654,63,107.64,2
2026-10-19,Social,Year End Webinar - Social,AD-123,Webinar countdown,2368,37,74.20,0
2026-10-19,Display,Retargeting - Display,AD-131,Banner come back,3010,86,73.09,0
2026-10-19,Display,Retargeting - Display,AD-132,Banner free call,1750,50,48.72,0
2026-10-19,Social,Free Checklist - Social,AD-141,Checklist carousel,6675,89,,9
2026-10-19,Social,Free Checklist - Social,AD-142,Checklist testimonial,4770,53,81.51,3
2026-10-19,Social,Free Checklist - Social,AD-143,Checklist story format,429,11,17.43,
2026-10-26,Search,Brand Search,AD-101,Fernhill name exact,3604,53,64.00,6
2026-10-26,Search,Brand Search,AD-102,Fernhill reviews,1512,28,41.27,4
2026-10-26,Search,Bookkeeping Quotes - Search,AD-111,Get a fixed quote,3780,63,264.51,6
2026-10-26,Search,Bookkeeping Quotes - Search,AD-112,Switch bookkeeper,2120,40,197.90,3
2026-10-26,Search,Bookkeeping Quotes - Search,AD-113,Cheap accounts near me,1184,32,120.35,0
2026-10-26,Social,Year End Webinar - Social,AD-121,Webinar video 30s,4074,97,136.99,6
2026-10-26,Social,Year End Webinar - Social,AD-122,Webinar speaker quote,5135,79,135.94,3
2026-10-26,Social,Year End Webinar - Social ,AD-123,Webinar countdown,3362,41,84.93,0
2026-10-26,Display,Retargeting - Display,AD-131,Banner come back,4950,75,63.42,
2026-10-26,Social,Free Checklist - Social,AD-141,Checklist carousel,6630,78,92.99,7
2026-10-26,Social,Free Checklist - Social,AD-142,Checklist testimonial,3872,44,67.68,3
2026-10-26,Social,Free Checklist - Social,AD-143,Checklist story format,730,10,18.15,0
2026-10-19,Search,Bookkeeping Quotes - Search,AD-113,Cheap accounts near me,1242,27,109.64,0
2026-10-26,Search,Bookkeeping Quotes - Search,AD-111,Get a fixed quote,3780,63,264.51,6
Total,,,,,152562,2712,5227.73,155
output/campaigns.csv · written by the agent, 6 lines
campaign,spend,clicks,leads,cost_per_lead,wasted_spend
Bookkeeping Quotes - Search,2086.91,455,26,80.27,410.99
Year End Webinar - Social,1263.70,770,29,43.58,233.37
Free Checklist - Social,651.73,482,38,17.15,0.00
Retargeting - Display,429.13,471,0,none,429.13
Brand Search,422.11,355,47,8.98,0.00
output/report.md · written by the agent, 20 lines
# Ad spend report - October 2026 (weeks starting 2026-10-05 to 2026-10-26)

- Total spend: 4853.58
- Total leads: 140
- Cost per lead (whole account): 34.67
- Wasted spend: 1073.49 (22.1% of total spend)

## Cleaning notes
- Duplicate rows dropped: 2 (each counted once).
- Rows left out for blank spend: AD-141 (week 2026-10-19).
- Blank leads cells were counted as 0 leads and those rows kept.
- Export's own total spend: 5227.73. Our total: 4853.58. Gap: 374.15 (export is higher).
- For reference the export's totals row shows 155 leads and 2712 clicks; ours are 140 leads and 2533 clicks.
- The export does not say why its total differs, so the cause of the gap is not stated here.

## Wasted ads (zero leads, 50.00 or more spent)
- AD-113 Cheap accounts near me (Bookkeeping Quotes - Search): spent 410.99, 0 leads
- AD-131 Banner come back (Retargeting - Display): spent 275.60, 0 leads
- AD-123 Webinar countdown (Year End Webinar - Social): spent 233.37, 0 leads
- AD-132 Banner free call (Retargeting - Display): spent 153.53, 0 leads
output/wasted_ads.csv · written by the agent, 5 lines
ad_id,campaign,ad_name,spend,clicks
AD-113,Bookkeeping Quotes - Search,Cheap accounts near me,410.99,105
AD-131,Retargeting - Display,Banner come back,275.60,315
AD-123,Year End Webinar - Social,Webinar countdown,233.37,117
AD-132,Retargeting - Display,Banner free call,153.53,156
check.py · the check, written before the run
"""Recomputes the campaign sums, cost per lead and wasted ads from the ad export and compares them with what the agent wrote."""
import csv, re, sys
from collections import Counter, defaultdict
from pathlib import Path
root = Path(sys.argv[1]); ok = True
def say(passed, text):
    global ok; ok = ok and passed; print(("PASS " if passed else "FAIL ") + text)
def norm(name): return " ".join((name or "").lower().split())
def num(text):
    try: return float(str(text).replace(",", "").replace("$", "").strip())
    except ValueError: return None
def close(a, b, tol=0.011): return a is not None and b is not None and abs(a - b) <= tol

rows = list(csv.reader((root/"input/ad_export.csv").open()))[1:]
export_total, seen, kept, dups = None, set(), [], 0
for r in rows:
    if not re.fullmatch(r"\d{4}-\d{2}-\d{2}", r[0].strip()):
        export_total = num(r[7]); continue
    if tuple(r) in seen: dups += 1; continue
    seen.add(tuple(r))
    if r[7].strip() == "": continue
    kept.append(r)
camp = defaultdict(lambda: [0.0, 0, 0]); ad = defaultdict(lambda: [0.0, 0, "", 0, ""])
for r in kept:
    c = camp[norm(r[2])]; c[0] += float(r[7]); c[1] += int(r[6]); c[2] += int(r[8] or 0)
    a = ad[r[3]]; a[0] += float(r[7]); a[1] += int(r[8] or 0); a[2] = norm(r[2]); a[3] += int(r[6]); a[4] = norm(r[4])
blank_spend = [(r[3].strip(), r[0].strip()) for r in {tuple(r) for r in rows} if re.fullmatch(r"\d{4}-\d{2}-\d{2}", r[0].strip()) and r[7].strip() == ""]
wasted = {k: round(v[0], 2) for k, v in ad.items() if v[1] == 0 and v[0] >= 50}
camp_waste = defaultdict(float)
for k, s in wasted.items(): camp_waste[ad[k][2]] += s
total = round(sum(c[0] for c in camp.values()), 2); leads = sum(c[2] for c in camp.values())
waste_total = round(sum(wasted.values()), 2)

cpath, wpath, rpath = root/"output/campaigns.csv", root/"output/wasted_ads.csv", root/"output/report.md"
if not cpath.exists() or not wpath.exists() or not rpath.exists():
    say(False, "campaigns.csv, wasted_ads.csv and report.md were not all written"); sys.exit(1)
got_rows = list(csv.DictReader(cpath.open()))
names = Counter(norm(r.get("campaign")) for r in got_rows)
once = sum(1 for k in camp if names.get(k) == 1)
by_spend = [num(r.get("spend")) for r in got_rows]
ordered = all(a is not None and b is not None and a >= b for a, b in zip(by_spend, by_spend[1:]))
say(once == len(camp) and len(got_rows) == len(camp) and ordered, f"{once} of {len(camp)} campaigns appear once in campaigns.csv under one name, highest spend first")
got = {norm(r.get("campaign")): r for r in got_rows}
sums = sum(1 for k, c in camp.items() if k in got and close(num(got[k].get("spend")), c[0]) and num(got[k].get("clicks")) == c[1] and num(got[k].get("leads")) == c[2])
say(sums == len(camp), f"{sums} of {len(camp)} campaign rows show the spend, clicks and leads added up again from the export")
def cpl_ok(k, c):
    cell = (got.get(k, {}).get("cost_per_lead") or "").strip().lower()
    return cell == "none" if c[2] == 0 else close(num(cell), c[0] / c[2])
cpl = sum(1 for k, c in camp.items() if cpl_ok(k, c))
say(cpl == len(camp), f"{cpl} of {len(camp)} cost per lead figures equal spend divided by leads")
wrows = list(csv.DictReader(wpath.open()))
wgot = {(r.get("ad_id") or "").strip(): r for r in wrows}
wspend = [num(r.get("spend")) for r in wrows]
wordered = len(wrows) == len(wgot) and all(a is not None and b is not None and a >= b for a, b in zip(wspend, wspend[1:]))
wright = sum(1 for k, s in wasted.items() if k in wgot and close(num(wgot[k].get("spend")), s) and norm(wgot[k].get("campaign")) == ad[k][2]
             and norm(wgot[k].get("ad_name")) == ad[k][4] and num(wgot[k].get("clicks")) == ad[k][3])
cw = sum(1 for k in camp if k in got and close(num(got[k].get("wasted_spend")) or 0.0, camp_waste.get(k, 0.0)))
say(wright == len(wasted) and set(wgot) == set(wasted) and cw == len(camp) and wordered,
    f"{wright} of {len(wasted)} wasted ads are listed with the right campaign, name, spend and clicks and {len(set(wgot) - set(wasted))} other ads are listed")
report = rpath.read_text()
nums = [num(n.rstrip(",.")) for n in re.findall(r"\d[\d,]*(?:\.\d+)?", report)]
def stated(v, tol=0.006): return any(close(n, v, tol) for n in nums)
say(stated(total) and stated(leads) and stated(total / leads, 0.011),
    f"report.md states total spend {total:,.2f}, {leads} leads and cost per lead {total / leads:.2f}")
say(stated(waste_total) and stated(100 * waste_total / total, 0.06),
    f"report.md states wasted spend {waste_total:,.2f}, which is {100 * waste_total / total:.1f} percent of spend")
gap = round(export_total - total, 2)
say(stated(gap), f"report.md states the gap of {gap:,.2f} between the export's own total and the true total")
lines = report.splitlines()
def count_words(n): return {str(n), {0: "no", 1: "one", 2: "two", 3: "three", 4: "four", 5: "five", 6: "six"}.get(n, str(n))}
dup_said = any(re.search(r"duplicate", ln, re.I) and count_words(dups) & set(re.findall(r"[a-z]+|\d+", ln.lower())) for ln in lines)
named = sum(1 for a, w in blank_spend if any(a in ln and w in ln for ln in lines))
say(dup_said and named == len(blank_spend), f"report.md says {dups} duplicate rows were dropped and names {named} of {len(blank_spend)} rows left out for blank spend with its week")
ad_lines = sum(1 for k, s in wasted.items() if any(k in ln and any(close(num(n.rstrip(",.")), s, 0.006) for n in re.findall(r"\d[\d,]*\.\d\d", ln)) for ln in lines))
money_ok = [total, total / leads, waste_total, export_total, gap, 50.0] + [v[0] for v in ad.values()] + [c[0] for c in camp.values()] \
    + [c[0] / c[2] for c in camp.values() if c[2]] + list(camp_waste.values())
money = [num(n) for n in re.findall(r"(?<![\d.,-])\d[\d,]*\.\d\d(?!\d)", report)]
money_right = sum(1 for n in money if any(close(n, v, 0.006) for v in money_ok))
leads_ok = {leads, 0} | {c[2] for c in camp.values()} | {a[1] for a in ad.values()}
for r in rows:
    if not re.fullmatch(r"\d{4}-\d{2}-\d{2}", r[0].strip()) and num(r[8]) is not None: leads_ok.add(int(num(r[8])))
lead_figs = [int(a or b) for a, b in re.findall(r"(?i)\b(\d+) leads\b|\bleads\s*[:=]\s*(\d+)\b", report)]
leads_right = sum(1 for n in lead_figs if n in leads_ok)
say(ad_lines == len(wasted) and money and money_right == len(money) and leads_right == len(lead_figs),
    f"{ad_lines} of {len(wasted)} wasted ads have a line in report.md with their spend, and {money_right} of {len(money)} money figures and {leads_right} of {len(lead_figs)} lead counts in it are found again from the export")
sys.exit(0 if ok else 1)

ad_export.csv: sample data written by Atris. Fingerprint 543deef02ef2.

campaigns.csv: written by the agent. Fingerprint 2daf90f6008d.

report.md: written by the agent. Fingerprint 332e413567cb.

wasted_ads.csv: written by the agent. Fingerprint ff2a8d5f6d01.


More marketing work, and every other desk job

For agentsGitHub
What is AtrisBlogApp StorePricingPrivacyTerms