- meta_ads_client: filter currently-paused ads from analysis (they have
historic spend in the window but shouldn't get PAUSE recommendations)
- run.py: fetch both 3d and 7d ad metrics; merge cpl_3d/cpl_7d into each ad
- agent.py AD_SYSTEM: base PAUSE on 7d window (more stable for low-volume ads);
treat high cpl_3d with acceptable cpl_7d as statistical noise
- slack_notifier: campaign header shows yesterday's spend/leads explicitly;
ad table shows CPL(3d) and CPL(7d) side by side; labels include time period
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Fetch campaign metrics for 1d/3d/7d windows at run start (2 extra API calls total)
- Pass spend_3d/leads_3d/cpl_3d and spend_7d/leads_7d/cpl_7d to Claude decide()
- DECIDE_SYSTEM: decisions based on cpl_3d (primary) vs cpl_7d (trend direction)
- PAUSE rule now uses leads_3d==0 + spend_3d >= 3x max_cpl threshold
- Adset and ad analysis now use 3-day aggregated data (get_period_*_metrics)
- Add get_period_campaign_metrics/adset/ad methods to MetaAdsClient
- Print shows 1d/3d/7d CPL and leads per campaign for easy trend reading
- UNIT_SYSTEM and AD_SYSTEM note data covers last 3 days
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- _count_conversions: prioritize 'lead' over 'lead_grouped' to fix double-counting
(optimizer was showing 2x actual leads on all campaigns)
- Add call_confirm/contact fallbacks for call-objective campaigns (Vodafone, Lowi)
- PAUSE at campaign level only when leads==0 AND spend >= 3x max_cpl (technical failure)
- Ad-level PAUSE threshold raised from 5€ fixed to 3x max_cpl (context-aware)
- Pass max_cpl to ad analysis so Claude uses the correct campaign target
- Skip INCREASE/REDUCE_BUDGET for ABO campaigns (no campaign-level daily budget)
- Fetch bid config before action save to enable ABO detection pre-Baserow
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- AD_SYSTEM prompt for per-ad PAUSE/MAINTAIN decisions (>5€ spend with 0 leads)
- pause_ad() in MetaAdsClient for individual ad pausing via Meta API
- Ad PAUSE actions saved to Baserow with "ad:{id}" campaign_id prefix
- _ad_action_blocks() in Slack notifier renders pause buttons per ad
- _table_name() strips diacritics (NFKD) for monospace column alignment
- Wider name column (45 chars) in adset/ad tables to reduce truncation
- Guard in _effect_text to suppress "+0% budget adjustment" when no change
- _execute_action handles "ad:" prefix to route pause to correct API method
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Migrate from Airtable to Baserow: BaserowClient with snapshots, actions, creatives, logs
- Claude agents (Haiku for decisions/units, Sonnet for creatives) with cost_cap_eur vs CPL comparison
- Slack bot with colored action emojis, effect text before approval buttons, 500-char justifications
- Streamlit dashboard with date-range navigation, campaign drill-down (adsets/ads), Histórico tab
- Approval server (FastAPI + ngrok) for Slack button callbacks
- backfill.py for historical snapshot regeneration with Claude re-analysis
- Margin fix: 0-lead campaigns contribute -spend (not 0) to margin
- CTR fix: Meta returns CTR as percentage already, removed *100
- Parameter fix: pass decision parameter to Slack action for correct budget effect display
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>