Skip to content

Usage ​

Usage is what the model calls, harness turns, and browse calls of a guild's agents have consumed: tokens, cost in US dollars, and the number of calls. Every model reply in a run records its own tokens and cost, every subscription agent's turn its tokens on its reply, and every browse call its own. Those numbers are also added to running totals for the agent, its guild, its organisation, and the whole instance.

Usage is a record, not a budget. Core never stops a run because of what it costs. Who pays for a call is the concern of the model credentials an extension plugs in (Model keys).

Why it exists ​

Agents call models on their own, many times a day. The operator needs to see what each agent costs, which guild spends the most, and what the organisation spent this month.

How it works ​

Cost of one reply ​

Each model reply stores its token counts: input, output, and cache reads (the part of the input the provider served from its cache). Its cost comes from the provider when the provider reports one. Otherwise it is computed from the model catalog's prices, with cache reads at the cache-read rate. A model with no catalog price records a cost of 0, marked unavailable. A provider that is not billed, the local endpoint, has no catalog price.

Cost of a harness turn ​

A subscription agent's turn runs on the operator's own subscription, which charges no price per token. Its harness reports the tokens the turn spent over every model call it made, and the turn's reply records them, a cost of 0, marked subscription (Harness turns). A turn that ends before its CLI reports the whole turn, such as one cancelled, timed out, or lost at a restart, records instead the tokens of the model calls the CLI reported while it ran, marked as partial: a floor of what the turn spent. A turn whose CLI reported neither, as Codex and Cursor report nothing before their turn's end, records no tokens and says so. The reply counts in the totals as one call when it records tokens. No price is computed and the usage callback is not called.

Running totals ​

Each reply with usage, and each browse call, adds to five totals at once:

The totals count since each scope was created. Deleting an agent drops its own total; its guild, organisation, and instance totals keep what it spent. Deleting a guild drops the guild's total and its agents'; the organisation and instance totals keep them.

Model calls of the Prompt Studio coach and of the Guild builder belong to no agent. They count in the organisation, monthly, and instance totals only. The Studio coach and the Builder each show as a row of their own.

Browse calls ​

A browse call drives a web page through a browsing service, which spends tokens of its own and of the model it drives the page with. Its tokens, cost, and call count are kept apart from model calls, and its cost is also part of the total cost. A browse call that is cancelled or stops at its time limit records no browser usage.

For extensions ​

After every model completion, core reports the run, the model, the tokens, the cost, and where the cost came from to the model credentials' usage callback, when one is set. A failing callback is logged and never fails the run (Extension points).

In the app ​

  • Agent › Usage: the agent's totals since it was made, across every session: Cost, Model calls, Input tokens, Output tokens, Total tokens, and Cache reads, and Browser with its cost and call count once a browse call was counted, with when it was last counted. A line says the cost is what the provider reported, or the catalog rate when it reported none. Total tokens are input plus output; cache reads are counted apart. The same tab shows the disk the agent's home and its machine use (Agent home).
  • Guild › Usage: the guild's totals, the same figures, then each agent with its model calls, tokens, and cost. A name opens that agent's Usage tab. A line says deleted agents' spend stays in the organisation's usage.
  • Settings › Usage: the organisation's totals, then each guild and its agents with calls and cost, and their browser calls and cost when there are any. The Studio coach and the Builder each have a row, and so does Deleted guilds and agents: what the organisation's total holds beyond the rows listed.
  • The run flow in a run's transcript shows the tokens and cost of each step and of the whole generation, and a reply its own. A harness turn's partial tokens read at least, and a turn with none tokens not reported (Run transcript).

Rules and limits ​

RuleValue or behaviour
Spend gate in corenone
Cost sourcethe provider's reported cost, else the catalog price, else 0 marked unavailable; a harness turn 0 marked subscription
Browse callscounted apart from model calls; their cost is part of the total cost
Cache readspriced at the cache-read rate; part of input tokens
Total tokensinput plus output
Counted fromeach scope's creation
Deleting an agentdrops its own total; parent totals keep its spend
Deleting a guilddrops the guild's and its agents' totals; organisation and instance keep them
Monthly totalsper organisation, by UTC month
Usage callback failurelogged; the run goes on

