Skip to content

feat: anomaly alerts panel in Tokens tab — surface cost spikes vs 7-day baseline#395

Open
vivekchand wants to merge 1 commit intomainfrom
fix/gh-clawmetry-304-anomaly-panel
Open

feat: anomaly alerts panel in Tokens tab — surface cost spikes vs 7-day baseline#395
vivekchand wants to merge 1 commit intomainfrom
fix/gh-clawmetry-304-anomaly-panel

Conversation

@vivekchand
Copy link
Copy Markdown
Owner

Closes #304

What

Adds a dedicated ⚠️ Anomaly Alerts panel to the Tokens tab that surfaces sessions with cost >2x their rolling 7-day average.

How

  • Panel is hidden when no anomalies exist (no visual noise)
  • When anomalies are detected, a section appears with a badge count
  • Table shows: session ID, actual cost, rolling avg, spike ratio (color-coded), timestamp
  • Ratio colors: amber (2–3x), orange (3–5x), red (5x+)
  • Fetches from the existing /api/usage/anomalies endpoint — no backend changes needed
  • Silent fail: if the endpoint is unavailable, panel stays hidden

Why now

The anomaly detection backend already existed (_compute_session_cost_anomalies, anomaly_daily budget alert) but there was no dedicated UI surface in the Tokens tab. Users could only see anomaly warnings as small ⚠️ icons on the Sessions tab. This panel makes the signal prominent and actionable.

Screenshot

The panel appears below the Cost Breakdown table when anomalies are detected, above the Plugin Cost chart.

…ay baseline (closes #304)

Add a dedicated Anomaly Alerts panel to the Tokens tab that surfaces sessions
with cost >2x their rolling 7-day average. The panel:

- Only appears when anomalies are detected (hidden otherwise)
- Shows session ID, cost, rolling avg, spike ratio, and timestamp
- Color-codes the ratio (amber 2-3x, orange 3-5x, red 5x+)
- Adds a badge count next to the section title
- Fetches from the existing /api/usage/anomalies endpoint (no backend changes)

The anomaly detection backend already existed (_compute_session_cost_anomalies,
anomaly_daily budget alert) but had no dedicated UI surface in the Tokens tab.
This closes the gap described in GH #304.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: Anomaly detection engine

1 participant