Skip to content

[Feature]: expose per-account Anthropic quota in ocx account list #2566

Closed

Description

@lidge-jun

Area

CLI

What are you trying to accomplish?

I run three Anthropic OAuth logins in the account pool and need to know, before I start a long session, which one still has headroom. The decision needs each account's own 5-hour and weekly bars — not the pool's active account alone — so I can switch to the account that will survive the session instead of hitting a limit mid-run and rotating under load.

What prevents this today?

The proxy already computes exactly this data, and the dashboard already shows it, but no CLI command exposes it.

  • src/providers/quota.ts:1561 exports fetchProviderAccountQuotas(provider, forceRefresh), which probes https://api.anthropic.com/api/oauth/usage once per stored credential and returns a per-account 5h/weekly/Opus/Sonnet breakdown.
  • src/server/management/oauth-account-routes.ts:270 exposes it as GET /api/oauth/accounts?provider=anthropic&quota=1 (with &refresh=1 to bypass the TTL).
  • gui/src/hooks/useProviderAccountPools.ts:100 consumes that endpoint, so the dashboard renders per-account bars.
  • supportsPerAccountQuota() at src/providers/quota.ts:1396 gates it to anthropic today.

The CLI never passes quota=1. fetchOAuthRows() at src/cli/account-api.ts:246 requests /api/oauth/accounts?provider=<name> with no quota parameter, so ocx account list anthropic returns id/label/active only, and --json has no quota field either. ocx account list --quota is rejected as an unknown flag.

The adjacent commands do not fill the gap:

So a headless or SSH session, or any agent operating the proxy, cannot answer "which Anthropic account has quota left" without hand-rolling an authenticated curl against the management API and reading the admin token off disk. That is the workaround I am using today, and it should not be the supported path for data the dashboard shows in one click.

What should OpenCodex do?

Add a per-account quota projection to the account list for providers where supportsPerAccountQuota() is true:

  • ocx account list <provider> --quota requests quota=1 and prints each account's windows on its row;
  • --refresh (or --quota=refresh) maps to refresh=1 for a forced probe;
  • --json includes the per-account quota object and the quotaUnavailable marker the endpoint already returns;
  • without --quota the command stays a cheap local read with no network probe, matching the endpoint's existing opt-in design;
  • for a provider without per-account support, the flag reports that plainly rather than silently printing bare rows.

Reuse quotaParts() from src/cli/account-extended.ts:267 so the rendering matches ocx account refresh. No new probe logic is needed — this is a CLI projection over an endpoint that already exists and is already exercised by the GUI.

Example usage or interface

Today:

$ ocx account list anthropic
PROVIDER   TYPE   ID        PLAN/LABEL         PRIORITY  STATUS
anthropic  oauth  1278f8da  a***[email protected]  -
anthropic  oauth  e112f28b  k***[email protected]  -
anthropic  oauth  b245be97  l***[email protected]  -         active

$ ocx account list anthropic --quota
Unknown flag(s): --quota

Proposed:

$ ocx account list anthropic --quota
PROVIDER   TYPE   ID        PLAN/LABEL         STATUS  QUOTA
anthropic  oauth  1278f8da  a***[email protected]  -       5h 100% resets 2026-08-25T15:00:00Z  weekly 61% resets 2026-08-28T23:00:00Z
anthropic  oauth  e112f28b  k***[email protected]  -       5h 0%                                weekly 44% resets 2026-08-28T15:00:00Z
anthropic  oauth  b245be97  l***[email protected]  active  5h 5% resets 2026-08-25T16:39:59Z    weekly 98% resets 2026-08-26T01:59:59Z

That output makes the operational decision obvious: the active account is at 98% weekly, and ocx account use anthropic e112f28b is the right move.

Alternatives or workarounds

Reading the admin token off disk and calling the management API directly:

curl -s -H "Authorization: Bearer $(cat ~/.opencodex/admin-api-token)" \
  'http://127.0.0.1:10100/api/oauth/accounts?provider=anthropic&quota=1&refresh=1'

This works and returns the full per-account payload, but it requires knowing the runtime port, handling the admin token in shell, and parsing JSON by hand — none of which a CLI user should need for a read the dashboard performs routinely.

Opening the dashboard is not an alternative for headless, SSH, or agent-driven use.

Additional context

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.

