Expand description
What each agent has used through the gateway today, counted from the usage in each response times
the route’s price table. The live table is in memory; once attach has been called every change is also
written to the history store (storage::spend_day) and the last two days are read back at start, so an srv
restart does not start the day again. The day is the UTC day.
Structs§
Functions§
- agents_
today - The agents that have a day of spend today.
- alerted
- The highest alert level (0, 50, 80 or 100) already sent for the agent’s day.
- attach
- Keeps the day’s table in
storefrom now on: reads the last two days, then writes each change from a thread of its own. - cost
- The cost of
tokensonmodel: a cached read at the cache price, the rest of the input at the input price. - record
- Adds one response to the agent’s day on
routeand returns that response’s cost: the provider’s own charge when the response reported one (actual), else the price table’s estimate. - reset_
session - Clears
agent’s provider-reported session total: a new process (spawn, restart, resume) starts its own, as the harness’s own total does. - reset_
today - Zeroes the agent’s day (a spend that was wrong): its rows are removed, here and in the store. Returns the dollars that were counted.
- restore
- Reads the last two days back from
storeinto the live table, keeping what the table already holds. Returns the number of rows read. - rewrite_
result_ total line, a JSON frame from the harness, with a route agent’sresulttotals replaced by the provider’s own charge: the harness prices its tokens with Claude’s rates, which on a route are wrong by orders of magnitude (#30143).total_cost_usdbecomes the session total, which the turn ledger takes the rise of;cost_usdbecomes this turn’s rise, because the pane adds each frame’s value to its running total.Nonewhen the line is not aresultframe, reports no total, or the agent is not on a route (none of its responses carried a charge).- route_
today_ usd - What every agent has spent on
routeso far today. - session_
usd - The provider-reported spend for
agentsincereset_session, orNonewhen none of its responses reported a charge (the agent is not on a route). - set_
alerted - Records the alert level sent for the agent’s day, on each of its rows so it survives a restart. A raised cap sets it back down to where the day now stands.
- today
- The agent’s use so far today, over every route it used.