Skip to content

Keep known model availability in partial Codex usage responses - #1678

Merged
mergify[bot] merged 3 commits into
mainfrom
lean178/r48-usage-parser
Nov 26, 2026
Merged

mergify[bot] merged 3 commits into
mainfrom
lean178/r48-usage-parser

Conversation

@eowca

@eowca eowca commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Upstream the installed usage-parser hotfix. Model entries with boolean availability remain usable and incomplete entries are reported in models_unknown. Quota windows and exact-model routing stay intact. The mixed-response test fails on main and the full ai-accounts test file passes on this branch. The installed file was untouched.


Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

Review

  • primary, claude, ed981cc, request_changes
  • delta, claude, a457396, approve

Validation

Recorded for 78b41a659bde

  • uv run --group dev ruff check src tests: exit 0
  • uv run --group dev tach check: exit 0
  • uv run --python 3.14 python scripts/check_architecture_docs.py: exit 0
  • scripts/size_budget.sh: exit 0
  • uv run --group dev pytest -q: exit 0

Architecture-Review: unchanged; the parser distinguishes unknown entries while retaining the existing exact-model policy.

Co-Authored-By: Codex <noreply@openai.com>

@loopzero-feder-positronics loopzero-feder-positronics Bot 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.

loopzero primary review by claude on ed981cc5efca431531c849c419c322415030b855, 17.7s: request_changes (0 critical, 1 important, 1 suggestion)

Settings per native call (launch configuration and CLI claims, not backend attestation):

  • Call 1: requested model claude-opus-5-5 (effort medium); CLI-reported model claude-opus-5-5 (effort unknown); configured model claude-opus-5-5 (effort medium)

Native Claude output is retained in the restricted local review receipt.

Comment thread scripts/ai-accounts/ai-accounts Resolved
Comment thread tests/test_ai_accounts.py
week = {'used_percent': 96, 'limit_window_seconds': 604800, 'reset_at': 1794384770}
short = {'used_percent': 99, 'limit_window_seconds': 18000, 'reset_at': short_reset} if short_reset else None
data = {'rate_limit': {'primary_window': short or week, 'secondary_window': week if short else None}, 'model_usage': {'m': {'available': True}}}
data = {'rate_limit': {'primary_window': short or week, 'secondary_window': week if short else None}, 'model_usage': {'m': {'available': True}, 'partial': {}}}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion: The partial-entry case is added to a window-sharing test instead of its own focused parser test

The new assertion sits inside test_codex_json_and_text_share_each_existing_window, which is about quota windows. The test never checks the resulting tier, or that model_availability reports an unknown model as not known. It also has no case where every entry is unknown, which is the case that regressed. Add a small dedicated test with three cases: a mix of known and unknown entries (tier 2 or 1 as expected, plus models_unknown), all entries unknown (tier -1 with an error), and model_availability('codex', name, 'partial') returning known=False.

Co-Authored-By: Codex <noreply@openai.com>

@loopzero-feder-positronics loopzero-feder-positronics Bot 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.

loopzero delta review by claude on a45739690d2279f09f3346dbcf49c1cace6743c2, 13.3s: approve (0 critical, 0 important, 2 suggestion)

Settings per native call (launch configuration and CLI claims, not backend attestation):

  • Call 1: requested model claude-opus-5-5 (effort medium); CLI-reported model claude-opus-5-5 (effort unknown); configured model claude-opus-5-5 (effort medium)

Native Claude output is retained in the restricted local review receipt.

Comment thread tests/test_ai_accounts.py
result = helper.check_codex('c2')
assert result['models_unknown'] == ['partial']
if short_reset == 'all-unknown':
assert result['tier'] == -1 and result['error'] == 'usage response has no known model availability'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion: All-unknown case doesn't check that quota windows are kept

The fix in check_codex (scripts/ai-accounts/ai-accounts:637-638) is correct. Before it, when every model entry was unknown, models was empty, all({}) was True, and an account with available quota got tier 2, so routing could pick an account whose model availability was unknown. Now it returns tier -1 and still includes **result (windows, util, next_reset). The new 'all-unknown' test branch only checks tier, error and models_unknown, then returns. It never checks windows or next_reset. The acceptance criteria require quota windows to be preserved, so a future change that returns a bare error dict on this path would still pass. Smallest fix: before the early return, add assert result['next_reset'] == 1794384770 and result['windows'] and 'models' not in result.

if isinstance(v, dict) and isinstance(v.get("available"), bool)}
unknown = sorted(m for m in model_usage if m not in models)
if not models:
return {**result, "error": "usage response has no known model availability", "models_unknown": unknown}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion: An exhausted account with all-unknown models is reported as unknown (tier -1), not unusable (tier 0)

When ok is False (rate limit reached or utilization ≥ MARGIN), the response already shows the account can't be used, whatever its model availability. The new early return still gives tier -1, so select treats it as unknown instead of known-exhausted. The existing 'no model usage' path (line 631) does the same, so the behaviour is consistent and not a bug. If you want the known exhaustion to count, return tier: 0 here when not ok.

@eowca
eowca marked this pull request as ready for review November 26, 2026 08:32
@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

@Mergifyio queue

@mergify

mergify Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

✅ Merged into main as b088890 at 08:38 UTC

5 min in the queue, 4 min of it CI.

So far

  • ✅ Entered the queue Thu 26 Nov, 08:33 · rule main · triggered by @eowca with the @mergifyio queue command
  • ✅ Passed · draft #1714
  • ✅ Merged 08:38 · b088890 · squash
3 merge conditions met
  • github-review-approved · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required
  • any of · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required:
    • check-success = checks
    • check-neutral = checks
    • check-skipped = checks
  • any of · required by GitHub repository ruleset rule main: PR only, Mergify queue, existing checks required:
    • check-success = Loop-zero Eligibility
    • check-neutral = Loop-zero Eligibility
    • check-skipped = Loop-zero Eligibility

Times in UTC · dashboard · how the merge queue works

@eowca

eowca commented Nov 26, 2026

Copy link
Copy Markdown
Contributor Author

No description provided.

@mergify
mergify Bot merged commit b088890 into main Nov 26, 2026
13 checks passed
@eowca
eowca deleted the lean178/r48-usage-parser branch November 26, 2026 08:38
@mergify mergify Bot removed the queued label Nov 26, 2026
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