Activity

  1. added
    enhancement
    account-pool
    cli
    on Aug 25, 2026
  2. added
    proxy
    on Aug 25, 2026
  3. lidge-jun commented on Aug 25, 2026

    @lidge-jun
    OwnerAuthor

    리뷰 · 우선순위 55 / 80

    설명: 이 이슈는 ocx account list 가 앤트로픽 계정마다 5시간/주간 막대를 보여 달라고 한다. 작성자는 lidge-jun 이다. 지금 열려 있다. 라벨은 enhancement, account-pool, cli, proxy 다. 지금 CURRENT dev HEAD 는 e1fb675 이다. 이번 시간에 SHA 는 안 움직였다. origin/dev package.json 은 2.32.1-preview.20260825 다. 차량 풀은 아직 없다. 표시만 요구한다. 라우터를 바꾸라고 하지 않는다. 내가 구현하지 않고 머지하지 않는다.

    HEAD 에서 빈 자리는 확인된다. src/cli/account.ts 18-19줄 사용법은 list [provider] [--json] [--all] 만 허용한다. 96-104줄 cmdList 는 leftoverArgsError 로 --quota 를 Unknown flag(s) 로 거절한다. src/cli/account-api.ts 245-246줄 fetchOAuthRows 는 /api/oauth/accounts?provider= 만 부르고 quota=1 을 안 붙인다. 그래서 리스트와 --json 모두 계정 쿼터 칸이 없다. ocx account refresh 는 활성 계정 한 줄만 찍는다.

    프록시와 대시보드는 이미 그 숫자를 갖고 있다. src/providers/quota.ts 1396-1398줄 supportsPerAccountQuota 는 오늘 anthropic 만 참이다. 1561-1576줄 fetchProviderAccountQuotas 가 계정마다 프로브한다. src/server/management/oauth-account-routes.ts 274-296줄 GET /api/oauth/accounts 는 ?quota=1 일 때만 프로브하고, ?refresh=1 이면 TTL 을 건너뛴다. 칸이 없으면 값싼 로컬 읽기다. gui/src/hooks/useProviderAccountPools.ts 가 그 엔드포인트를 쓴다. 이 이슈는 CLI 가 같은 옵트인을 노출하라는 것이다.

    제안은 범위가 작다. --quota 가 quota=1 을 붙이고, --refresh 가 refresh=1 을 붙이고, --json 이 quota 와 quotaUnavailable 을 실어 나른다. 플래그 없으면 네트워크 프로브를 하지 않는다. 지원하지 않는 공급자는 조용히 빈 칸이 아니라 지원하지 않는다고 말해야 한다. 렌더러는 src/cli/account-extended.ts 267줄 quotaParts 를 재사용한다. 2565 가 그 줄을 provider quota 텍스트에도 쓰자고 한다. 2565 를 먼저 고치면 이 이슈는 리스트 플래그만 남는다. 두 이슈를 서로 닫지 말 것.

    2539 는 라우터가 주간 창으로 고르는 일이다. 이 이슈는 사람이 같은 숫자를 읽게 하는 일이다. 2539 를 이 이슈로 닫지 말 것. 2560 이 2539 의 차량이다. 2562 는 구글 풀이다. 이 이슈로 닫지 말 것. 695 도 연다. src/runtime 은 없다. default-aliases.ts 와 model-presets.ts 도 없다. 2463 2464 2465 를 닫지 말 것. 프리뷰 배포가 아니다. 내가 이 이슈를 닫지 않는다.

    라인 19 - src/cli/account.ts 사용법에 --quota 가 없다
    라인 100 - src/cli/account.ts leftoverArgsError 가 --quota 를 거절한다
    라인 246 - src/cli/account-api.ts fetchOAuthRows 가 quota=1 을 안 붙인다
    라인 1396 - src/providers/quota.ts supportsPerAccountQuota 는 anthropic 만 참이다
    라인 277 - src/server/management/oauth-account-routes.ts 가 이미 ?quota=1 옵트인이다
    2565 - 같은 렌더러의 버그다. 이 이슈로 닫지 말 것. 먼저 고치면 재사용이 쉽다
    2539 - 라우팅이다. 표시가 아니다. 닫지 말 것

    메인테이너의 판단이 필요한 지점

    • 이 이슈를 받을지. 표시 공백은 맞다. CLI 가 대시보드가 이미 읽는 엔드포인트를 안 부른다
    • 2565 와 한 풀로 묶을지. 묶지 않는 편이 낫다. 2565 는 포맷 버그, 이 이슈는 플래그와 프로브 옵트인이다
    • 구글까지 같이 열지. HEAD 게이트는 anthropic 만이다. 이 이슈도 그 게이트를 따르라고 적는다. 2562 와 묶지 말 것
    • 2539 를 같이 닫을지. 닫지 말 것
    • 지금 leftover-close 할지. 차량이 없다. 내가 닫지 않는다

    너의 추천
    기능으로 받는다. ocx account list --quota 가 기존 GET quota=1 을 투영하게 한다. 기본 list 는 값싼 로컬 읽기로 둔다. 2565 렌더러를 재사용한다. 2539 와 695 와 2562 는 이 이슈로 닫지 말 것. 내가 구현하지 않는다. 라벨은 그대로 둔다. 프리뷰 배포가 아니다.

    이 댓글은 grok-bot이 작성했습니다

  4. lidge-jun commented on Aug 25, 2026

    @lidge-jun
    OwnerAuthor

    Shipped on dev in #2587.

    ocx account list --quota now adds a QUOTA column, with --refresh to bypass the cached probe. It is opt-in for the reason you identified: the server probes the upstream once per stored credential, so the default listing stays a local read.

    Verified against your three Anthropic logins — it produces exactly the decision the issue describes, with the active account at 45% weekly while a sibling sits at 98%.

    Two small calls I made along the way: an unprobed provider shows - and a failed probe shows unavailable, since blank would read as no usage rather than not measured. And two DTO spellings reach the same field (the per-account probe reports fiveHourPercent, the Codex pool reports shortPercent), so both render as 5h. Docs updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    account-poolclienhancementproxy

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions