Repository navigation
Preserve cache creation usage and context price tiers - #8
Merged
Merged
Conversation
qduc
marked this pull request as ready for review
November 11, 2026 14:48
This was referenced Nov 11, 2026
qduc
added a commit
that referenced
this pull request
Nov 11, 2026
Carries the two changes merged since alpha.2: the 500,000-token unknown-model context assumption (#7) and cache-creation usage with whole-request price tiers (#8). Term2 currently applies both as a pnpm patch over alpha.2; publishing this version lets it pin the release and drop the patch. Claude-Session: https://claude.ai/code/session_01JqbJBBoCXgqyyFZaYn5Co4 Co-authored-by: Claude <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.
Cache creation is currently lost at the public Usage/accounting boundary, and catalog estimates cannot select whole-request context pricing. Consumers cannot fix this solely in their provider adapters.
Add optional aggregate and one-hour cache-write counters to Usage and preserve them in normal and compaction cost records. Usage.inputTokens remains inclusive of reads and writes; normalize once to prompt_tokens excluding separately billed creation so writes are not double charged. Existing models omitting the new counters retain their old shape and behavior.
Add whole-request CatalogPrice tiers selected by total input, including reads and writes, with strictly exceeded thresholds and explicit one-hour pricing. Unknown creation prices remain unpriced, explicit zero rates remain free, and provider-reported charges retain precedence. Preserve per-dimension integer-micro rounding.
Validation: core build/typecheck; packed-tarball smoke covering runtime imports, two isolated concurrent turns and public TypeScript declarations; 11 independent billing controls for thresholds, write-only input, mixed TTLs, missing/free rates, invalid subsets and provider-charge precedence. Consumer validation replays 54 native Luna and 79 Haiku responses through actual adapters and TurnBudgetControl.record, matching usage dimensions and independent rounded costs. CI validate passes.
Consumer integration: qduc/term2#253 carries the app integration and temporary owner-derived patch until publication. No packages were published.