Skip to content
Engine has no release yet: these pages describe unreleased main.

Budgets and Spend

Two numbers describe what a company’s models consumed; reading one as the other causes most confusion about spend. This guide says what each is, where it comes from, how far back it reaches, and how Settings › Spend draws it.

The budget counterThe spend rollup
What it isThe fleet’s shared counter the budget gate charges with every model round on the engine host the moment its reply arrives, and with an executor run’s whole spend when the run is collectedA breakdown of what the calls consumed, by phase, model, provider entry, auxiliary purpose and seat (or person)
Its windowOne calendar window (day, ISO week or month) on the company’s clockThe live 24 hours, or any run of 1 to 90 company days
Where it livesThe coordination store (budgets), one record per scopeThe live projection for the last 24 hours; the replicated usage domain for every named window
What it is forStopping a turn whose round did not fit a ceiling, and every round and launch after itUnderstanding where the tokens went
Read byGET /budgets, the budget push, the meters on the Spend, Budgets and seat screensGET /tokens/breakdown, GET /tokens/series, the figures and chart on Settings › Token spend

They are never comparable: the counter is what a ceiling is divided into, the rollup says why. Both count the same calls (every round of a turn and every auxiliary call); the reasons they part are listed.

A token_budget is a set of ceilings per calendar window (day, week, month, each optional) on the company, on an agent seat, or both:

timezone: Europe/Berlin
token_budget: {day: 3000000, month: 40000000}

Windows are cut on the company’s one clock: a day is local midnight to midnight, a week the ISO week from Monday, a month from the 1st. Every model round on the engine host (reviewer, worker, onboarding pass, side pass) is charged in all three windows it falls in, against the company and its seat, as soon as its reply arrives; what it asked for runs only while every capped window of both had room.

A seat’s executor is its harness’s own run in a box, whose requests the engine never sees singly, so its whole spend is charged once, when the run is collected: a post-charge. It never refuses and can take a window past its ceiling (sandbox_spend_over_budget); the seat’s next round and delivery are then refused until the window turns over. What admits a run is the floor at its launch.

A ceiling has room for one executor run, or it is refused. Every executor launch, including one mid-turn, needs turn_engine.executor_min_budget_tokens (default 65 000: the fixed part of one run’s opening request) plus its brief (a token per four bytes) left in every capped window of its seat and the company. A seat short of it is parked until the window turns over. The default is sized for the opening request of a seat with only the engine’s own tools on every supported harness (about 48 000 tokens on Claude Code, 11 000 on Grok Build, which defers them); a company on a lighter harness can lower it, but a floor below a run’s opening request admits runs that cannot finish their first round.

  • A launch whose fresh brief takes that past the most room the capped windows can leave is held instead (executor_floor_held), at the floor alone where the floor fits. Room is each window’s ceiling less what the launch’s own turn spent there before (gathered context, rewrites).
  • Held at the floor alone, it goes out once a window has the floor left, whatever other seats spent first, so a busy company never keeps it waiting; its opening request may take that window past its ceiling.
  • Only where the turn’s own spend left less than the floor is it held at the room, waiting for a window holding nothing but its own turn’s spend.
  • A launch refused below the floor with its brief, or with a session’s context, waits one turnover at most: other seats spend first after every turnover. In the next window its next try is held at the floor alone and continues a session only where that window has room. That covers the next try of the same message’s delivery or the same turn’s relaunch, never the launch of a person’s message the seat is handed first after turnover, which is held to its own floor.
  • A reviewer sending work back on a window that cannot pay for it holds the job the turn just collected: it waits collected in its paused box, seat held behind it, and the turn resumes once the window turns over or a revision raises the ceiling (sandbox_resume_held in the log), rather than reviewing again into the same refusal. A run that finishes while its window is full is held the same way; its tokens are charged in the window it ran in.
  • A person’s answer carrying a parked run on is not let in while the window is full or too short for a launch. One whose relaunch is refused anyway waits, uncharged, in its own series of attempts (sandbox_resume_refused), until turnover or a raised ceiling (see Mid-run clarification).
  • A ceiling below the floor never has it left, so on a seat that runs an executor, or a company that has one, it is refused at validation, at the ceiling: raise it to the floor, or lower the floor (0 turns it off for every launch whose session’s context is not known).

