Repository navigation
Keep known model availability in partial Codex usage responses #1678
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -384,7 +384,7 @@ def http(req): | |
| assert ('fallback' in output and 'HTTP 403' in output) is (api == 403) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize('short_reset', [None, 1793912400, 'offline']) | ||
| @pytest.mark.parametrize('short_reset', [None, 1793912400, 'offline', 'all-unknown']) | ||
| def test_codex_json_and_text_share_each_existing_window(helper, monkeypatch, capsys, short_reset): | ||
| helper.write_private(helper.codex_home('c2') / 'auth.json', '{"tokens":{"access_token":"fake"}}') | ||
| monkeypatch.setattr(helper, 'now', lambda: 10000) | ||
|
|
@@ -396,10 +396,17 @@ def test_codex_json_and_text_share_each_existing_window(helper, monkeypatch, cap | |
| assert 'unknown (network: offline)' in capsys.readouterr().out | ||
| return | ||
| 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}}} | ||
| short = {'used_percent': 99, 'limit_window_seconds': 18000, 'reset_at': short_reset} if isinstance(short_reset, int) else None | ||
| 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. Choose a reason for hiding this commentThe 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 |
||
| if short_reset == 'all-unknown': | ||
| del data['model_usage']['m'] | ||
| monkeypatch.setattr(helper, '_http', lambda req: (200, {}, json.dumps(data).encode())) | ||
| 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. Choose a reason for hiding this commentThe 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 |
||
| return | ||
| assert result['models'] == {'m': True} | ||
| assert result['next_reset'] == 1794384770 | ||
| status = {'checked_at': 10000, 'providers': {'codex': {'active': 'c2', 'accounts': {'c2': result}}}} | ||
| helper.write_private(helper.STATE / 'status.json', json.dumps(status)) | ||
|
|
||
There was a problem hiding this comment.
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
okis 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, soselecttreats 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, returntier: 0here whennot ok.