Repository navigation
Keep known model availability in partial Codex usage responses - #1678
Conversation
Architecture-Review: unchanged; the parser distinguishes unknown entries while retaining the existing exact-model policy. Co-Authored-By: Codex <noreply@openai.com>
There was a problem hiding this comment.
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.
| 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': {}}} |
There was a problem hiding this comment.
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>
There was a problem hiding this comment.
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.
| 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' |
There was a problem hiding this comment.
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} |
There was a problem hiding this comment.
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.
|
@Mergifyio queue |
✅ Merged into
|
|
No description provided. |
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-botwith what you need.Review
Validation
Recorded for
78b41a659bdeuv run --group dev ruff check src tests: exit 0uv run --group dev tach check: exit 0uv run --python 3.14 python scripts/check_architecture_docs.py: exit 0scripts/size_budget.sh: exit 0uv run --group dev pytest -q: exit 0