A launch that continues a session needs room for that session. A send-back, a person’s answer, a lost job or a replaced sign-in continues the turn’s harness session where it can; a conversation’s next turn continues the session its last turn left, and a schedule’s next fire the session its last fire left. A continued run sends the session’s whole context again before its brief, so its launch needs the larger of the floor and that context plus the continuing brief’s estimate: the whole input of the session’s last request, cache included, recorded at capture. A 90 000-token session handed a 2 000-token continuation needs 92 000 left in every capped window.

  • It never needs less than the floor with its fresh brief (held as above where past the room), since its box starts a session of its own wherever it cannot take the session up.
  • This holds for a run continued in its own box and one restored into another, and for the session a conversation’s last turn left (that capture’s recorded context).
  • A run continued in its own box is held to the larger of its job’s newest capture’s measure and what the job’s collection found the copy’s newest request carried (which a company that keeps no session has alone). A session neither measured has no known context; its launch needs the floor plus the continuing brief.
  • A relaunch below its figure is held (an answer, turned back) as above, one turnover at most.
  • A turn’s first launch below its figure parks the seat’s mail on that figure, never the floor alone: a window with room for a fresh run but not the session would read as having room and hand the delivery straight back into the same refusal. A colleague’s ask behind such a park is still owed its answer. The reason names what the figure is made of.
  • A session whose figure is past the most room the capped windows can leave (each ceiling less what the launch’s own turn spent there), which no turnover ever leaves, is not continued: the launch starts a session of its own, on the floor with its fresh brief, held as above where past the room.
  • A seat with no capped window continues a session of any size.

And it pays for its context on every request. Every request sends the harness’s whole conversation and is charged its whole input, cache’s share included (Cache share). A run continuing a 60 000-token session with 20 requests is charged about 1.2 million input tokens for that context alone, mostly cache reads, where a fresh run begins at its harness’s prompt, instructions and brief. A conversation’s next turn pays as a relaunch does. A session’s context is bounded by its harness’s compaction for that reason.

  • Every Claude Code run is pinned to its model’s context window (CLAUDE_CODE_AUTO_COMPACT_WINDOW, with the variables that would switch compaction off or move its point unset; from 2.1.310 that window and those two overrides are held over a repository’s own settings). It compacts at the smaller of that window and the one it holds the model to (200 000 for Opus 4.6 and Sonnet 4.6 unless the account is served more or the model opts in with [1m]) less about 33 000 tokens of headroom. A continued run of n requests is charged up to about n × 967 000 input tokens on a 1 000 000-token model, n × 167 000 on a 200 000-token one.
  • A smaller fixed window would starve the run: the first request already carries the harness’s prompt, tools and brief, and a window too small for those and the files read compacts repeatedly until the harness stops it (What a continued launch costs).
  • OpenCode compacts once its own count of the conversation (last settled reply’s input, cache, output and reasoning, plus an estimate of what follows) reaches its model’s limit (input limit where set; on 2.2 the smaller of input and context limits) less 15% on 2.1 and 2.2, or 10% on 2.0, at least 16 000 tokens, or less a configured compaction.buffer, which the engine does not move (it is a share or count of a window the engine does not know). A continued OpenCode run of n requests on a 200 000-token model is charged up to about n × 170 000. So is a Claude Code run whose repository’s settings switch compaction off, up to its model’s window.
  • A session is continued wherever the seat’s budget can carry it (the floor above) and on a member whose model’s window, as Claude Code holds that model, can carry it.

A schedule pays for its session on every fire. A schedule is a conversation of each seat that runs it, so each fire continues the session its last fire left on that seat and pays for it on every request, up to about the model’s compaction point with Claude Code (967 000 input tokens on a 1 000 000-token model). An hourly check at that point making ten requests is charged about 9.7 million input tokens a fire, some 232 million a day on its seat and the company, mostly cache reads. Its first launch needs that context left in every capped window and, short of it, parks the seat’s mail until a window has room. There is no per-schedule switch: the ceilings bound it, and turn_engine.conversation_session.enabled: false starts every fire and every conversation’s next turn fresh (Scheduling).

A round’s size is known only from its reply, so the vendor has billed it by the time it is judged, and a refused round is counted like any other. The refusing window reads over its ceiling by that round: a day at 98 000 of 100 000 whose next 4 000-token round is refused reads 102 000 of 100 000 on GET /budgets, the Spend, Budgets and seat meters and crewlet budgets show, and that is the figure the budget park judges. Every later round is refused until the window turns over or the ceiling is raised. The figure is what the company was billed; leaving the refused round out would read below the invoice and let a smaller round in on room already spent.

