Skip to main content

Module account_usage

Module account_usage 

Source
Expand description

How much of an account’s usage windows is used, from the report Claude Code sends with every request.

Every request’s rate_limit_event frame carries rate_limit_info.unifiedWindows.<window>.{utilization, resetsAt} for each plan window (five_hour, seven_day, …), whatever its status (CLI 2.1.301: utilization is a fraction from 0 to 1, resetsAt is unix seconds). Every agent on one account reports the same windows, so the readings are kept per account, not per pane: the newest frame from any pane wins, a pane closing loses nothing, and a window’s reading is dropped once its reset has passed.

A reading that crosses a notice threshold (agent:usagenoticeat, agent:usagenoticehighat; a percent of the window, 0 turns one off) gives the leaders of the account’s agents one [AgentMux] note, once per window per threshold. The note is held for the leader’s next turn or joins the turn it is in: it never starts one.

Providers other than Claude report nothing here; UsageStatus::NotReported says so.

Structs§

AccountUsage
An account’s usage as an agent or a window reads it.
Crossing
A threshold a reading has newly crossed.
UsageWindow
One window’s latest reading for an account.

Enums§

UsageStatus
Whether an account’s usage is known.

Constants§

DEFAULT_NOTICE_AT
DEFAULT_NOTICE_HIGH_AT
SETTING_NOTICE_AT
agent:usagenoticeat: the percent of a usage window from which the account’s leaders get a note.
SETTING_NOTICE_HIGH_AT
agent:usagenoticehighat: the percent from which they get a second, stronger one.

Functions§

install_config
Attach the live settings (bootstrap), so the notice thresholds can be read.
observe
Keep windows (from windows_of_frame) as account’s latest at now_ms, and say which thresholds they newly cross. A reading for a window that resets earlier than the one kept is a frame from the window before: ignored. A later reset is a new window, and tells again.
observe_claude_frame
Any frame of block_id’s CLI: a rate_limit_event with usage is kept for the pane’s account, and its leaders told when it crosses a threshold. The persistent stdout reader calls it for every frame; anything else returns at once.
of_account
account’s windows that have not reset at now_ms, with their age.
reports_usage
Whether the provider’s CLI reports usage windows that srv reads: Claude’s rate_limit_event. Codex and Gemini report nothing srv reads, so their accounts say not_reported.
windows_of_frame
The windows a rate_limit_event frame reports: name, utilization (0 to 1) and reset (unix seconds). Empty for any other frame, and for a window with no utilization.