Skip to content

Preserve cache creation usage and context price tiers - #8

Merged
qduc merged 1 commit into
mainfrom
codex/cost-cache-tiers
Nov 11, 2026
Merged

qduc merged 1 commit into
mainfrom
codex/cost-cache-tiers

Conversation

@qduc

@qduc qduc commented Nov 11, 2026 •

Copy link
Copy Markdown
Owner

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.

@qduc
qduc marked this pull request as ready for review November 11, 2026 14:48
@qduc
qduc merged commit 9ce958d into main Nov 11, 2026
1 check passed
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant