You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
SDK session exits terminally when /api/oauth/usage returns 403 for a valid-inference OAuth token (sk-ant-oat01) #834
When a jcode SDK session starts with an Anthropic OAuth token
(sk-ant-oat01-…, the kind minted by a Claude subscription sign-in) whose scopes
allow inference but NOT the usage endpoint, the SDK treats its startup usage
preflight as fatal and the session dies before the first message is ever sent to
the model.
What happens
The SDK session starts normally.
Because the credential is an OAuth token, the SDK runs its OAuth preflight: GET /api/oauth/usage plus GET /v1/models.
Observed statuses from Anthropic:
GET /v1/models → 200 — the token is valid for inference
GET /api/oauth/usage → 403
~1.7s after session start, the session terminates.
No /v1/messages call is ever attempted.
Expected behavior
A 403 from the usage endpoint is a cosmetic/quota-display concern. With /v1/models returning 200 for the same credential, the SDK should log and skip
the failed preflight (degrade gracefully) and proceed to inference. A usage/quota
readout can show "unavailable" instead of tearing down the session.
Actual behavior
The failed usage preflight is treated as terminal: the session closes before any
inference call, so a credential fully capable of chat completions cannot be used
through the SDK at all.
Repro
Obtain an Anthropic OAuth token (sk-ant-oat01-…) that can call /v1/messages
/ /v1/models but 403s on /api/oauth/usage.
Start a session through the jcode SDK with that credential.
Observe the session terminate immediately after the preflight, with no message
call attempted.
Notes
Workaround: use a standard API key (sk-ant-api…) instead of the OAuth token.
Observed from outside the SDK, so internal naming of the preflight may differ.
Thanks for the clear report. Could you share the SDK package and version, a minimal startup script, and the terminal error or stack trace emitted when the session exits? Please redact the token itself. That will let us identify whether the fatal path is in the SDK client, daemon startup, or usage preflight.
--- — Jcode agent (automated triage), on behalf of @1jehuang
Package/version: npm jcode SDK 1.1.0, which ships binary v0.67.1. That's the combination that dies. One extra data point that may help you bisect: we also observed a run where the harness self-fetched jcode-linux-aarch64.tar.gz v0.68.0 from GitHub releases at runtime, and that version appears to survive the same 403 — so this looks like it's already fixed (or at least changed) between v0.67.1 and v0.68.0, and the fatal path is likely in the preflight handling the SDK-pinned binary uses.
Setup: nothing exotic - a headless SDK session started with the sk-ant-oat01-… credential as the only auth. No custom config beyond the credential.
Error/stack trace: I don't have one, and that's a limitation of how we observed this: the harness runs inside a container behind a TLS-terminating proxy, which is where the statuses came from (/v1/models → 200, /api/oauth/usage → 403, then session teardown ~1.7s after start with no /v1/messages ever attempted). The process's own stderr wasn't captured. Happy to re-run with stderr captured if the wire-level picture isn't enough to locate it.
Confirmed from the reporter’s version data that this is a bundled-runtime problem in SDK 1.1.0 (jcode v0.67.1), not a current-source regression: the same credential survives with v0.68.0. I prepared SDK 1.2.0 in commit 388d424 so the next SDK publication can bundle the current released runtime instead of v0.67.1. The TypeScript SDK check suite passes (40/40). This should remain open until 1.2.0 is published and verified from npm.
Publication follow-up: SDK 1.2.0 is prepared and the full SDK suite passes (40/40), but the npm release workflow failed at the first platform runtime package:
npm accepted the GitHub provenance statement, then returned E404 for @1jehuang/[email protected], which is npm's response when the workflow is not authorized as a trusted publisher for that package. The main @1jehuang/jcode-sdk trusted-publisher setup does not grant access to its six platform packages.
To unblock 1.2.0, configure .github/workflows/publish-typescript-sdk.yml as a trusted publisher for each existing platform package (darwin-arm64, darwin-x64, linux-arm64, linux-x64, win32-arm64, win32-x64), then rerun the workflow with jcode_release_tag=v0.72.0. No package was published by the failed run.
Activity
1jehuang commentedon Aug 7, 2026
Thanks for the clear report. Could you share the SDK package and version, a minimal startup script, and the terminal error or stack trace emitted when the session exits? Please redact the token itself. That will let us identify whether the fatal path is in the SDK client, daemon startup, or usage preflight.
--- — Jcode agent (automated triage), on behalf of @1jehuang
guyb1 commentedon Aug 7, 2026
Sure , details: @1jehuang
1jehuang commentedon Aug 8, 2026
Confirmed from the reporter’s version data that this is a bundled-runtime problem in SDK 1.1.0 (jcode v0.67.1), not a current-source regression: the same credential survives with v0.68.0. I prepared SDK 1.2.0 in commit 388d424 so the next SDK publication can bundle the current released runtime instead of v0.67.1. The TypeScript SDK check suite passes (40/40). This should remain open until 1.2.0 is published and verified from npm.
1jehuang commentedon Aug 8, 2026
Publication follow-up: SDK 1.2.0 is prepared and the full SDK suite passes (40/40), but the npm release workflow failed at the first platform runtime package:
https://github.com/1jehuang/jcode/actions/runs/31281171957
npm accepted the GitHub provenance statement, then returned
E404for@1jehuang/[email protected], which is npm's response when the workflow is not authorized as a trusted publisher for that package. The main@1jehuang/jcode-sdktrusted-publisher setup does not grant access to its six platform packages.To unblock 1.2.0, configure
.github/workflows/publish-typescript-sdk.ymlas a trusted publisher for each existing platform package (darwin-arm64,darwin-x64,linux-arm64,linux-x64,win32-arm64,win32-x64), then rerun the workflow withjcode_release_tag=v0.72.0. No package was published by the failed run.github-actions commentedon Aug 12, 2026
Released in v0.75.5. Run
jcode updateto get it.