token_usage
Aggregate token usage across projects and agents, view breakdowns by project, agent, or source, and check per-agent subscription quota utilization in one query.
Instructions
Portfolio-wide token-usage aggregation (SQL over tokens.db) plus
a normalized per-agent subscription quota snapshot.
Separated from orchestration_history so token monitoring can evolve
independently of event/dispatch history (and eventually power a live
token pane). Reads are windowed by the user's configured timezone.
period: today | week | month | all
project: restrict to one project name (mutually exclusive with
workspace; if both are given, project wins)
workspace: restrict to projects in a workspace (via registry)
group_by: project | agent | source — how breakdown is keyed
include_quota: include per-agent subscription window utilization
(default True). Cached 60s in-process; opt out for fast bulk polling.
include_summary: include a pre-rendered markdown HUD
(summary_markdown) the orchestrator can surface verbatim
(default True). Uses Unicode block bars, emoji color markers
(🟢 < 50%, 🟡 50–89%, 🔴 ≥ 90%), and fixed-width alignment
inside a fenced code block. Disable to save tokens when you
only need the raw structured data.
Returns: { "ok": True, "period": "today", "window": {"start": ISO, "end": ISO} | {"start": null, "end": null}, "group_by": "project", "breakdown": { key: {dispatch, orchestrator, total, input, output} }, # When group_by="project", # tokens that aren't tied to # any registered project # (orchestrator-session usage) # are bucketed under the # special key "ORCHESTRATOR", # always emitted first in the # breakdown. "total": {dispatch, orchestrator, total, input, output}, "quota": { # only when include_quota=True "claude": {"mode": "pro", "five_hour": {"used_pct", "resets_in"}, "seven_day": {"used_pct", "resets_in"}}, "codex": {"mode": "chatgpt", "primary": {...}, "secondary": {...}}, "gemini": {"mode": "auth_only", "auth_type": ..., "note": ...}, "fetched_at": ISO, "cached": bool, }, "summary_markdown": "Token Usage — ...\n```text\n..." # only when include_summary=True # — pre-rendered HUD; surface # verbatim, do not re-format. }
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| period | No | today | |
| project | No | ||
| group_by | No | project | |
| workspace | No | ||
| include_quota | No | ||
| include_summary | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||