Skip to content

feat(kin): the Usage page shows the day's cache read share and cost per turn - #1096

Merged
GLDRoger merged 6 commits into
kinfrom
train-18-1129/step-5
Nov 29, 2026
Merged

GLDRoger merged 6 commits into
kinfrom
train-18-1129/step-5

Conversation

@GLDRoger

Copy link
Copy Markdown
Owner

The owner sets two rules for Kin's agents: turns read at least 98% of their input from the model's cache, and the cost per turn is always known. Neither number is visible anywhere.

  • The host computes an owner-only daily figure, through the RPC kin.host.cacheDaily:
    • the share of turn input read from cache;
    • carried and fresh turns, with the reason for each fresh start;
    • the cost per turn at Usage's prices, counting each budget charge once;
    • what keeping the cache warm cost.
  • Usage on web, desktop and phone opens with "Kin today" and "Kin yesterday", in the owner's time zone. One shared function turns the figure into words. A missing figure reads "not available", never 0% or $0, and an unknown reason code reads "other".
  • Turns that sent nothing are not counted. A failed turn's spend still counts. Keep-warm writes are priced at the one-hour rate.

People-change: The owner sees two lines on the Usage page: how much of Kin's input came from the cache today and yesterday, what a turn cost, and why sessions started fresh.

Checked as part of train 18's one check at the tip.

An independent review by Claude Opus 5.5 found it LANDS AFTER FIXES, and its fixes are on this branch.

🤖 Generated with Claude Code

GLDRoger and others added 6 commits November 29, 2026 15:38
Count completed turns, fresh starts and upkeep on the owner's local day.
Price the metered totals with Usage's settings and rate table, expose the
figure only to the owner, and log yesterday's figure once per day.

T3-file: apps/server/src/ws.ts: Supply the existing Usage service to the Kin handler.
T3-file: apps/server/src/usage/UsageService.ts: Share the live pricing settings and rate cache without starting a transcript scan.
T3-file: apps/server/src/usage/UsageService.test.ts: Verify changing the Usage price changes the aggregated estimate by the same amount.
T3-file: apps/server/src/usage/usagePricing.ts: Reuse the request rate arithmetic for aggregated ledgers without treating a day as one request.
People-change: The owner host records daily cache reads, fresh starts and upkeep costs. No screen changes yet.
Co-Authored-By: GPT-6.2 Sol <noreply@openai.com>
Today's and yesterday's Kin cache figure sits at the top of Usage on web,
desktop and phone, for the owner only. One shared function turns the host's
figure into words: the read share, cost per turn, turns, fresh starts with
their reasons in plain words, and what keeping the cache warm cost. A missing
figure reads "not available", an unknown reason counts as "other".

People-change: The owner sees two lines on the Usage page: how much of Kin's input came from the cache today and yesterday, what a turn cost, and why sessions started fresh.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… they happened

A wake-up that finished before starting a model run (routine content with
nothing new, dropped events) was counted as a turn and, having no ledger, made
the whole day's cost per turn unavailable. A turn that ran and then failed or
timed out was dropped entirely, though its spend was charged. Every cache write
was priced at the five-minute rate although Kin's owner seat and its keep-warm
requests write the one-hour cache (2x input, not 1.25x). And a day whose
midnight is skipped by a clock change ran an hour into the next day, so that
hour counted twice.

Turns are now completed wake-ups that started a run; a failed run's tokens and
charges count toward spend and the share but not the turn count; writes the
adapter recorded with an hour's lifetime, and every keep-warm write, are priced
at the hour's rate; and a day ends where the next one starts.

People-change: the owner's Usage line no longer reads "cost per turn not
available" on days with a routine that had nothing new, and its "about $X a
turn" now includes failed turns' spend and the one-hour write price.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The session carry branch stores five reasons the Usage line had no label for
(summary, cold_large, unseen, rules_overflow, no_file), so they would read as
"other". Each now has a short plain label, with the table test extended.

People-change: the owner's Usage line names these fresh starts instead of
counting them as "other".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…urn on web and phone

Joins feat/kin-cache-daily-figure and feat/kin-cache-daily-line as one step.

People-change: none

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
People-change: none

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@GLDRoger
GLDRoger merged commit 9cd6fc6 into kin Nov 29, 2026
14 of 17 checks passed
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-29T15:35:36.121469Z b0caa7d PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Copy link
Copy Markdown
Owner Author

Ein is commenting on behalf of Nishchay.

Server 4 is red at apps/server/src/auth/RpcAuthorization.kin.test.ts:27. The joined kin assertion still expects every kin.* method except kin.refreshes.announce to be on the chat-only grant. kin.host.cacheDaily is intentionally absent: it needs diagnostics read plus the org owner role. Please update the inventory expectation and its comment to include that explicit exception, retain the denial and owner-role checks, and rerun Server 4 on the joined tip. No runtime permission widening is needed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant