Skip to content

feat(codex): add review model quota support - #836

Merged
decolua merged 1 commit into
decolua:masterfrom
hiepau1231:fix/codex-review-models-quota
May 3, 2026
Merged

decolua merged 1 commit into
decolua:masterfrom
hiepau1231:fix/codex-review-models-quota

Conversation

@hiepau1231

Copy link
Copy Markdown
Contributor

Summary

  • add virtual Codex review models with separate quota metadata
  • map review model IDs back to upstream Codex model IDs before dispatch
  • parse Codex review quota windows from usage responses
  • stop storing new Codex idToken values because it is unnecessary

Closes #830

Verification

  • node --check open-sse/config/providerModels.js open-sse/executors/codex.js open-sse/services/usage.js src/app/api/providers/[id]/models/route.js src/lib/oauth/providers.js src/lib/oauth/services/codex.js src/lib/localDb.js
  • npx eslint open-sse/config/providerModels.js open-sse/executors/codex.js open-sse/services/usage.js src/app/api/providers/[id]/models/route.js src/lib/oauth/providers.js src/lib/oauth/services/codex.js src/lib/localDb.js src/shared/constants/models.js
  • Codex smoke test confirms gpt-5.3-codex-high-review is exposed as a review model, maps to gpt-5.3-codex-high, and uses quota family review.

Build note

  • npm run build currently fails on this Windows environment because the script uses POSIX NODE_ENV=production syntax.
  • Running the equivalent PowerShell build reaches Next.js, then fails with EPERM: operation not permitted, scandir 'C:\Users\hiep\Application Data', which appears environment/file-tracing related rather than caused by this change.

@vrdons

vrdons commented May 1, 2026 •

Copy link
Copy Markdown

also can you add filter layer to codex responses endpoint ( {"detail":"Unsupported parameter: max_output_tokens"} etc.) i realized codex with responses api uses less token, or reasoning.summary: "auto" by reasoning models

@hiepau1231
hiepau1231 force-pushed the fix/codex-review-models-quota branch from b3c5cc4 to da4f460 Compare May 1, 2026 10:54
@hiepau1231

Copy link
Copy Markdown
Contributor Author

Updated the PR for this feedback.

Changes added:

  • Codex executor now strips Responses API token cap fields before forwarding upstream: max_output_tokens and max_completion_tokens.
  • The existing Codex reasoning handling already ensures reasoning models get reasoning.summary = "auto" when a reasoning object is present, and creates { effort, summary: "auto" } when only an effort/model suffix is provided.

Verification after the update:

  • node --check open-sse/executors/codex.js
  • npx eslint open-sse/executors/codex.js
  • Codex review model smoke test still passes.

@vrdons

vrdons commented May 1, 2026

Copy link
Copy Markdown

Also Closes #812

@decolua
decolua merged commit a463ee0 into decolua:master May 3, 2026
brilliant5163 pushed a commit to brilliant5163/9router that referenced this pull request May 8, 2026
caothu159 pushed a commit to diepxuan/9router that referenced this pull request May 14, 2026
diegosouzapw pushed a commit to diegosouzapw/OmniRoute that referenced this pull request Jun 21, 2026
…e_limits fallback

The Codex usage dashboard only emitted the primary `code_review_rate_limit`
window as `quotas.code_review` and dropped review descriptors that arrive via
the `additional_rate_limits` array (the shape some ChatGPT Codex plans report).

`buildCodexUsageQuotas` now:

- Emits the secondary window as `quotas.code_review_weekly` (mirrors the
  existing `session`/`weekly` pair for the normal rate limit).
- Falls back to the matching `additional_rate_limits[]` entry when the dedicated
  `code_review_rate_limit` block is empty — matched on `limit_name`,
  `metered_feature`, `limit_id`, `id`, or `name` containing `code_review`,
  `codex_review`, or `review`.

The dedicated block stays preferred when both are present. The existing
`quotas.code_review` key is preserved (back-compat for the dashboard
rendering and the `usage-service-hardening` regression test).

The new `code_review_weekly → "Code Review Weekly"` label is registered in
`ProviderLimits/utils.tsx` so the card renders both windows side-by-side.

TDD: 4 new assertions in `tests/unit/codex-usage-quotas-review-window.test.ts`
(secondary-window surfacing, `additional_rate_limits` fallback, silent-payload
back-compat, dedicated-block preference) + 1 label assertion appended to
`tests/unit/provider-limits-ui.test.ts`. All 46 codex-usage-related tests pass.

What we did NOT port from upstream:
- The virtual `<model>-review` chat-model variants — OmniRoute already exposes
  `codex-auto-review` as a dedicated native review model
  (`CODEX_NATIVE_UNPREFIXED_MODELS`), so per-model `-review` aliases would
  duplicate that surface.
- The `idToken` removal — OmniRoute actively parses the `id_token` JWT to
  extract the workspace id used for `chatgpt-account-id` binding on the
  usage endpoint (`src/lib/oauth/providers/codex.ts::parseIdToken`); removing
  it would break workspace selection.
- The `max_completion_tokens` / `max_output_tokens` stripping — the Codex
  executor already enforces an allowlist (`RESPONSES_API_ALLOWLIST`) that
  rejects unknown chat-completions fields before they reach upstream.

Inspired-by: decolua/9router#836 (review-quota plumbing pattern)

Co-authored-by: Rezky Hamid <hiepau1231@gmail.com>
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.

Add Codex Review Models With Quota

3 participants