feat: anomaly detection engine — rolling baseline alerts for cost, tokens, errors#370
Open
vivekchand wants to merge 3 commits intomainfrom
Open
feat: anomaly detection engine — rolling baseline alerts for cost, tokens, errors#370vivekchand wants to merge 3 commits intomainfrom
vivekchand wants to merge 3 commits intomainfrom
Conversation
- Track per-turn model attribution in _compute_transcript_analytics() - Record model switching events with session context and timestamps - Add /api/usage/model-attribution endpoint returning: - Turn distribution by model with percentages - Model switching events (from/to, session, timestamp) - Per-session model breakdown with multi-model detection - Primary model identification - Add Model Attribution section to Tokens tab UI: - Horizontal bar chart showing turn share per model - Per-session models table (recent 30 sessions, multi-model flag) - Model switch events list with from→to arrows - Switch event count badge
- Add /api/cron/health endpoint: aggregates run history, success rate, sparkline data, and cost per job from local cron/runs/*.jsonl files - Add /api/cron/<job_id>/kill endpoint: kill switch that disables a cron job immediately via gateway or local file fallback - Add Cron Health Monitor panel in dashboard UI: - Per-job success rate % over last 7 days (color-coded) - 7-day sparkline bar chart (green=ok, red=fail) - Run count, duration, total cost columns - Collapsible run history table per job - Kill switch button to disable a running/scheduled job - Health Monitor button in crons tab refresh bar
…kens, errors - Add _get_anomaly_status(): computes 7-day rolling hourly baseline for 4 signals: cost_per_hour (2x threshold), token_velocity (3x), error_rate (2.5x), latency_p95 (2.5x) - Add /api/alerts/anomaly-status endpoint returning severity ok/warning/high per signal - Hook rolling-baseline detector into _budget_monitor_loop() to fire alerts automatically - Keep legacy daily anomaly check for backward compat - Add '⚡ Anomaly Status' panel in System Health section (overview tab) - One row per signal: icon + label + current vs baseline + ratio badge - Green/amber/red row background by severity; 'All Clear' state when ok - startAnomalyStatusRefresh() polls every 60s 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.
Summary
Implements a proper rolling-baseline anomaly detection engine with 4 signal types, configurable thresholds, and a live dashboard panel.
What's new
Backend:
_get_anomaly_status()ok/warning/highBackend:
/api/alerts/anomaly-statusendpointReturns live signal status with current, baseline, ratio, threshold, and severity per signal.
_budget_monitor_loop()integration_get_anomaly_status()to fire_fire_alert()for any crossing signalFrontend: ⚡ Anomaly Status panel
Added in the System Health sidebar (overview tab):
Closes
closes #301