Reference ​

Per message ​

Each assistant row with usage stores:

  • metadata.usage: input_tokens, output_tokens, cache_read_tokens, and cache_write_tokens where the source reports cache writes, which the counters do not keep; the cache's reads and writes are part of input_tokens;
  • metadata.cost_usd;
  • metadata.cost_source: provider, catalog, unavailable, or subscription for a harness turn;
  • on a harness turn's reply, metadata.usage_extent: complete for the CLI's report of the whole turn, partial for the tokens of the model calls it reported before the turn ended without that report, or none, with no metadata.usage, when it reported neither;
  • metadata.pricing_version, the catalog's date, whenever the provider reported no cost;
  • messages.cost_usd, a column for accounting queries.

Each tool row of a browse call stores metadata.browser_usage: model, the browsing service's jev_input_tokens, jev_output_tokens, and jev_cost_usd, the driving model's llm_input_tokens, llm_output_tokens, and llm_cost_usd, and their sum cost_usd, which is also its messages.cost_usd. messages.cost_usd is NULL on system and user rows and on every other tool row.

Counters ​

The same insert increments rollup counters in usage_counters, one row per (scope, scope_id):

Scopescope_id
agentthe agent id
guildthe guild id
orgthe organisation id
globalempty: the instance as a whole

Each counter holds input_tokens, output_tokens, cache_read_tokens, cost_usd, calls, browser_input_tokens, browser_output_tokens, browser_cost_usd, browser_calls, and updated_at. A model reply adds its tokens and cost and one to calls. A browse call adds its jev and llm tokens to the browser token columns, its cost to both browser_cost_usd and cost_usd, and one to browser_calls, leaving calls as it is. org_monthly_usage holds the same figures per (org_id, month), the month being the UTC YYYY-MM. It also counts studio_builder_runs, the Studio coach and Builder generations of the month, which the organisation policy's monthlyCoachRuns caps. Core sets no cap.

Deleting an agent deletes its agent counter row and its messages. Deleting a guild deletes its guild counter row and its agents'. Parent totals stay.

Studio coach and Builder calls increment the org and global counters and org_monthly_usage, not an agent or guild counter. The organisation listing's studio entry is summed from the organisation's Studio session messages, and its builder entry from its Builder session messages, null when the Builder has spent nothing. Its archived entry is the organisation total minus the listed guilds, studio, and builder, each figure floored at zero, and null when nothing is left. It therefore holds deleted guilds and agents, and guilds the caller cannot see.

HTTP ​

RouteReturns
GET /api/agents/:id/usagethe agent's totals, workspace_mib, max_workspace_mib, and its machine with its own disk figures
GET /api/guilds/:id/usagethe guild's totals and agents, each with its totals
GET /api/usage{ organisation }: the current organisation's totals, studio, builder, archived, and guilds with their agents, limited to the guilds the caller can see

Each set of totals carries input_tokens, output_tokens, cache_read_tokens, total_tokens, cost_usd, calls, browser_input_tokens, browser_output_tokens, browser_cost_usd, browser_calls, and updated_at (null before the first call). total_tokens is model input plus output.

Usage callback ​

ModelCredentials.onUsage(usage) is called once per completion with { run_id, model, usage: { input_tokens, output_tokens, cache_read_tokens }, cost_usd, cost_source }. Core keeps no spend gate.

Code ​

  • apps/orchestrator/src/usage/index.ts: counters, totals, the usage tree
  • apps/orchestrator/src/llm/cost.ts: catalog pricing
  • apps/orchestrator/src/browse/cost.ts: a browse call's browser_usage
  • apps/orchestrator/src/llm/credentials.ts: onUsage
  • apps/orchestrator/src/usage/view.ts: the organisation, guild, and agent listings

Free software under the GNU Affero General Public License, version 3 only.