Skip to content

fix: inject anthropic service_tier for OAuth auth#55922

Merged
vincentkoc merged 4 commits intoopenclaw:mainfrom
Cypherm:fix/oauth-service-tier
Mar 29, 2026
Merged

fix: inject anthropic service_tier for OAuth auth#55922
vincentkoc merged 4 commits intoopenclaw:mainfrom
Cypherm:fix/oauth-service-tier

Conversation

@Cypherm
Copy link
Copy Markdown
Contributor

@Cypherm Cypherm commented Mar 27, 2026

No description provided.

@openclaw-barnacle openclaw-barnacle bot added agents Agent runtime and tooling size: XS labels Mar 27, 2026
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 27, 2026

Greptile Summary

This PR removes the OAuth token (sk-ant-oat-*) exclusion from createAnthropicFastModeWrapper, allowing OAuth-authenticated requests to receive service_tier injection (auto or standard_only) just like regular API key requests. This fixes unnecessary 529 overloaded errors for OAuth users during high API load. The isAnthropicOAuthApiKey helper remains in use in createAnthropicBetaHeadersWrapper for beta-header filtering, so it is not dead code.\n\nKey changes:\n- anthropic-stream-wrappers.ts: Removes || isAnthropicOAuthApiKey(options?.apiKey) from the early-return guard in createAnthropicFastModeWrapper\n- pi-embedded-runner-extraparams.test.ts: Flips the existing OAuth test assertion from "does not inject" to "injects auto"; adds a second regression test covering fastMode: falsestandard_only\n\nThe fix is correct, well-scoped, and well-tested. The existing guard at line 370 (if (payloadObj.service_tier === undefined)) ensures pre-set values are never overwritten.

Confidence Score: 5/5

This PR is safe to merge — the change is minimal, correct, and well-covered by updated tests.

One line removed from an early-return guard; the fix aligns OAuth token behavior with regular API key behavior and is backed by two targeted regression tests. No P0/P1 issues found.

No files require special attention.

Important Files Changed

Filename Overview
src/agents/pi-embedded-runner/anthropic-stream-wrappers.ts Removes the OAuth token exclusion from the service_tier injection guard — one-line fix, correct and minimal.
src/agents/pi-embedded-runner-extraparams.test.ts Flips existing OAuth test assertion and adds a regression test for fastMode: false → standard_only.

Reviews (1): Last reviewed commit: "fix: inject anthropic service_tier for O..." | Re-trigger Greptile

@Cypherm
Copy link
Copy Markdown
Contributor Author

Cypherm commented Mar 27, 2026

@vincentkoc — OAuth tokens now receive service_tier injection, matching Claude Code CLI behavior. Reduces avoidable 529 cascades during high API load. 2 files, +22/-4. Fixes #55758.

DanieleSalatti pushed a commit to DanieleSalatti/openclaw that referenced this pull request Mar 28, 2026
Remove the x-anthropic-billing-header, OAuth metadata injection, beta
fetch interceptor, and claude-cli-identity.ts. These impersonated Claude
Code at the API level to get Max-tier capacity routing.

Instead, rely on the legitimate approach:
- service_tier=auto for OAuth tokens (per PR openclaw#55922)
- OAuth betas always injected (per outage2 fix)

The billing header approach was fragile (caused 3 outages today) and
ethically questionable. If service_tier alone isn't sufficient, we'll
pursue the proper channel with Anthropic.
@Mdx2025

This comment was marked as spam.

@vincentkoc vincentkoc self-assigned this Mar 29, 2026
Cypherm and others added 2 commits March 30, 2026 07:40
Remove the OAuth-token exclusion from createAnthropicFastModeWrapper
so that sk-ant-oat-* requests receive service_tier injection, matching
Claude Code CLI behavior and reducing avoidable 529 overload cascades.

isAnthropicOAuthApiKey remains in use in createAnthropicBetaHeadersWrapper
for beta header selection — it is not dead code after this change.

Fixes openclaw#55758
@vincentkoc vincentkoc merged commit 924c264 into openclaw:main Mar 29, 2026
8 checks passed
@Mdx2025

This comment was marked as spam.

pritchie pushed a commit to pritchie/openclaw that referenced this pull request Mar 30, 2026
* fix: inject anthropic service_tier for OAuth auth

Remove the OAuth-token exclusion from createAnthropicFastModeWrapper
so that sk-ant-oat-* requests receive service_tier injection, matching
Claude Code CLI behavior and reducing avoidable 529 overload cascades.

isAnthropicOAuthApiKey remains in use in createAnthropicBetaHeadersWrapper
for beta header selection — it is not dead code after this change.

Fixes openclaw#55758

* docs(changelog): note anthropic oauth service tier fix

* Update CHANGELOG.md

---------

Co-authored-by: Cypherm <[email protected]>
Co-authored-by: Vincent Koc <[email protected]>
alexjiang1 pushed a commit to alexjiang1/openclaw that referenced this pull request Mar 31, 2026
* fix: inject anthropic service_tier for OAuth auth

Remove the OAuth-token exclusion from createAnthropicFastModeWrapper
so that sk-ant-oat-* requests receive service_tier injection, matching
Claude Code CLI behavior and reducing avoidable 529 overload cascades.

isAnthropicOAuthApiKey remains in use in createAnthropicBetaHeadersWrapper
for beta header selection — it is not dead code after this change.

Fixes openclaw#55758

* docs(changelog): note anthropic oauth service tier fix

* Update CHANGELOG.md

---------

Co-authored-by: Cypherm <[email protected]>
Co-authored-by: Vincent Koc <[email protected]>
livingghost pushed a commit to livingghost/openclaw that referenced this pull request Mar 31, 2026
* fix: inject anthropic service_tier for OAuth auth

Remove the OAuth-token exclusion from createAnthropicFastModeWrapper
so that sk-ant-oat-* requests receive service_tier injection, matching
Claude Code CLI behavior and reducing avoidable 529 overload cascades.

isAnthropicOAuthApiKey remains in use in createAnthropicBetaHeadersWrapper
for beta header selection — it is not dead code after this change.

Fixes openclaw#55758

* docs(changelog): note anthropic oauth service tier fix

* Update CHANGELOG.md

---------

Co-authored-by: Cypherm <[email protected]>
Co-authored-by: Vincent Koc <[email protected]>
pgondhi987 pushed a commit to pgondhi987/openclaw that referenced this pull request Mar 31, 2026
* fix: inject anthropic service_tier for OAuth auth

Remove the OAuth-token exclusion from createAnthropicFastModeWrapper
so that sk-ant-oat-* requests receive service_tier injection, matching
Claude Code CLI behavior and reducing avoidable 529 overload cascades.

isAnthropicOAuthApiKey remains in use in createAnthropicBetaHeadersWrapper
for beta header selection — it is not dead code after this change.

Fixes openclaw#55758

* docs(changelog): note anthropic oauth service tier fix

* Update CHANGELOG.md

---------

Co-authored-by: Cypherm <[email protected]>
Co-authored-by: Vincent Koc <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants