[PR #4746] [Engine] serve: print what the counted tokens would have cost at your own prices #5158

Open
opened 2026-11-07 16:33:08 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/4746
Author: @au70ma70n
Created: 10/30/2026
Status: 🔄 Open

Base: main ← Head: engine-plain-cost-pricing


📝 Commits (3)

  • 145e349 [GUI] settings: let a long help line wrap instead of squeezing every field
  • 419a478 [Engine] serve: keep the Monitor's token counts between starts
  • 0b7d7d9 [Engine] serve: print what the counted tokens would have cost at your own prices

📊 Changes

7 files changed (+377 additions, -6 deletions)

View changed files

📝 docs/DETAILS.md (+12 -1)
📝 serve/runconfig.py (+4 -0)
📝 serve/server.py (+136 -1)
➕ serve/test_totals.py (+189 -0)
📝 serve/web/app.css (+7 -2)
📝 serve/web/app.js (+28 -2)
📝 serve/web/index.html (+1 -0)

📄 Description

Draft — the costing story wants scope agreement first: #4742. It lands after #4745 (it prices the counts that PR keeps between starts); merge order is #4743 → #4745 → this one → #4747, and until the branch before it merges this pull request's diff also shows those commits and shrinks on its own as they merge.

Branch engine-plain-cost-pricing, base main.

Problem and result

The Monitor counts tokens and says nothing about what they would have cost. Strata charges nothing of its own — the hardware is already bought — so a dollar figure only means what an API would have asked for the same work. After: two prices, cost_input_per_million and cost_output_per_million, editable in the page's Settings view and overridable for one start with --cost-in and --cost-out, read when the server starts like every other setting. /metrics totals carry the rates and cost_usd; /metrics/prometheus gains the counter strata:cost_usd. The Monitor's state card gains one short line — the cost first, then what the model was given, what the cache already held, and what it returned, with the date the counting began — narrow enough for a phone, while the sentence under the request table still gives the same counts in full and serves as that line's tooltip. With no price set, no figure is printed rather than a $0.00 that would read as a model that works for free.

#4742 — the one scope issue opened for the costing story (this pull request, #4745 which keeps the counts it prices, and #4747 which splits the price); it waits on a maintainer's yes.

Approach

The server does the arithmetic and sends the rate each kind of token is paid at, so a page never multiplies and never needs to know a price. A price in the config that is not a number is reported once at start and treated as no price at all, because a bad setting must not cost a start. A flag wins over the config for one start. The long sentence's wording moved from "prompt tokens read … written" to "input tokens read … output tokens", so the sentence names the parts the prices name. The example the tests hold: $5 per million in and $25 per million out prices 2,000,000 read and 100,000 written at 2 × $5 + 0.1 × $25 = $12.50.

Validation

Passed: serve.test_totals on this branch's tree (which also carries #4745's commits) — the 8 tests that are this PR's: Cost.test_no_price_means_no_cost, Cost.test_a_million_tokens_costs_its_price, Cost.test_the_response_carries_the_prices_and_the_cost, Cost.test_the_cost_covers_every_start_the_file_remembers, and PriceSettings.test_both_prices_are_editable_from_the_page, test_a_price_set_from_the_page_is_written_and_read_back, test_only_a_price_of_at_least_nothing_is_a_price, test_the_two_prices_travel_with_their_own_name_only. Environment as in #4745's Validation (Windows 11 NT 10.0.26200, Python 3.10.11, no GPU and no downloads, at 870aedd9 + these changes).

Failed: none observed.