Because every later round is certain to be refused, a refusal also stops every later model call of the turn before it is sent: the next phase, the round-cap judge, the seat’s other workers and an executor launch. Each is the gate’s refusal like any other, recorded as the window’s refused_at (the “last refused” on Company › Budgets and in crewlet budgets show) the first time a turn holds one there.

  • The refused round is the one a turn pays for past its ceiling; a turn running alongside on the same company can still pay for one round of its own before the counter tells it.
  • A turn’s own auxiliary calls go through the same meter: a context assembly or rewrite that takes a window to its ceiling has its round refused before it is sent, and the turn makes no further auxiliary call while that window is full. The exception is the task card’s rewrite, made after the last round as the turn’s record, so a turn the budget ended still has a readable card.
  • “Certain” is on the turn’s own clock: a turn begun before the company’s timezone moved east can stop on a day other nodes have already turned over. Its message then runs again, since the park finds nothing refusing, unless the turn had already written outside the engine, in which case it is recorded, as after any refusal.

The same holds wherever the engine turns work away on an already full window before making a call: a seat’s delivery parked until turnover, a person’s answer_knowledge question refused, a reflection or background learning pass declined. Each is the gate’s refusal, recorded as refused_at on the scope a charge would have been refused by (the company’s before the seat’s), so a window filled by an executor’s launch, a background pass or a person’s answers says when it last turned work away.

A third ceiling holds each person’s Ask Crewlet questions: assistant.token_budget, the same three windows, charged per person on top of the company’s (see Ask Crewlet’s budgets).

Every ceiling is part of the company document. The company’s token_budget, a seat’s and each person’s Ask Crewlet ceiling are written through /config (admin), a seat’s alone with PUT /config/roles/{handle}, and every node enforces them once it has applied that epoch. The write is a revision recorded with a summary such as “Raise the company’s daily token ceiling from 2M to 5M”. A seat ceiling the company’s own makes unable to refuse a turn (a seat’s day at or above the company’s day) is a warning at the seat’s ceiling from crewlet validate and on every /config write’s answer. A refusal one of them caused names it (its remedy), so the dashboard offers whoever may raise it the way to that ceiling on Company › Budgets, and tells anybody else who can. See Dashboard design § Company › Budgets.

The spend rollup, and why it has two sources

Section titled “The spend rollup, and why it has two sources”

The live 24 hours are held by each node’s live projection: the phase and auxiliary records of the last day, folded on every node and pushed over the dashboard’s socket every few seconds (the tokens push). It is instant and can list recent turns one by one; no screen of the bundled dashboard draws it.

Every named window (7, 30 or 90 days, or two dates you name) is read from the replicated usage domain. Every data node derives its own day from its own event log (its own seats’ and those of nodes without data whose events it keeps through custody) and publishes it whole; every data node applies every data node’s days. So a named window is:

  • the company’s, whichever node answers;
  • whole company days on the company’s clock, so “the last 7 days” is the same seven days everywhere;
  • there after a node leaves: a departed node’s days stay.

A company day holds nothing finer than a day, so a named window has no list of turns and no hourly chart column. The costliest turns over a window are the turn list sorted by tokens (GET /turns?sort=-tokens), which reads the fleet’s event logs and reaches back as far as they do.

Settings › Token spend reads named windows only: 7, 30 or 90 company days (it opens on 30), or two dates on the company’s clock, so every figure is the company’s and every card names its window. A window the engine refuses is shown once, in the engine’s own sentence, with no figures under it. The two refusals differ with their fixes: a window longer than ninety days is told to narrow its dates wherever it lies; one starting behind the history’s floor is told the first day it may start on. See Dashboard design § Spend.

HistoryReaches backBounded by
Spend (named windows)181 daysThe usage domain’s history (spend_history_seconds on GET /health)
Turns, events, traces30 daysEach data node’s event log (event_history_seconds)

181: the longest window is 90 days, comparing it with the 90 before reaches back 180, and one more day covers a window cut on a clock that moved. A window whose first day (or whose previous window’s) is older than the floor is refused, naming what to change, rather than drawn short. Every answer states its horizon (days and floor, the oldest company day still answerable) so a screen can say where history ends.

Split by phase, the chart draws four bands, folded once by the engine so no screen folds a phase differently:

