Universal usage cap for every provider, with lane failover when the cap is reached

Open
#9,165 2 comments 1 reaction 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
typescript

Research direction

Start by tracing the existing auto-switch implementations for OpenAI/ChatGPT and Anthropic referenced by issues #6013 and #6207, then follow how combo/* lanes handle 429 and 402 failures. Determine where provider quota state and lane selection meet; done means quota-reporting providers honor the shared cap and overrides, and lanes move to the next configured provider once the account reaches its cap. This spans multiple provider pools and routing behavior, so it needs project familiarity.

Written by the indexing model from the issue text.

Description

account-pool enhancement
Area

Authentication and account pool

What are you trying to accomplish?

Use one consistent percentage-based usage cap across every provider that reports quota (including google-antigravity), with optional per-provider or per-account overrides, and have combo/* lanes automatically fail over to the next configured provider as soon as an account reaches its cap.

What prevents this today?

Usage caps (auto-switch threshold) are only implemented for some pools today (such as OpenAI/ChatGPT and Anthropic pools via #6013 and #6207). On ocx 2.100.10, running ocx account auto-switch google-antigravity status reports:

auto-switch: inactive (stored threshold unset; not applied by this pool)

In addition, combo/* lanes currently only switch to the next provider on a 429 or 402 error, so an account continues receiving lane traffic until its quota is completely exhausted.

What should OpenCodex do?
  1. Provide one universal percentage cap system (auto-switch) that works the same way for every quota-reporting provider (including google-antigravity), with optional overrides per provider and per account (--account <id>).
  2. Integrate cap state into combo/* lane routing so that when an account passes its configured cap percentage, the lane moves to its next configured provider before hitting a 429 or 402 exhaustion error.
Example usage or interface
# Set a default cap across all quota-reporting providers (proposed)
ocx account auto-switch threshold 80

# Optional per-provider or per-account overrides using the existing command shape
ocx account auto-switch google-antigravity threshold 85
ocx account auto-switch openai threshold 90 --account <id>

Before: a combo/* lane keeps routing to the current provider until a request fails with 429 or 402.
After: once an account reaches its configured cap (e.g. 80%), the lane routes subsequent requests to the next target provider while leaving headroom on the capped account.

Alternatives or workarounds

Manually checking quota per pool and switching providers or accounts by hand, or relying on reactive 429/402 fallback in combo/* lanes after an account is already exhausted.

Additional context
  • Related issues/PRs: #6013, #6207
  • Environment: macOS (Apple Silicon), opencodex 2.100.10
  • Happy to test a build or PR on macOS (Apple Silicon, ocx 2.100.10).
Checks
  • I searched existing issues and documentation.
  • This request describes a concrete OpenCodex workflow rather than merely naming a desired technology.
  • I removed secrets and personal data.
Dominant language
TypeScript
Stars
16.9k
Forks
1.3k
Avg merge
1d 4h
Merged PRs (30d)
814

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from lidge-jun/opencodex

All issues in lidge-jun/opencodex

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.