Skip to content

fix(server): a custom endpoint no longer shows the local login's usage limits - #39793

Draft
shivamhwp wants to merge 2 commits into
mainfrom
issue-watch/39737
Draft

shivamhwp wants to merge 2 commits into
mainfrom
issue-watch/39737

Conversation

@shivamhwp

Copy link
Copy Markdown
Collaborator

Thread details showed the local Claude login's usage for a Claude instance routed through a custom ANTHROPIC_BASE_URL. The CLI's get_usage reads that login, which a custom endpoint may not route its requests through, so the card showed another account's numbers as valid, and they never moved.

For a custom endpoint, the instance now publishes unavailable limits with a message instead of the get_usage result, so the card reads Unavailable.

Closes #39737

Evidence

Server tests. apps/server: vp test run src/provider/ProviderRegistry.test.ts src/provider/claudeUsageLimits.test.ts passes, 104 tests, at 7a0b719. The new case, "does not report the local login's limits for a custom endpoint", fails on main with expected undefined to equal 'unsupported'.

Web, in the real app. scripts/scenarios/claude-custom-endpoint-shows-unavailable-limits.e2e.ts, run with vp run scenarios:prove in headless Chromium: it fails on main and passes on this commit. The Claude instance points at a fake CLI that answers get_usage with a login's limits. The same thread details card, on both sides:

