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

This commit is contained in:
hh
2026-09-01 15:37:53 +02:00
parent 3406e2e178
commit 63014a487d
6 changed files with 304 additions and 5 deletions
+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.