Skip to content

Account for cache writes and long-context pricing - #253

Merged
qduc merged 3 commits into
mainfrom
codex/cost-cache-tiers
Nov 11, 2026
Merged

qduc merged 3 commits into
mainfrom
codex/cost-cache-tiers

Conversation

@qduc

@qduc qduc commented Nov 11, 2026

Copy link
Copy Markdown
Owner

Cache creation was dropped from native Luna usage, and estimates ignored long-context price tiers. This understated benchmark costs: replaying 54 Luna responses changes the recorded estimate from $0.044146 to $0.045987; 79 Haiku responses change from $0.166045 to $0.718036, including context tiers.

Preserve aggregate and one-hour cache writes through adapters, core budgeting, persisted facts, session totals and displays. Canonical input includes reads and writes; normalized prompt excludes separately counted creation, so totals and charges include each token once. Raw chat usage is normalized idempotently. Share TUI normalization with the common implementation.

Carry whole-request pricing tiers with strict input thresholds and explicit native Anthropic one-hour rates. The generated catalog preserves all 470 existing model capacities and base rates while adding 94 tiers and 17 one-hour rates; snapshot provenance is documented. Provider-reported charges remain authoritative, and existing per-dimension micro-dollar rounding is retained.

Depends on qduc/agent-runtime#8. Until an owner package containing that change is published, use an owner-derived temporary patch that also preserves the existing 500k fallback. Removal conditions are documented. No packages were published; historical accepted cost facts are not rewritten.

Validation:

  • Five real CLI/HTTP fixture cases covering Responses, chat, tier boundaries and mixed cache TTLs.
  • 133 recorded native responses replayed through actual adapters and core accounting, matching independently calculated rounded costs.
  • Eleven independent billing controls and packed-core smoke checks.
  • Build, typecheck, targeted lint/formatting, architecture and complexity guards passed; all nine existing parity goldens matched without changes.
  • Rebased onto current main, including the merged Haiku fix and Luna projection extraction; typecheck, formatting and complexity guards passed again.

Seven per-file size exceptions document their local rationale and retirement conditions; global limits are unchanged. Independent review covered billing behavior and the exceptions. Cost estimates remain estimates rather than invoices.

@qduc
qduc marked this pull request as ready for review November 11, 2026 14:56
@qduc
qduc merged commit 6aec666 into main Nov 11, 2026
8 checks passed
@qduc
qduc deleted the codex/cost-cache-tiers branch November 11, 2026 14:57
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