feat: adaptive anomaly detection engine — per-session cost spikes, frequency alerts, configurable multipliers (closes #301)#353
Open
vivekchand wants to merge 1 commit intomainfrom
Conversation
…ncy alerts, configurable multipliers (closes #301)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #301
What
Upgrades the anomaly detection engine from a single daily-cost check to a full adaptive multi-signal detection system that fires alerts (Telegram + webhook + dashboard banner) when agent behavior deviates from rolling baselines.
New detection signals
Configurable thresholds
All multipliers are now user-configurable in the Alert Rules → Webhook Config UI:
Alert routing
All anomaly signals route through the existing
_dispatch_configured_webhooks()and_fire_alert()pipeline — so they reach Slack, Discord, generic webhooks, and Telegram automatically based on existing config.How
_detect_per_session_cost_spikes(): Reuses_compute_session_cost_anomalies()output, fires_fire_alert+ webhook for sessions in the last 2h that exceed N×rolling avg_detect_session_frequency_anomaly(): Counts sessions per day from transcript analytics, alerts when today exceeds N×7-day avg_budget_monitor_loop()(runs every 60s, with cooldown deduplication via rule_id)_default_alerts_webhook_config(): Extended with 5 new keys; all persisted via existing config file/api/alerts/webhook: allowed-keys allowlist updated to include new multiplier fields