Not run: a live screenshot of the new state line with an API key present (see #4743's note on the headless profile); the app's npm test (no node here); the Terminal suite (no pytest).

Limits

One currency (US dollars), no exchange rate, one flat price per million; a changed price works from the next start, not mid-run; strata:cost_usd is a counter over the window #4745 keeps, so it grows across starts and restarts on --totals-reset.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/4746 **Author:** [@au70ma70n](https://github.com/au70ma70n) **Created:** 10/30/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `engine-plain-cost-pricing` --- ### 📝 Commits (3) - [`145e349`](https://github.com/Niko1221/Strata/commit/145e349444f39c6c7dae300f40a15223098e173b) [GUI] settings: let a long help line wrap instead of squeezing every field - [`419a478`](https://github.com/Niko1221/Strata/commit/419a4784aff7e76b94799ee19e9e29342bb58b05) [Engine] serve: keep the Monitor's token counts between starts - [`0b7d7d9`](https://github.com/Niko1221/Strata/commit/0b7d7d9a54e375945f9b6e8e13b8aa47018e3740) [Engine] serve: print what the counted tokens would have cost at your own prices ### 📊 Changes **7 files changed** (+377 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `docs/DETAILS.md` (+12 -1) 📝 `serve/runconfig.py` (+4 -0) 📝 `serve/server.py` (+136 -1) ➕ `serve/test_totals.py` (+189 -0) 📝 `serve/web/app.css` (+7 -2) 📝 `serve/web/app.js` (+28 -2) 📝 `serve/web/index.html` (+1 -0) </details> ### 📄 Description Draft — the costing story wants scope agreement first: #4742. It lands after #4745 (it prices the counts that PR keeps between starts); merge order is #4743 → #4745 → this one → #4747, and until the branch before it merges this pull request's diff also shows those commits and shrinks on its own as they merge. Branch `engine-plain-cost-pricing`, base `main`. ## Problem and result The Monitor counts tokens and says nothing about what they would have cost. Strata charges nothing of its own — the hardware is already bought — so a dollar figure only means *what an API would have asked for the same work*. After: two prices, `cost_input_per_million` and `cost_output_per_million`, editable in the page's Settings view and overridable for one start with `--cost-in` and `--cost-out`, read when the server starts like every other setting. `/metrics` totals carry the rates and `cost_usd`; `/metrics/prometheus` gains the counter `strata:cost_usd`. The Monitor's state card gains one short line — the cost first, then what the model was given, what the cache already held, and what it returned, with the date the counting began — narrow enough for a phone, while the sentence under the request table still gives the same counts in full and serves as that line's tooltip. With no price set, **no figure is printed** rather than a `$0.00` that would read as a model that works for free. ## Related discussion **#4742** — the one scope issue opened for the costing story (this pull request, #4745 which keeps the counts it prices, and #4747 which splits the price); it waits on a maintainer's yes. ## Approach The server does the arithmetic and sends the rate each kind of token is paid at, so a page never multiplies and never needs to know a price. A price in the config that is not a number is reported once at start and treated as no price at all, because a bad setting must not cost a start. A flag wins over the config for one start. The long sentence's wording moved from "prompt tokens read … written" to "input tokens read … output tokens", so the sentence names the parts the prices name. The example the tests hold: $5 per million in and $25 per million out prices 2,000,000 read and 100,000 written at 2 × $5 + 0.1 × $25 = **$12.50**. ## Validation **Passed:** `serve.test_totals` on this branch's tree (which also carries #4745's commits) — the 8 tests that are this PR's: `Cost.test_no_price_means_no_cost`, `Cost.test_a_million_tokens_costs_its_price`, `Cost.test_the_response_carries_the_prices_and_the_cost`, `Cost.test_the_cost_covers_every_start_the_file_remembers`, and `PriceSettings.test_both_prices_are_editable_from_the_page`, `test_a_price_set_from_the_page_is_written_and_read_back`, `test_only_a_price_of_at_least_nothing_is_a_price`, `test_the_two_prices_travel_with_their_own_name_only`. Environment as in #4745's Validation (Windows 11 NT 10.0.26200, Python 3.10.11, no GPU and no downloads, at `870aedd9` + these changes). **Failed:** none observed. **Not run:** a live screenshot of the new state line with an API key present (see #4743's note on the headless profile); the app's `npm test` (no node here); the Terminal suite (no pytest). ## Limits One currency (US dollars), no exchange rate, one flat price per million; a changed price works from the next start, not mid-run; `strata:cost_usd` is a counter over the window #4745 keeps, so it grows across starts and restarts on `--totals-reset`. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#5158
No description provided.