12 Commits

Author SHA1 Message Date
7228cf1b65 Integración con OpenCode 2026-07-09 16:49:00 +02:00
d23cb6b9c2 Fix tracking discrepancy direction, improve daily metrics table, increase max_tokens
Some checks failed
Weekly Strategic Report / run (push) Has been cancelled
- analyzer.py: use abs() for tracking discrepancy so both directions alert
- slack_reporter.py: daily table adds L.AT/L.GA/Coste/€.AT/€.GA columns; margin uses Google Ads conversions × PPL; split monthly rankings into separate blocks; fix stale margen field
- run.py: leads_grupo always uses Google Ads conversions; tracking alert shows direction (over/under attribution)
- agent.py: increase decide() max_tokens 700→750 to fix JSON truncation for long campaign names

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-13 20:27:31 +02:00
4d03ddf271 Increase decide() max_tokens 600→700 to prevent JSON truncation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-12 15:57:08 +02:00
4848253c49 Fix leadform double-attribution and Slack message truncation
- airtable_client: restrict leadform cursoid path (path 5) to PMX-only
  campaigns, preventing triple-attribution to search+pmx+leadform companion
- slack_reporter: derive margen from ingreso-coste instead of stale MetricasDiarias
  field; split monthly rankings from fields to separate section blocks; add
  _trunc() helper to clamp all text blocks under Slack's 3000-char limit
- agent: increase portfolio_daily_analysis max_tokens 500→800
- backfill: extend to June 11

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-11 23:04:40 +02:00
0eb360bf6d Increase decide() max_tokens to 600 to fix JSON truncation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-11 19:06:41 +02:00
c025a5f828 Downgrade Claude calls to sonnet-4-6 for cost efficiency
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-06 10:00:58 +02:00
3028123c81 Switch all Claude calls to claude-opus-4-8
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-06 09:54:05 +02:00
a94c18c13c Add daily portfolio analysis and weekly strategic report
- agent.py: portfolio_daily_analysis() for daily Slack block,
  weekly_strategic_analysis() for deep weekly report
- run.py: call portfolio analysis before Slack send
- slack_reporter.py: add strategic diagnosis block at end of daily report
- weekly_report.py: standalone weekly report script
- .github/workflows/weekly.yml: runs Mondays at 9am (CEST)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-21 20:22:37 +02:00
c728cfc149 Improve lead tracking and agent advice quality
- Use GACampaignID field + FIND(gad_campaignid) fallback in Leads Lake filter
- Add ConvLeadsLakeMes to campaign data for tracking discrepancy comparison
- Update ConvLeadsLakeMesFinal daily as snapshot of Airtable lead count
- Agent: ignore capping when capping=0 in advice

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-22 12:25:00 +02:00
f6f897adeb Include campaign status in analysis and fix agent reactivation advice
- analyzer.py: add status_google (ENABLED/PAUSED) to analysis dict
- agent.py: instruct agent never to recommend reactivating an ENABLED campaign;
  mention reactivation in consejo only when campaign is PAUSED

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-21 13:01:41 +02:00
e4362c6ad9 Add sync detail and per-campaign advice
- Sync shows campaign ID, name and status for new campaigns,
  and field-level changes (before/after) for updated ones
- Agent now returns a 'consejo' field with a specific actionable
  recommendation per campaign
- Summary table includes leads, margin and consejo per campaign

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-17 16:16:43 +02:00
f0d7f65c1a Initial commit 2026-04-17 12:53:25 +02:00