Repository navigation
fix(agent-usage): preserve mixed price versions in usage bills - #168
Merged
Merged
Conversation
239573049
added a commit
that referenced
this pull request
Dec 1, 2026
The per-day store (one segment file per day plus a manifest) replaced the single usage-snapshot.json, so the two upstream fixes are re-applied on top of it: - #168: a row priced from the table keeps one price version; tokens recorded at another version mark it "mixed" (no single snapshot price), the snapshot meta turns mixed as rows are recorded, and bill rows merge versions the same way. Segments store a mixed row's missing price apart from a model without a price. - #171: rows inside a day are indexed by the encoded [cwd, agent, model] tuple, so directories and model names with '|' never merge two rows; a version 1-2 snapshot's pipe-joined keys are split the same way #171 does. Migrating a version 1-2 snapshot now keeps every row as it was (no recount, no reprice), Claude rows included, and leaves the old file untouched so a rollback to a version that only reads it resumes from a consistent state. Claude replies are counted once per message id from the upgrade on. The #171 tests read the per-day store instead of the old file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #165.
Two 100,000-input-token requests priced at $10/M and $30/M should still total $4, but a new bill must not attribute all $4 to the first catalog. This fixes the price label; it does not reprice history on refresh.
history.jsnow compares the incoming estimate's source and sync time at the point where it is recorded. A row that spans versions staysmixedafter serialization and after per-directory rows are merged for billing.bill.jsuses the selected rows' versions when available. A mixed CSV row hasprice_source=mixedand an emptyprice_synced_at; the HTML receipt labels it a multi-version snapshot. Single-version rows retain their timestamps. Older rows without their own version still use unambiguous snapshot metadata.Verification
On unmodified
main@3742ff6, the two new Jaunt regression cases both failed: with the second request in the same directory the snapshot returnedmixed=false; in a different directory the snapshot was mixed but the merged CSV row was not. The plugin and test sources did not change between that baseline and39a8b4f.On
main@39a8b4fplus this patch, macOS 27.2.1 arm64, .NET SDK 10.0.403:dotnet test tests/Octopus.Plugins.Jaunt.Tests/Octopus.Plugins.Jaunt.Tests.csproj -c Releasepassed 56/56 (0 skipped). The tests use the real plugin modules, file access, Jaunt engine and a local synthetic price catalog. Also checked filtered bills and older metadata-only rows against the bill renderer. No desktop UI or full-solution run. The existing SQLite restore warning is tracked in #129.Impact and compatibility
This affects users of the built-in Agent Usage history and bill exporter on any desktop platform. No schema migration or rewrite of saved bills. An old snapshot that already lost its second price version cannot reconstruct it retrospectively; explicit re-estimation remains available.