Skip to content

Native Anthropic passthrough drops anthropic-ratelimit-* headers, so Claude Code statusLine rate_limits is missing #6297

Closed

Description

@lhj6102

Client or integration

Claude Code

Area

Proxy and routing

Summary

When Claude Code runs through opencodex (ocx claude, ANTHROPIC_BASE_URL=http://127.0.0.1:10100) with a claude.ai subscription, the native Anthropic passthrough rebuilds the response headers and drops every anthropic-ratelimit-* header. Claude Code reads the 5-hour / 7-day subscription usage from these headers, so the statusLine JSON never gets rate_limits (five_hour / seven_day). The key is missing entirely. Without the proxy it is present.

Expected: the passthrough relays the upstream anthropic-ratelimit-* headers so Claude Code can fill rate_limits, as it does against api.anthropic.com directly.

This is the same defect as #6292, which the issue-quality bot auto-closed because it did not use a template. It is still present on dev (checked src/server/claude-messages.ts at ea7bd16).

Cause: in src/server/claude-messages.ts, anthropicNativePassthrough() returns a new Response with a fixed header set:

  • SSE path: only Content-Type, Cache-Control, Connection
  • non-stream path: only Content-Type and Retry-After

All other upstream headers, including anthropic-ratelimit-unified-*, are discarded.

Reproduction

  1. Configure a Claude Code statusLine command that dumps its stdin JSON to a file.
  2. Launch Claude Code with ocx claude on a Pro/Max subscription (native passthrough) and send a message.
  3. The dumped JSON has no rate_limits key. Launch plain claude (no proxy) and it is present.

I applied the change below to the installed 2.73.0 package, ran ocx restart, and the statusLine stdin started carrying live rate_limits.five_hour / seven_day values on the next responses.

+/** Relay Anthropic rate-limit headers so Claude Code can fill statusLine `rate_limits`. */
+function passthroughRateLimitHeaders(upstream: Response): Record<string, string> {
+  const out: Record<string, string> = {};
+  upstream.headers.forEach((value, name) => {
+    if (name.toLowerCase().startsWith("anthropic-ratelimit-")) out[name] = value;
+  });
+  return out;
+}
+
 async function anthropicNativePassthrough(
@@
         "Content-Type": contentType,
         "Cache-Control": "no-cache",
         "Connection": "keep-alive",
+        ...passthroughRateLimitHeaders(upstream),
       },
@@
-    headers: { "Content-Type": contentType, ...(retryAfter ? { "Retry-After": retryAfter } : {}) },
+    headers: {
+      "Content-Type": contentType,
+      ...(retryAfter ? { "Retry-After": retryAfter } : {}),
+      ...passthroughRateLimitHeaders(upstream),
+    },

Version

2.73.0

Operating system

Ubuntu 26.04.1 LTS (WSL2)

Provider and model

anthropic-native passthrough / claude-opus-5-5 (Claude Code 2.1.285, claude.ai subscription OAuth)

Logs or error output

No error is logged. The statusLine stdin JSON simply has no `rate_limits` key while routed through the proxy.

Screenshots and supporting files

No response

Redacted configuration

{
  "claudeCode": {
    "nativePassthrough": true,
    "authMode": "subscription"
  }
}

Checks

  • I searched existing issues and documentation.
  • I removed secrets, tokens, account details, request credentials, and personal data.

Activity

  1. added
    bug
    proxy
    streaming
    on Sep 30, 2026
  2. Ingwannu commented on Oct 1, 2026

    @Ingwannu
    Owner

    Confirmed against current dev 6429463: anthropicNativePassthrough reconstructs both SSE and JSON/error response headers without the upstream anthropic-ratelimit-* family. The existing native response path therefore loses the information regardless of whether the body succeeds. I am preparing a narrow header-family relay with SSE and JSON/error regressions; unrelated upstream headers will not be forwarded. No live runtime restart or account traffic is needed for this validation. I will link the PR and exact test results here; this issue remains open until the fix lands.

  3. github-actions commented on Oct 1, 2026

    @github-actions
    Contributor

    Automated translation bookkeeping — detected language: English.

  4. Ingwannu commented on Oct 1, 2026

    @Ingwannu
    Owner

    Fix PR: #6356, head eaadb51 (based on dev 6429463). The three original SSE/JSON/429 regressions failed before the change; after it, the expanded focused suite and layout/structure/file-size gates pass (141 tests), and typecheck passes. count_tokens and missing/unrelated-header behavior are covered too. All local validation used disposable homes and hard CPU/RAM limits; no live account or service changes. The PR is draft pending independent review and required CI, not a released fix. Keeping this issue open until the verified dev landing.

  5. Ingwannu commented on Oct 1, 2026

    @Ingwannu
    Owner

    Update: #6356 at unchanged head eaadb51 is now ready for independent review. Exact-head Cross-platform CI run 36818611817 completed successfully, including four test shards, gates, docs build, structure and packaging/smoke jobs. This does not certify unselected full Windows/macOS lanes or a live statusLine/account run. Review was requested from lidge-jun; no self-approval or merge was performed.

  6. added a commit that references this issue on Oct 1, 2026
    404ca8b
  7. lidge-jun commented on Oct 1, 2026

    @lidge-jun
    Owner

    Fixed on dev by #6356 (404ca8b). It ships in the next release.

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

    bugproxystreaming

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions