Compare Periods
compare_periodsCompare two time periods and rank what changed — THE tool for "what changed in our bill?", "why is this month higher than last?", "what moved week over week?", "which team's spend went up?". Returns totals for both periods, the absolute and percentage delta, and a movers table ranked by the SIZE of the change (largest absolute swing first), each row flagged "new" (spend only in period_a), "gone" (only in period_b), or "changed". Deltas are period_a MINUS period_b — period_b is the baseline. Give explicit windows ({ "period_a": { "start_date": "2026-06-01", "end_date": "2026-06-15" }, "period_b": { … } }) or use preset: "mom" (this month-to-date vs the same day-range of the previous month — also the default when you pass nothing), "wow" (the last 7 days vs the 7 before), "yoy" (this month-to-date vs the same day-range 12 months ago). Break the change down with group_by. "service" (default) and "account" are the FAST path: one call, any window length. Also: "tag:" (any tag key), "subcategory" (usage type), "usage_family", "region", "cost_center", "service_category", "charge_type". Those run two DAILY cost pivots in parallel (never monthly columns, which would compare a partial month against a full one), so: each window must be 31 days or shorter (a longer one is refused); they need one scope — provider OR integration_id, not both — and default to AWS like the fast path, saying so in scopeNote; a tag key is checked against get_available_tag_keys first and a wrong one is refused with the valid keys (keys are case- and hyphen-sensitive); and if the backend serves a different window than requested the tool fails rather than compare clamped data. Tag rows include "untagged" for spend without that tag. If those pivots take longer than the call allows you get { "status": "pending", "jobIds", "resumeWith" }: call compare_periods again with the resumeWith arguments (they include job_ids) to finish — that collects the same jobs instead of starting new ones. Scope with provider and integration_id. cost_basis is applied identically to BOTH periods and echoed as costBasis; on the fast path you can set any subset of the five toggles (the rest keep the organization's saved values), but the pivot group_by values take all five or none, because a pivot can't layer a partial basis over the saved settings. limit caps the movers table (default 25). FOLLOW-UP: this tool tells you WHAT moved; investigate_anomaly tells you WHY for a service, and run_cost_pivot with the mover's dimension plus "service" shows what is inside a tag or usage-type mover. Read-only. Examples: { "preset": "mom", "group_by": "service", "limit": 10 } returns the 10 services that moved the most this month vs the same days last month; { "preset": "mom", "group_by": "tag:team" } does the same per team tag value; { "preset": "wow", "group_by": "subcategory", "provider": "aws" } ranks usage types week over week.
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "compare_periods"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Max mover rows to return, ranked by the size of the change (default 25). | |
| preset | No | Relative windows instead of explicit dates. "mom" = this month-to-date vs the same day-range of the previous month (the default when nothing is given). "wow" = the last 7 days vs the 7 days before them. "yoy" = this month-to-date vs the same day-range 12 months ago. Ignored for whichever period you supply explicitly. | |
| job_ids | No | ONLY to finish a pivot comparison that returned status "pending": pass back the `jobIds` it gave you, with the SAME group_by, windows and scope (the pending response lists them under `resumeWith`). The jobs are collected, not resubmitted. Not accepted with group_by "service" or "account", which never create jobs. | |
| group_by | No | What to break the change down by. "service" (default) and "account" are the FAST path (any window length). Also: "tag:<key>" (any tag key — case- and hyphen-sensitive, validated against get_available_tag_keys before running), "subcategory" (usage type), "usage_family", "region", "cost_center", "service_category", "charge_type". Those run two daily cost pivots, so each window must be 31 days or shorter. | service |
| period_a | No | The RECENT window — the one you are asking about. Omit to use the preset (or the default: this month-to-date). | |
| period_b | No | The BASELINE window to compare against. Deltas are period_a minus period_b. Omit to use the preset (or the default: the same day-range of the previous month). | |
| provider | No | Provider scope. OMIT = AWS when no integration_id is pinned; with integration_id the scope follows that integration's provider. Pass "azure", "gcp", "snowflake", "anthropic", or "openai" to compare that provider's spend. One provider per call. | |
| cost_basis | No | Optional cost-basis override — how cost is computed. LAYERED: each field you set overrides just that toggle for this call; every field you omit keeps the organization's SAVED value. Omit the whole object to use the org's saved settings unchanged. Finance/chargeback questions usually want { "use_amortized": true }; "what did we actually get billed" questions want { "use_amortized": false }. The effective basis is echoed back as `costBasis` in the response, including which toggles this request overrode. | |
| integration_id | No | Scope to one or more provider connections (integration id). Omit for the whole organization. | |
| response_format | No | concise = totals, deltas and the top-N movers (default). detailed = additionally every row in both periods, unranked and uncapped (still bounded by the output-size guard). | concise |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| note | No | States the delta direction and the ingest lag caveat. | |
| tool | No | Which tool truncated (only on a truncated result). | |
| counts | No | Entity counts per period plus how many are `new` and `gone`. | |
| jobIds | No | Pivot path: the `{ period_a, period_b }` job ids. Pass back as `job_ids` to finish a pending comparison. | |
| movers | No | Movers — `name`, `periodACost`, `periodBCost`, `delta`, `deltaPct`, `status` ("new" | "gone" | "changed") — ranked by the ABSOLUTE size of the change. | |
| preset | No | "wow" | "mom" | "yoy" | "explicit". | |
| source | No | "cost_dashboard" (service/account fast path) or "daily_pivot" (two daily cost pivots). | |
| status | No | "pending" when the pivot jobs had not finished; absent on a completed comparison. | |
| totals | No | `periodA`, `periodB`, `delta` and `deltaPct` for the whole scope. | |
| allRows | No | Every mover row, uncapped (detailed only). | |
| groupBy | No | The pivot the change was broken down by. | |
| message | No | How to narrow the request (only on a truncated result). | |
| periodA | No | The recent window { start_date, end_date }. | |
| periodB | No | The baseline window { start_date, end_date }. | |
| currency | No | The organization's display currency — every amount is in it. | |
| followUp | No | The tool to call next to explain a mover. | |
| costBasis | No | The accounting basis these numbers were computed on: `source` ("organization_defaults" or "organization_defaults+overrides"), an `overrides` array naming the toggles this request pinned, the five resolved toggles (null = kept the org's saved value, which this server cannot read), and a one-line `summary` to quote when reporting the figures. | |
| jobStatus | No | Pending only: each job's status. | |
| scopeNote | No | Present when the scope defaulted to AWS on the pivot path. | |
| truncated | No | Present and true when the result exceeded the output-size budget and was WITHHELD. When you see this, no data fields are present — narrow the request as `message` says and call again. | |
| moverCount | No | How many movers exist in total. | |
| resumeWith | No | Pending only: the exact arguments (including `job_ids`) to call compare_periods with to finish. | |
| lastUpdated | No | service/account path: when this response was generated (NOT a data-ingest time); null on the pivot path. Use get_data_freshness for how current the data is. | |
| approx_chars | No | Approximate size of the withheld result (only on a truncated result). | |
| providerScope | No | The provider these numbers cover. | |
| returnedMovers | No | How many were returned after `limit`. | |
| integrationScope | No | The integration(s) scoped to, or null. |