Account Limits
A subscription allows so much use in each of a few windows of time: Claude's, five hours from the first turn in them, a week, and a week for each of some models. When a window's allowance is used up, the agent refuses turns until it resets. CAF keeps what the agent last said of each, its account limits, so your program can show the user how much is left before they run out.
Where they come from #
Only Claude says, for now, and only, as the Claude Agent SDK documents
its rate_limit_info (type SDKRateLimitInfo in its sdk.d.ts, as
bundled with @agentclientprotocol/claude-agent-acp 0.98.0), for
"claude.ai subscription users": an account signed in with an API key
should expect none. Its adapter tells a session of them in a
usage_update. An agent that never says has none.
Claude reports them from a reply's rate-limit headers when they say
something other than what that Claude process last heard, and first from
a quota check it makes as it starts. Upstream's adapter drops that first
report, which arrives before the first prompt's turn has begun, and any
that arrives before a turn has had a reply; and as the turn's own reply
then says nothing new, a new chat may never show its limits. CAF installs
Claude's adapter patched
(Installing and Signing In),
as 0.98.0+caf.1, and that passes on every report it hears while the
session lasts (one still held as the session closes is lost): so a chat
hears the limits with its first prompt, as a live run confirms. A host that runs
upstream's adapter itself, by its own command, may never hear them.
After that, a report comes only when something changes, which may be rarely: show limits as news when they come, and say how old they are.
Each window has:
kind:FiveHours,Week,ModelWeekwith the model's name in lower case (opus,sonnet),ExtraWeek(the week with extra usage counted in), orOther, with the agent's own name for a window CAF doesn't know;used: how much of it is used, a whole percent, 0–100;resets: when it starts again, if the agent said;state:Fine,Warning(the agent warns it's near the end), orRefuseduntil it resets, always 100% used;heard: when CAF last heard of it.
extra_usage says whether extra usage, paid for beyond the plan as it
goes, is in use, if the agent has said.
Whose they are #
An account's, not a chat's: every chat with an agent, and every agent with
the same profile, shares them, as they share one sign-in. They come with
the agent's status, as AgentStatus::limits, the same for every viewer:
use ;
use Wall;
let mut agents = caf.watch_agents;
while let Some = agents.next.await
They're information only. CAF never holds a message back for them, nor
warns before sending: a turn the agent refuses for its limits fails as
it does without them, as FailureReason::UsageLimit.
Over time #
- The latest news wins, window by window. A report changes only the windows it names, each replacing the one of its kind if it was heard later, whichever chat, app or saved copy it came from.
- A window is forgotten once its reset has passed, and the statuses are told again. One with no reset stays until another replaces it.
- Signing out, and a sign-in finishing, clears them, as the account may have changed. A window heard before that is never taken back.
- A limit reset early by the provider, or raised by a new plan, shows
as it was until the agent next says, with the next turn: CAF can't ask.
heardlets you say how old a window is.
Where they're kept #
In the usage folder every CAF app on the machine shares
(Usage), a file per profile in limits/,
such as limits/claude-agent-acp.json. So an app has them as it starts,
before the agent says again. Each save is merged with the file, so two
apps never undo each other's later news, and an app takes in what another
kept as it starts and whenever it saves news of its own. With no usage
folder (config.usage = None), limits are still kept while CAF runs, but
not across restarts.
Showing them #
A window's pace is how much of it has gone by, as a whole percent:
where used would be at an even pace. Used above it is ahead of pace, on
the way to running out before the reset. A window CAF doesn't know the
length of (Other), or with no reset, has none.
The TypeScript SDK has the rest, so every viewer says the same of them:
;
for of caf.agents
labelnames a window for showing:5-hour,Weekly,Weekly · Opus,Weekly · extra included, or the agent's own name for it.leftis how much is left, as a whole percent: none once refused.lownessislowat 20% left or less (LOW_LEFT), andoutat 10% or less (OUT_LEFT), or once refused; otherwisefine.lowestis the window with the least left, the first of them on a tie, ornullwith none.paceandlengthmatch caf-core'sLimitWindow::paceandWindowKind::lengthexactly.
Each takes an agent's status as a watch gives it, read-only. A kind of window newer than the SDK has no length and no pace, and is named by its type.
Pace and resets move with the clock, not with news, so draw them again as time passes: a viewer has no other word that a window is nearer its reset.