Skip to content

Add observed quota API-equivalent estimates - #13

Merged
merefield merged 4 commits into
mainfrom
agent/quota-api-equivalent
Aug 13, 2026
Merged

merefield merged 4 commits into
mainfrom
agent/quota-api-equivalent

Conversation

@merefield

@merefield merefield commented Aug 13, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • add a model-aware observed API-equivalent estimate to every Quota presentation
  • show both the inferred value consumed in the current primary Codex window and its inferred 100% capacity
  • report an integer-rounding range, sample count, and conservative LOW/MED confidence
  • show the pricing retrieval date and official source hyperlink responsively on every pricing-bearing Quota and Benchmark view
  • keep evidence process-local, account-isolated, bounded to 12 samples per window, and never persist it
  • bump the maintained source version to v0.7.1

Method

Codexometer prices newly completed local model calls from content-free rollout telemetry. It uses the requested model durably stored in each turn context and prices ordinary input, cached input, cache-write input, and output separately. Current rollout files do not persist transient server-side model reroutes, so the implementation and documentation no longer claim they can be reconstructed.

Each refresh reads cumulative local accounting immediately before and after the account quota request. If any priced-cost, priced-call, or unpriced-call counter changes, the observation is deferred rather than pairing asynchronous telemetry with the wrong quota snapshot.

For each primary codex window, a sample requires at least five clean displayed percentage points without a reset, counter regression, unpriced call, or local coverage gap. The central capacity estimate is observed API-equivalent cost × 100 / percentage movement; bounds use movement ± 1 to represent the quota API's integer granularity. Current spend-equivalent is the capacity range multiplied by the current used percentage.

Additional/model-specific rate limits display LIMIT ATTRIBUTION UNKNOWN: the rate-limit response does not expose enough information to assign aggregate local model costs safely to those buckets.

Safeguards and privacy

  • confidence remains LOW until at least three samples span 15 percentage points and both their rounding ranges and central capacity estimates have acceptable spread
  • confidence is capped at MED because another machine, client, cloud task, or unrecorded reroute can move quota outside local observation
  • unknown models, missing price classes, and telemetry failures fail closed and are visible in the UI
  • account/read identity is immediately reduced to an in-memory one-way fingerprint; neither the email nor fingerprint is persisted
  • switching accounts clears all in-memory anchors and evidence; an unavailable identity reports ACCOUNT ATTRIBUTION UNKNOWN
  • saved preferences now contain presentation settings only

The README states that this is a workload-dependent standard API-equivalent—not an account balance, invoice, subscription valuation, contractual allowance, or disclosure of OpenAI's quota formula.

Pricing

  • use official OpenAI standard API prices retrieved 2026-08-13
  • include published GPT-5.4 and GPT-5.5 long-context rates as well as GPT-5.6 family rates
  • make stale compiled pricing conspicuous wherever those rates produce a displayed value, while keeping the footer off Monitor
  • apply long-context thresholds per exact raw response in Benchmark
  • fail closed for cumulative-only long-context benchmark telemetry where response boundaries cannot be proven

Sources: OpenAI API pricing, GPT-5.4, and GPT-5.5.

The demo advances by five points per refresh, so codexometer --demo followed by r immediately demonstrates a learned estimate.

Verification

  • go test ./...
  • go test -race -cover ./...
  • go vet ./...
  • git diff --check
  • codexometer --check-auth against the prevailing local Codex session: 2 quota meters online
  • rebuilt the local Linux binary
  • rebuilt Linux amd64/arm64 distributions
  • rebuilt macOS amd64/arm64 distributions
  • rebuilt Windows amd64/arm64 distributions

Race coverage: root 67.9%, internal/codex 84.7%, internal/ui 91.1%, internal/version 81.0%.

@merefield
merefield marked this pull request as ready for review August 13, 2026 15:23
@merefield
merefield requested a lite review from Copilot August 13, 2026 15:23

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a process-local “observed standard API‑equivalent” estimator to Quota views by correlating stable local rollout accounting with quota percentage movement, and extends pricing provenance (retrieval date + official hyperlink) to all pricing-bearing Quota/Benchmark footers. It also updates embedded standard API pricing (including long-context tiers) and bumps the maintained source version to v0.7.1.

Changes:

  • Introduce a quota API‑equivalent observation pipeline (anchors, evidence retention, confidence rules) and render responsive “API‑EQ” lines on Quota meters.
  • Add account identity fingerprinting (process-local, non-persisted) to isolate observations per account and fail closed when identity is unavailable.
  • Update standard API pricing constants, long-context pricing behavior, demos, tests, and docs; bump version to v0.7.1.

Reviewed changes

Copilot reviewed 21 out of 21 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
README.md Documents the observed quota API‑equivalent estimator, safeguards/privacy posture, pricing provenance display, and version bump.
main.go Enhances demo fetcher to simulate API‑EQ usage and quota movement with a stable accounting bracket.
main_test.go Updates version expectation and adds demo bracket stability / API‑EQ advancement assertions.
internal/version/version.go Bumps maintained fallback version to 0.7.1.
internal/version/version_test.go Updates maintained fallback version test to 0.7.1.
internal/ui/view.go Injects quota “insights” meters and shows pricing provenance footer on Quota + Benchmark views.
internal/ui/view_test.go Expands footer tests to cover all priced views and responsive behavior.
internal/ui/quota_api_eq.go Implements the quota API‑equivalent sampling, trimming, estimation, confidence gating, and responsive rendering.
internal/ui/quota_api_eq_test.go Adds estimator correctness tests, account isolation, fail-closed cases, and responsive UI coverage.
internal/ui/preferences.go Clarifies that operational/account/quota-estimation data is never stored.
internal/ui/preferences_test.go Uses deep equality for preferences round-trip assertions.
internal/ui/model.go Brackets quota fetches with local accounting reads and wires observation/telemetry issue states into the model.
internal/ui/model_test.go Adds tests for stable accounting bracket requirements and telemetry failure surfacing.
internal/ui/meters.go Supports multi-line meter details rendering (needed for API‑EQ + attribution lines).
internal/codex/types.go Adds snapshot account fingerprint and propagates LimitID into Meter for attribution/eligibility logic.
internal/codex/live_usage.go Extends rollout decoding to capture per-call model and compute per-response standard API‑equivalent costs (fail closed).
internal/codex/live_usage_test.go Adds tests for model pricing, mid-turn model recovery, and event-order pricing behavior.
internal/codex/client.go Requests account identity (optional) and derives an anonymized fingerprint for account-isolated observation.
internal/codex/client_test.go Verifies fingerprint anonymization and tolerates missing account identity support.
internal/codex/benchmark.go Renames pricing provenance constants, adds long-context tiers, and applies long-context thresholds per raw response.
internal/codex/benchmark_test.go Adds tests for long-context pricing and per-response threshold application / fail-closed cumulative-only cases.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread internal/codex/live_usage.go Resolved
@merefield
merefield merged commit 0821361 into main Aug 13, 2026
6 checks passed
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.

2 participants