BandWhat spent it
ExecuteThe seat’s own turn doing its work: the executor, its harness’s own run in a box. What the run spent is recorded from the box once per launch (executor_collected), which names no phase and is filed here; the executor’s own record carries no tokens
ReviewThe reviewer’s pass over that work
WorkersThe short-lived workers an executor delegated tasks to
AuxiliaryEverything not the turn’s own work: the seats’ auxiliary model (turn-start context, compaction rewrites, reflection workers, background passes, a person’s answered questions), the round-cap judge, a busy seat’s wake triage and the first-turn onboarding

The other splits (model, provider entry, seat, unit, worker) draw the four biggest and fold the rest into one “other” band.

  • Worker is the auxiliary model’s spend by purpose (memory_filter, condense_thread, …). It is only part of the Auxiliary band, which also holds the round-cap judge, the first-turn onboarding and any phase a newer peer records (no purpose), so the Worker split sums to the band less those.
  • Provider answers “which configured entries are we paying for”, which model cannot: two entries can run one model (a subscription entry and an auth.mode: api-key entry for the same Claude model), and only the entry says which account paid.

Each seat names a cheap model, llm_auxiliary (falling back to its llm), for questions the engine asks on its behalf: what to remember, what to search for, how to fit a long text into a prompt. Every such call goes through one seam that charges the budget counter and records an auxiliary_spend event, which every spend figure folds (live window, named windows, a turn’s page, the turn list, a task’s spend). A turn’s call is charged through that turn’s own meter, the one its rounds use, so the turn knows of a window the call filled before its next round is sent.

Each call states its stage (whose cost it is) and its purpose:

StageWhat spent it (purposes)Charged toIn the turn’s cost and its task’s spend
turnThe turn-start memory filter, knowledge query and episode summary (memory_filter, knowledge_query, episode_summary); every rewrite the turn’s ledgers, judge, tools and delegated workers needed, and its card (condense_<kind>); and what its executor cost between two parts of the turn: its bridged tools and the condensing of a collected launch’s report or failure (condense_report, condense_tool_error); and the triage of a wake that reached the seat while its run worked, on the seat’s llm_triage chain (wake_triage, in the turn’s cost but not its task’s spend, since no part of the turn is open to pay it)the seat and the companyyes; the part that resumes from the executor pays for what it cost between parts
reflectionThe learning workers after the turn (persist_decider, counterparty_profiler, skill_synthesizer, skill_refiner)the seat and the companyno; drawn beside the turn in its Reflection lane: it is what the seat remembers, not what the work cost
backgroundThe episode compaction, clustered synthesis and skill promotion passes (episode_compaction, skill_clustering, skill_promotion), and the probe of a model entry at its usage limit when tried again, one per seat parked on it, charged to the parked seat it runs as (provider_probe)the seat and the company (the company alone for a unit a person leads)no, there is no turn
operatorA person’s question answered on the operator surface (answer_knowledge, and condense_source for a page too long to read whole)the company alone: a person has no seat budgetno, no turn

A compaction’s purpose names what it rewrote (condense_thread, condense_produced, condense_report), so a chat thread’s rewrite and an executor report’s are told apart.

A person is their own row. What the auxiliary model spends for a person (their questions, or a pass resolved on the chain of a unit they lead) names no agent seat, so per-seat breakdowns draw it as the person’s row (person: true), with no turns. It reaches the named windows as the usage domain’s person record, published with the rest of the node’s day.

Coalesced, a flush behind. A node’s ledger keeps one record per (stage, seat or person, turn, purpose, model, provider entry, company day) and publishes it every 15 seconds; a turn’s own records are also published before the turn’s end, and its reflection pass’s before reflection_completed, so a Turn page open while the turn ends asks again at each moment. A compaction of seventy rewrites is one record of seventy calls. The live window therefore trails the counter by up to one flush, a named window by up to two (the flush and the usage publisher’s own tick). Every figure’s calls are provider calls (a phase’s model rounds; an executor launch’s own turns as its harness reported them, one per launch where it reports none, as OpenCode; an auxiliary record’s coalesced calls), never records. The executor’s own record counts none, since its run’s calls are its launches’.

