Quota #
The daemon polls supported accounts for provider-reported quota readings. These
readings are separate from the token usage recorded for
provider requests.
quota.gleam owns discovery,
storage, and queries, and runs the schedule that
quota_schedule.gleam
decides. The schedule is pure: the poller passes it each tick, discovery and
finished poll with the time, and starts the discovery and polls it answers. Keep
scheduling rules there, not in the actor.
Accounts #
Provider extensions supply the accounts through QuotaPlugin sources. The
daemon server passes every
installed source to the poller, enabled or not, with the runtime's key
environment. The poller hands that value to each source so key profiles find
environment keys. enumerate collects each source's sign-in accounts first. It
then asks the source of the extension each saved profile names for that
profile's target. A target includes a provider, a non-secret account label, and
credentials for the fetch. Discovery and individual polls run outside the poller
actor. See
enumerate and run_effect,
provider contributions,
and authentication.
These extensions contribute sources today:
- Claude, Codex, Google Antigravity, and OpenCode Go poll their sign-in accounts
as
anthropic,openai-codex,google-antigravity, andopencode-go. - An OpenCode Go key profile polls the first key it resolves to.
- An OpenAI-compatible profile polls the feed its endpoint host names. The OpenAI extension maps the Hyper, DeepSeek, and Alibaba hosts.
Cadence #
The quota section of extensions.json defaults to enabled: true,
pollSeconds: 600, and busyPollSeconds: 120. The poller reloads settings each
round. It clamps the ordinary interval to 1 through 86,400 seconds and the busy
interval to 1 through the ordinary interval.
A successful report uses the busy interval if a limit is at least 80 percent
used or resets within the next 15 minutes. Failed polls use exponential backoff
based on the ordinary interval, with the exponent capped at six and the wait
capped at one hour. When discovery removes an account, its in-flight poll can
finish and record its reading. Only accounts still listed by discovery are
scheduled again. See
load_settings and is_busy,
and
tick, polled, and wait_seconds.
Readings #
record stores one row per reported limit, or an error row with an empty limit
ID when a report has no limits. All rows from one poll commit together. If a
limit cannot be stored, the writer rolls back the poll. Every returned report
then runs its source's heal. Antigravity's
quota_source
heal updates account limit marks, including for reports with an error or no
limits. Claude's heal marks a sign-in until the latest reset of a window at 100
percent and never clears a mark; see rotation. Empty reports
prune expired marks and remove integer legacy global marks. The
account policy
owns reconciliation; the native adapter retains matching, locking, storage
layout, and unknown fields. An omitted meter keeps its live mark. The recorded
reading is the provider report, not an independently measured balance. See
run and record.
Reading them back #
latest returns the latest
row for each account, provider, and limit. It suppresses an empty-limit error
row after a newer real limit reading for that account and provider. history
returns newest-first rows with an ID cursor and can filter a provider, account,
and limit trail. The
daemon server exposes these
queries through its HTTP API.