analysis_anomalies_check
Detects anomalies in campaign metrics by comparing current data against a median-based baseline from historical action logs. Flags critical issues like zero spend, CPA spikes, and CTR drops with severity ordering.
Instructions
Detect anomalies for one campaign by comparing its current metrics against a median-based baseline built from STATE.json's action_log history. Returns severity-ordered anomalies — zero spend (CRITICAL), CPA spike (HIGH/CRITICAL, gated by 30+ conversions), CTR drop (HIGH/CRITICAL, gated by 1000+ impressions). No baseline is produced when history < min_baseline_entries (default 7).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| current | Yes | Point-in-time metrics for the campaign. | |
| state_file | No | Path to STATE.json. Resolved inside the server's current working directory; traversal or symlink escape is rejected. Defaults to 'STATE.json'. | |
| had_prior_spend | No | Set false for fresh campaigns that have never spent. Suppresses the zero-spend alert in that case. | |
| min_baseline_entries | No | Minimum action_log entries required to build a baseline. Default 7 (one week). Below this the tool returns baseline=null and evaluates only zero-spend. |