fix(storage,api): usage cost as per-turn delta of the sdk running total, backfill

This commit is contained in:
hh committed 2026-09-01 15:37:53 +02:00
1 parent a8491330fa
commit 90063a7cfe
6 files changed
+304 -5

No files matched your search

+4 -3
View File
@@ -6,9 +6,10 @@ write goes through ``core/conversations``; the frontend only shapes JSON.
bus as SSE with the same keepalive the markdown frontend uses, so a proxy
never sees a silent socket.
Usage figures come from the ``usage`` table (one row per turn, API-price
``cost_usd`` and per-model ``model_usage`` from the SDK's
``ResultMessage``); subscription quotas come from ``rate_limits``
Usage figures come from the ``usage`` table (one row per turn; API-price
``cost_usd`` and per-model ``model_usage`` are per-turn deltas of the SDK's
cumulative ``ResultMessage`` counters, see ``storage.append_usage``);
subscription quotas come from ``rate_limits``
(``RateLimitEvent``). The quota covers the whole subscription, so
``/api/limits`` puts the gateway's own spend for the window next to it
for calibration by eye.