main This commit
Usage card Session 0% (the local login's limits) Limits Unavailable

Not shown: the before and after screenshots. They are not uploaded yet, so the table is the only record of the view here.

Checks. The repo's check:changed passes format, lint, both knip passes, graphql and the tests. Its typecheck step reports @t3tools/scripts#typecheck as failed because it "modified its inputs". Running effect-tsgo tsrs --noEmit in scripts directly on the same tree exits 0 with no errors. Not shown: why the harness flags that package.

Not in this change

  • A --settings launch argument can override ANTHROPIC_BASE_URL for a turn. The probe reads the endpoint from the instance and settings environment only, as before, so that configuration keeps its existing customEndpoint label.
  • A custom endpoint routed through a CLIProxyAPI hub shows Unavailable here. Showing that hub's limits needs hub matching, which fix(web): thread details show the CLIProxyAPI hub's limits for instances routed through it #39752 covers and which edits the same provider lines.
  • The scenario's fake CLI stands in for the CLI's get_usage response, and its chat turn never completes. The card assertion depends on neither.

Written by Claude Haiku 5.5 in Claude Code; reviewed by GPT 6.2 Sol in Codex.

🤖 Generated with Claude Code

…e limits

get_usage reads the local Claude login, which a custom ANTHROPIC_BASE_URL may not route its requests through, so the instance showed another account's limits as valid. Publish unavailable limits for a custom endpoint instead.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
@shivamhwp
shivamhwp marked this pull request as draft November 20, 2026 16:04
@github-actions github-actions Bot added vouch:trusted Author is trusted by repo permissions or the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Nov 20, 2026
@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

Thread transfer impact

✅ Thread transfer remains within every enforced ceiling.

Provider Metric Main baseline This PR Impact PR ceiling
Codex Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅
Codex Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Codex Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅
Codex Live turn WebSocket decoded 21.5 KiB 21.5 KiB 0 B (0.0%) 24.4 KiB ✅
Codex Live turn messages 1 1 0 (0.0%) 8 ✅
Claude Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅
Claude Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅
Claude Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅
Claude Live turn WebSocket decoded 21.9 KiB 21.9 KiB 0 B (0.0%) 24.4 KiB ✅
Claude Live turn messages 1 1 0 (0.0%) 8 ✅

Other scenarios

All 64 scenario measurements match main.

All 64 scenario measurements
Provider Scenario Metric Main baseline This PR Impact PR ceiling
Codex short turn resume WebSocket decoded 10.5 KiB 10.5 KiB 0 B (0.0%) 12.7 KiB ✅
Codex short turn resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Codex long turn running, cold open HTTP decoded 281.7 KiB 281.7 KiB 0 B (0.0%) 302.7 KiB ✅
Codex long turn running, cold open rows 75 75 0 (0.0%) 75 ✅
Codex long turn running, history page HTTP decoded 92.4 KiB 92.4 KiB 0 B (0.0%) 107.4 KiB ✅
Codex long turn running, history page rows 75 75 0 (0.0%) 75 ✅
Codex long turn finished, cold open HTTP decoded 381.5 KiB 381.5 KiB 0 B (0.0%) 410.2 KiB ✅
Codex long turn finished, cold open rows 151 151 0 (0.0%) 151 ✅
Codex long turn finished, socket cold open WebSocket decoded 381.6 KiB 381.6 KiB 0 B (0.0%) 410.2 KiB ✅
Codex long turn finished, socket cold open WebSocket messages 2 2 0 (0.0%) 2 ✅
Codex long turn finished, socket cold open rows 151 151 0 (0.0%) 151 ✅
Codex long turn finished, work page HTTP decoded 186.2 KiB 186.2 KiB 0 B (0.0%) 200.2 KiB ✅
Codex long turn finished, work page rows 150 150 0 (0.0%) 150 ✅
Codex idle thread resume WebSocket decoded 65 B 65 B 0 B (0.0%) 200 B ✅
Codex idle thread resume WebSocket messages 1 1 0 (0.0%) 1 ✅
Codex fleet shell snapshot HTTP decoded 42.4 KiB 42.4 KiB 0 B (0.0%) 53.7 KiB ✅
Codex fleet shell snapshot rows 27 27 0 (0.0%) 27 ✅
Codex fleet shell subscribe WebSocket decoded 65 B 65 B 0 B (0.0%) 200 B ✅
Codex fleet shell subscribe WebSocket messages 1 1 0 (0.0%) 1 ✅
Codex fleet shell resume check HTTP decoded 18 B 18 B 0 B (0.0%) 100 B ✅
Codex fleet shell resume check rows 0 0 0 0 ✅
Codex stale shell reload HTTP decoded 42.4 KiB 42.4 KiB 0 B (0.0%) 53.7 KiB ✅
Codex stale shell reload rows 27 27 0 (0.0%) 27 ✅
Codex stale shell resume WebSocket decoded 140 B 140 B 0 B (0.0%) 400 B ✅
Codex stale shell resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Codex stale todo list cold open HTTP decoded 72.4 KiB 72.4 KiB 0 B (0.0%) 83.0 KiB ✅
Codex stale todo list cold open rows 75 75 0 (0.0%) 75 ✅
Codex stale todo list cold open nodes 2 2 0 (0.0%) 4 ✅
Codex stale todo list cold open subagents 2 2 0 (0.0%) 4 ✅
Codex stale todo list cold open plans 1 1 0 (0.0%) 2 ✅
Codex stale todo list cold open providerTurns 1 1 0 (0.0%) 2 ✅
Codex stale todo list cold open checkpoints 1 1 0 (0.0%) 2 ✅
Claude short turn resume WebSocket decoded 10.6 KiB 10.6 KiB 0 B (0.0%) 12.7 KiB ✅
Claude short turn resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Claude long turn running, cold open HTTP decoded 283.3 KiB 283.3 KiB 0 B (0.0%) 302.7 KiB ✅
Claude long turn running, cold open rows 75 75 0 (0.0%) 75 ✅
Claude long turn running, history page HTTP decoded 93.4 KiB 93.4 KiB 0 B (0.0%) 107.4 KiB ✅
Claude long turn running, history page rows 75 75 0 (0.0%) 75 ✅
Claude long turn finished, cold open HTTP decoded 384.2 KiB 384.2 KiB 0 B (0.0%) 410.2 KiB ✅
Claude long turn finished, cold open rows 151 151 0 (0.0%) 151 ✅
Claude long turn finished, socket cold open WebSocket decoded 384.3 KiB 384.3 KiB 0 B (0.0%) 410.2 KiB ✅
Claude long turn finished, socket cold open WebSocket messages 2 2 0 (0.0%) 2 ✅
Claude long turn finished, socket cold open rows 151 151 0 (0.0%) 151 ✅
Claude long turn finished, work page HTTP decoded 188.1 KiB 188.1 KiB 0 B (0.0%) 200.2 KiB ✅
Claude long turn finished, work page rows 150 150 0 (0.0%) 150 ✅
Claude idle thread resume WebSocket decoded 66 B 66 B 0 B (0.0%) 200 B ✅
Claude idle thread resume WebSocket messages 1 1 0 (0.0%) 1 ✅
Claude fleet shell snapshot HTTP decoded 43.0 KiB 43.0 KiB 0 B (0.0%) 53.7 KiB ✅
Claude fleet shell snapshot rows 27 27 0 (0.0%) 27 ✅
Claude fleet shell subscribe WebSocket decoded 66 B 66 B 0 B (0.0%) 200 B ✅
Claude fleet shell subscribe WebSocket messages 1 1 0 (0.0%) 1 ✅
Claude fleet shell resume check HTTP decoded 18 B 18 B 0 B (0.0%) 100 B ✅
Claude fleet shell resume check rows 0 0 0 0 ✅
Claude stale shell reload HTTP decoded 43.0 KiB 43.0 KiB 0 B (0.0%) 53.7 KiB ✅
Claude stale shell reload rows 27 27 0 (0.0%) 27 ✅
Claude stale shell resume WebSocket decoded 140 B 140 B 0 B (0.0%) 400 B ✅
Claude stale shell resume WebSocket messages 2 2 0 (0.0%) 2 ✅
Claude stale todo list cold open HTTP decoded 73.4 KiB 73.4 KiB 0 B (0.0%) 83.0 KiB ✅
Claude stale todo list cold open rows 75 75 0 (0.0%) 75 ✅
Claude stale todo list cold open nodes 2 2 0 (0.0%) 4 ✅
Claude stale todo list cold open subagents 2 2 0 (0.0%) 4 ✅
Claude stale todo list cold open plans 1 1 0 (0.0%) 2 ✅
Claude stale todo list cold open providerTurns 1 1 0 (0.0%) 2 ✅
Claude stale todo list cold open checkpoints 1 1 0 (0.0%) 2 ✅

Baseline: 9cc4018 · PR result: 6343a65 · Source CI: success

Scenario and decoded snapshot size

10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.

  • Codex decoded thread snapshot: 108.5 KiB
  • Claude decoded thread snapshot: 108.8 KiB

Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.

@coderabbitai

coderabbitai Bot commented Nov 20, 2026

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Claude custom endpoints now report usage limits as unsupported instead of showing limits from the local Claude login. Provider tests and an end-to-end scenario cover the status response and thread details display.

Changes: Custom endpoint usage limits

Layer / File(s) Summary
Custom endpoint limit reporting
apps/server/src/provider/ClaudeProvider.ts, apps/server/src/provider/ProviderRegistry.test.ts, scripts/scenarios/claude-custom-endpoint-shows-unavailable-limits.e2e.ts
Custom endpoints report usage limits as unsupported. Other endpoints retain their existing usage handling. Provider and end-to-end tests check the unsupported status and the “Limits: Unavailable” display.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Possibly related issues

  • pingdotgg/t3code#30990 — This PR changes custom-endpoint usage reporting, but does not add the hub-limit matching requested by the issue.
  • pingdotgg/t3code#30886 — This PR changes the provider state read by the limits popup, but does not provide the hub limits requested by the issue.
  • pingdotgg/t3code#39751 — This PR changes the unsupported reason and message, but does not show CLIProxyAPI hub limits.

Suggested labels: bugfix

Suggested reviewers: juliusmarminge, bitmvk, macroscopeapp

Merge Risk: Minimal · up to 7a0b7

Claude instances using a custom endpoint now show Unavailable limits instead of another account's usage. The change is narrow and tested, and no merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: a custom endpoint no longer shows the local Claude login's usage limits. It follows the conventional commit form. The changeset matches it: ClaudeProvider reports unav…
Description check Passed The description follows the template. It explains the problem (a custom ANTHROPIC_BASE_URL showed the local login's usage as valid), the change (custom endpoints now publish unavailable limits with a …
Linked Issues check Passed Linked issue #39737 asks that a Claude instance routed through a custom ANTHROPIC_BASE_URL not show the local CLI login's limits. Its acceptance outcome is either the serving account's limits or Unava…
Out of Scope Changes check Passed The whole-PR changes are limited to the usage-limit branch in ClaudeProvider.ts (+18/-11), a ProviderRegistry test extension for the custom-endpoint case, and an e2e scenario for the thread details Un…
Full details: Title check

Explanation

The title names the main change: a custom endpoint no longer shows the local Claude login's usage limits. It follows the conventional commit form. The changeset matches it: ClaudeProvider reports unavailable limits for custom endpoints, and tests and an e2e scenario cover that behavior.

Full details: Description check

Explanation

The description follows the template. It explains the problem (a custom ANTHROPIC_BASE_URL showed the local login's usage as valid), the change (custom endpoints now publish unavailable limits with a message), and scope (links issue #39737, with known exclusions listed). Verification gives specific commands, a test count, the failing-before and passing-after results, and a table of observed output. It also states what was not checked: the screenshots are missing, and the check:changed typecheck failure is unexplained. The template asks for before/after screenshots for UI changes, so the missing screenshots are a gap, but the description is mostly complete.

Full details: Linked Issues check

Explanation

Linked issue #39737 asks that a Claude instance routed through a custom ANTHROPIC_BASE_URL not show the local CLI login's limits. Its acceptance outcome is either the serving account's limits or Unavailable. The reviewed diff of apps/server/src/provider/ClaudeProvider.ts (merge base to head) computes usageLimits from customApiEndpoint first. When that is set, it publishes makeUnavailableUsageLimits with reason 'unsupported' and a custom-endpoint message. The get_usage result is no longer used for that case. Non-custom endpoints keep the prior probeFailed and recordClaudeUsageResponse paths. The PR takes the Unavailable outcome, which the issue allows. Hub matching (#39752) is deferred and is not a requirement here. The author reports a new ProviderRegistry test that covers this case (fails on main, passes at head). The test file was not re-read in this assessment. The --settings override gap is a stated limitation, not a requirement of #39737. Unverified: the exact definition of customApiEndpoint was not read, only its use in the diff.

Full details: Out of Scope Changes check

Explanation

The whole-PR changes are limited to the usage-limit branch in ClaudeProvider.ts (+18/-11), a ProviderRegistry test extension for the custom-endpoint case, and an e2e scenario for the thread details Unavailable view. All of these support the #39737 objective. The PR description's check:changed typecheck harness report concerns repository tooling and not a code change. It does not indicate unrelated changes.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
Fix failing CI checks

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 9cc4018 and 7a0b719.

Files selected for processing: 3

  • apps/server/src/provider/ClaudeProvider.ts
  • apps/server/src/provider/ProviderRegistry.test.ts
  • scripts/scenarios/claude-custom-endpoint-shows-unavailable-limits.e2e.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

…sage response

The local usage shape did not match the SDK type, so the typed helper rejected every checkClaudeProviderStatus call in the file.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>

This branch has not been deployed

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

Labels

size:M 30-99 changed lines (additions + deletions). vouch:trusted Author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Thread details shows the local Claude login's usage for a Claude instance routed through a custom ANTHROPIC_BASE_URL

1 participant