preview_alert
Backtest a cost-alert condition BEFORE creating it: replays the condition against the last lookbackDays (default 45) of data and reports how many times it would have fired. Takes the same queries + condition + dedup as create_alert (no notification channel needed). Window math includes lastWeekSum/lastWeekAvg/lastMonthSum/lastMonthAvg for the previous complete calendar period; averages divide by calendar days, including zero-spend days. Example: (a - lastMonthAvg(a)) / abs(lastMonthAvg(a)) > 0.1. The dedup window is per groupBy value; delivery stays one message listing newly eligible groups. Returns the evaluation window, firingDays (distinct days the condition held), firingRows (per-group fires), notificationsCount (days on which at least one newly eligible group would notify) and a sample of firing dates with per-group state. Use this to sanity-check a condition/threshold (and tune dedup) before calling create_alert.
Effects: Read-only retrieval or computation; does not change saved resources or send messages. Scope: Authorized Costory workspace only.
EXAMPLE: "Would 'alert if 7-day AWS spend tops $50k' have fired this month?" → { queries: [{ type: "cost", name: "a", metricId: "cost", currency: "USD", filterCel: "cos_provider in ["AWS"]" }], condition: "rollingSum(a, 7, DAY) > 50000", dedup: { kind: "CALENDAR", calendarUnit: "WEEK" }, lookbackDays: 30 }
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"queries": "<queries>",
"condition": "<condition>"
},
"name": "preview_alert"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| slug | No | Organization slug. Omit to auto-detect from your account (fails if you belong to multiple orgs). | |
| dedup | No | Deduplication config controlling how often a still-firing group notifies. The window is per groupBy value; delivery stays one message listing newly eligible groups. Either CALENDAR (kind: CALENDAR, calendarUnit: WEEK | MONTH) = at most once per current ISO week / calendar month, or ROLLING (kind: ROLLING, windowDays: N) = at most once every N days. Optional here: when provided the result also reports how many notifications would actually be sent after dedup. | |
| context | No | Optional context used only for analytics; it does not affect tool execution. Omit it by default. Do not include conversation text, personal information, or workspace data. | |
| queries | Yes | Same series objects as the `query` tool `queries` array (referenced by `condition`). | |
| condition | Yes | Alerts v3 firing rule: a single boolean expression over the query names (`name` field of each query). Supports arithmetic (+ - * /), comparisons (> >= < <= == !=), logical and/or/not, parentheses, and these window functions: rollingSum(a, N, UNIT) (trailing sum over the last N units, UNIT ∈ DAY|WEEK|MONTH where MONTH is a 30-day window, not a calendar month, inclusive of today), weekToDateSum(a) (Monday-to-date), monthToDateSum(a) (1st-of-month-to-date), lastWeekSum(a)/lastMonthSum(a) (previous complete calendar period totals), lastWeekAvg(a)/lastMonthAvg(a) (period sum divided by 7 or the actual 28–31 calendar days, including zero-spend days), and timeShift(a, N, UNIT) (value shifted back N units; UNIT ∈ DAY|WEEK only — MONTH and YEAR are not supported; use timeShift(a, 30, DAY) as a 30-day approximation; may wrap a window function). Examples: `a > 1000`, `(a - lastMonthAvg(a)) / abs(lastMonthAvg(a)) > 0.1`, `rollingSum(a, 7, DAY) > 1000`, `(a - timeShift(a, 1, DAY)) / timeShift(a, 1, DAY) > 0.2`, `a > 10000 or rollingSum(a, 7, DAY) > 50000`. | |
| llm_model | No | The model identifier you are running as, for example "claude-opus-4-8" or "gpt-5.2". Pass "unknown" if you are not certain. Recorded for the server developer's analytics. | |
| lookbackDays | No | Trailing window length in days to replay the condition over (default 45). | |
| conversation_id | No | The conversation_id this server returned earlier in this conversation, unchanged, including after later user messages. Omit it if you have none. Recorded for the server developer's analytics. |