What is not counted: embeddings. Calls that turn text into vectors are metered by neither the counter nor the rollup: they run on the embeddings provider, not a seat’s model chain, and a token budget does not judge them. That bill appears at the embeddings provider, made of:

  • The corpus. The fleet’s embedding duty embeds changed pages and tasks, once for the fleet.
  • What a seat stores. A diary note and an episode are embedded as written, and the node holding a seat fills every note without a vector of the current model (after a change of providers.embeddings.model, the whole diary, up to 512 notes a minute per node).
  • What a turn recalls by. Each turn embeds its ask once at its start, for memory and episode recall, and refresh_memory and query_episodes embed their hint on each call.
  • Every knowledge or work search that ranks by meaning (semantic, or hybrid, the default, over Doclet and Worklet) embeds its query: the turn-start knowledge prefetch (beside its ask vector), search_knowledge, search_work_items, the retrieval behind answer_knowledge, the operator tools, and the API’s and dashboard’s search. A query vector is cached per node (1 024 entries, cleared when the model changes), so a phrase searched again soon costs nothing.

Why the counter and the rollup still differ

Section titled “Why the counter and the rollup still differ”

They count the same calls, so a gap is one of these, each of known size:

  • The flush. An auxiliary call reaches the rollup up to one 15-second flush after the counter (two for a named window); a phase record, the moment its phase ends.
  • A node that stopped hard. A dying process loses the auxiliary records it had not published: at most one flush, plus, if it dies while the broker is refusing them, every refused record held for retry, up to the 4 096 below. The counter holds that spend; the rollups are short by it.
  • A broker that refused records. A node keeps up to 4 096 unpublished records for its next flush (most of an hour of a busy company) and logs any it drops past that, with their tokens.
  • A charge that failed. A counter the node could not reach is short of that call; the record still reaches the rollup. A charge that reached the company’s counter and then failed on the seat’s keeps the call on the company and leaves only the seat’s counter short, logged as coord_kv_budget_spend_uncounted.

Beside turns and spend, a seat’s day counts what it did on Gitlet: the changes it opened, the reviews it gave, the findings it received (every finding a review raised on a change the seat owns, counted on the owner, whose day counts the review), and what the merge gate did to its changes: the checks that failed them and their ejections from a merge queue, each counted on the change’s owner. They are kept in the replicated usage domain with spend, for the same 181 days, and summed across every node.

FigureCounted whenOn whose day
changes_openedA change is opened, by a change tool, the API, or a push’s -o change optionsThe change’s owner, the seat that opened it
reviews_givenA review of a change landsThe seat that gave it
findings_receivedA review that raised findings landsThe seat that owns the change it judged, whoever reviewed it, a person included
checks_failedA check of a change’s head ends failing it (failed, or errored past the home’s own requeue: its third attempt, or an error its infrastructure did not cause), whether the engine ran it or a person’s CI reported it, which counts on the live change (open or draft) into its target at the commit reportedThe seat that owns the change, whoever pushed the head or reported the check
ejectionsA merge queue puts a change’s entry out (a check failed, a conflict, the gate no longer met, the head moved)The seat that owns the change, whoever queued it

Each is counted once, by the data node whose record landed it, from the change_opened, review_submitted, code_check_finished and code_queue_ejected events that node announces (see the event system), never once per data node and never again for a retried write the code log collapsed onto the first: a failed check once by its attempt, whatever corrections of its ending follow, and an ejection once by its queue entry. A person has no seat day: a change a person opens or a review a person gives is counted nowhere, though a person’s review still counts its findings on the seat whose change it judged. A change carries no spend of its own: its turns’ tokens are the seat’s spend.

The seat activity answer (GET /agents/activity, the seat_activity question in the API reference) returns changes_opened, reviews_given, findings_received, checks_failed and ejections over the window, and over the window before it when previous=true.

A seat’s day that counts any of them is usage record version 3, and one that counts failed checks or ejections version 4, so during a rolling upgrade a node on an older build keeps that day aside, unapplied, until upgraded; a day with none of them stays readable by every build.

Every figure carries the prompt cache’s share of its input: cache_read_tokens (served from the cache) and cache_write_tokens (stored into it). They are a breakdown of input_tokens, never an addition (the backend adds the harness’s reported cache counts into its input total), so the share of input a cache served is cache_read_tokens / input_tokens, and total_tokens is input plus output. A harness that reports no cache counts carries zero for both; one that reports no usage at all is charged an estimate, four characters a token, which crewlet llm doctor names on its token usage line.

The dashboard measures spend in tokens only. A price is reported only by an executor’s launch, in its harness’s own figure, and by no call on this host, so a currency figure would leave out every reviewer, worker and auxiliary call while reading as the company’s spend.