A Sessions poll copies every agent's list of ~20k files several times
(listedRollouts, heldFiles' clone, callFilesWith, allFiles, byKey,
statsRead). Each file was 232 bytes, most of it fields only OpenCode,
ZCode, Hermes, Alma, agy, Cursor's editor or WSL files fill. Those move
into fileMore behind file.more (nil when a file has none); reads go
through m(), writes through w(), which copies first, so copies of a file
never see each other's writes, as before.
A/B with the real ~/.codex and ~/.claude data (ab5.sh, 8 polls 15s
apart, alloc_space between heap-0 and heap-1), base f51ab771f vs this:
- sessionRoutes 848 MB -> 731 MB
- allFiles 426 MB -> 281 MB, heldFiles 322 MB -> 216 MB
- callFilesWith 199 MB -> 109 MB, byKey 86 MB -> 56 MB
- statsRead 467 MB -> 375 MB, listSessions 456 MB -> 352 MB
- all HTTP handlers 1422 MB -> 1379 MB; the profile's total rose
(2392 -> 2570 MB) in usage's ledger reads, a package this doesn't
touch, on live data that grew between the runs.
Footprint was not compared: a GUI suite and Go tests ran beside it.
Run before the rebase, at f51ab771f plus this change:
go test -timeout 45m ./internal/sessions/... ./internal/gui/
./internal/usage/... ./internal/cli/ ./internal/tui/ ./internal/otlp/
./internal/tune/ ./internal/agent/ ./internal/gateway/: all ok.
Run at the pushed head (rebased on 6a6c06868, which touches no
sessions file): go test ./internal/sessions/... ok; gofmt clean;
GOOS=linux, windows, darwin go vet -tags nogui ./internal/sessions/
./internal/gui/ ok; the whole tree vetted on all three before the rebase.
Not run: the GUI JS suite (no GUI file changes).
What changed
- traceOpenCodeWindow keeps the latest main sessions. A child is not
exported, so it no longer takes one of the Limit places. Limit newer
children were filling the window and the parent was not read. The JSON
store and the SQLite store share that window.
Run
- TestOpenCodeChildrenDoNotEvictParentTrace failed on a15e576 plus the
test (sqlite and json: parent dropped behind 200 newer children, no
spans) and passes with the window. go test -tags nogui -count=1 -p 2
./internal/sessions/ passed in a sandbox home (648s). gofmt -l on the
three files printed nothing. go vet -tags nogui and go build -tags
nogui with CGO_ENABLED=0 passed for windows, linux and darwin.
- Not run: the rest of the module, -race, a real OpenCode database, or
a Langfuse server.
Full suite: go test -tags nogui -timeout 45m ./... (pipefail, suite-lock) at the four #2494/#2504/#2505/#2490 commits on origin/main a751f5282: 65 packages ok, among them internal/agent (2124s), internal/gateway (1845s) and internal/sessions (148s). internal/gui was red on TestSetAnswersWhileDevinAndProvidersHang alone (the state after a set took 11.5s at load ~250; #1375); internal/gui run again alone: ok (206s).
Generated-by: Grok 4.7 (Cursor)
OpenAI bills gpt-6-astra, gpt-6.1-sol and gpt-6-luna over 272K input at 2× input and cache and 1.5× output, for the whole request. A price now has tiers: `magpie model price <m> 10,50,1,12.5 --tier 272k 20,75,2,25` (--tier can repeat). A tier applies when input + cache reads + cache writes is over its size, so 272,000 is not over and 272,001 is. The built-in prices take tiers only where models.dev lists one (cost.tiers of type "context"), and it does list one for those three. The ledger, each request and OTLP are costed at the tier the call reached. Session and day totals sum many calls, so they stay at the base price.
Anthropic bills a cache write kept for an hour at 2× input and one kept for 5 minutes at 1.25×. Its usage reports which is which in cache_creation.ephemeral_5m/1h_input_tokens. The gateway (API and Claude subscription) and Claude Code's transcripts now keep that split. A price's fifth part is the 1-hour write. When it isn't given, it is 2× input: that is Anthropic's rule, and only Anthropic reports 1-hour writes. Claude list prices carry the 2× too. cache_write_tokens is still the total, and the usage CSV adds cache_write_5m_tokens and cache_write_1h_tokens at the end. The app shows the split on a request's Cache and on the usage tooltips. Old prices and old records, which have no 1-hour part, read as before. The sessions cache (18) and the call cache (calls-v8) are re-read once.
In the GUI, the price boxes were number inputs and dropped what they didn't parse ("0,25"). They are now decimal text boxes that take both "0.25" and "0,25". A model's price row has a 1-hour box (empty means 2× input) and a quiet Long-context price row. That row shows the list's tier greyed in, or sits behind a link when the list has none. A bad size is refused by name. en/zh/ja/de.
Tests:
- New: TestPriceTiers, TestCostSplit, TestPriceJSON, TestModelPriceTiers, TestModelPriceTierCmd, TestAnthropicCacheWriteSplit and TestClaudeCacheWriteSplit. The ledger CSV test expects the new columns.
- model-price-tiers.test.cjs is new; model-price-edit and provider-price-rate are updated. All of them fail against the old assets and pass in WebKit. Chromium couldn't be launched here.
- go vet, go build (darwin, GOOS=linux nogui, GOOS=windows) and go test -tags nogui ./... under a temp HOME pass.