diff --git a/docs/gateway/troubleshooting.md b/docs/gateway/troubleshooting.md index 86874820b41..46d2c58b966 100644 --- a/docs/gateway/troubleshooting.md +++ b/docs/gateway/troubleshooting.md @@ -29,6 +29,35 @@ Expected healthy signals: - `openclaw doctor` reports no blocking config/service issues. - `openclaw channels status --probe` shows connected/ready channels. +## Anthropic 429 extra usage required for long context + +Use this when logs/errors include: +`HTTP 429: rate_limit_error: Extra usage is required for long context requests`. + +```bash +openclaw logs --follow +openclaw models status +openclaw config get agents.defaults.models +``` + +Look for: + +- Selected Anthropic Opus/Sonnet model has `params.context1m: true`. +- Current Anthropic credential is not eligible for long-context usage. +- Requests fail only on long sessions/model runs that need the 1M beta path. + +Fix options: + +1. Disable `context1m` for that model to fall back to the normal context window. +2. Use an Anthropic API key with billing, or enable Anthropic Extra Usage on the subscription account. +3. Configure fallback models so runs continue when Anthropic long-context requests are rejected. + +Related: + +- [/providers/anthropic](/providers/anthropic) +- [/reference/token-use](/reference/token-use) +- [/help/faq#why-am-i-seeing-http-429-ratelimiterror-from-anthropic](/help/faq#why-am-i-seeing-http-429-ratelimiterror-from-anthropic) + ## No replies If channels are up but nothing answers, check routing and policy before reconnecting anything. diff --git a/docs/help/faq.md b/docs/help/faq.md index 14757d24e09..10009ba1b7a 100644 --- a/docs/help/faq.md +++ b/docs/help/faq.md @@ -714,8 +714,15 @@ use a **Claude subscription** (setup-token or Claude Code OAuth), wait for the w reset or upgrade your plan. If you use an **Anthropic API key**, check the Anthropic Console for usage/billing and raise limits as needed. +If the message is specifically: +`Extra usage is required for long context requests`, the request is trying to use +Anthropic's 1M context beta (`context1m: true`). That only works when your +credential is eligible for long-context billing (API key billing or subscription +with Extra Usage enabled). + Tip: set a **fallback model** so OpenClaw can keep replying while a provider is rate-limited. -See [Models](/cli/models) and [OAuth](/concepts/oauth). +See [Models](/cli/models), [OAuth](/concepts/oauth), and +[/gateway/troubleshooting#anthropic-429-extra-usage-required-for-long-context](/gateway/troubleshooting#anthropic-429-extra-usage-required-for-long-context). ### Is AWS Bedrock supported diff --git a/docs/help/troubleshooting.md b/docs/help/troubleshooting.md index c4754da1867..4b6e93afe3c 100644 --- a/docs/help/troubleshooting.md +++ b/docs/help/troubleshooting.md @@ -34,6 +34,12 @@ Good output in one line: - `openclaw channels status --probe` → channels report `connected` or `ready`. - `openclaw logs --follow` → steady activity, no repeating fatal errors. +## Anthropic long context 429 + +If you see: +`HTTP 429: rate_limit_error: Extra usage is required for long context requests`, +go to [/gateway/troubleshooting#anthropic-429-extra-usage-required-for-long-context](/gateway/troubleshooting#anthropic-429-extra-usage-required-for-long-context). + ## Decision tree ```mermaid diff --git a/docs/providers/anthropic.md b/docs/providers/anthropic.md index 40f86630dba..69a0025d2f5 100644 --- a/docs/providers/anthropic.md +++ b/docs/providers/anthropic.md @@ -137,6 +137,14 @@ with `params.context1m: true` for supported Opus/Sonnet models. OpenClaw maps this to `anthropic-beta: context-1m-2025-08-07` on Anthropic requests. +This only activates when `params.context1m` is explicitly set to `true` for +that model. + +Requirement: Anthropic must allow long-context usage on that credential +(typically API key billing, or a subscription account with Extra Usage +enabled). Otherwise Anthropic returns: +`HTTP 429: rate_limit_error: Extra usage is required for long context requests`. + Note: Anthropic currently rejects `context-1m-*` beta requests when using OAuth/subscription tokens (`sk-ant-oat-*`). OpenClaw automatically skips the context1m beta header for OAuth auth and keeps the required OAuth betas. diff --git a/docs/reference/token-use.md b/docs/reference/token-use.md index 9127e2477e0..9e85c25e687 100644 --- a/docs/reference/token-use.md +++ b/docs/reference/token-use.md @@ -154,6 +154,12 @@ agents: This maps to Anthropic's `context-1m-2025-08-07` beta header. +This only applies when `context1m: true` is set on that model entry. + +Requirement: the credential must be eligible for long-context usage (API key +billing, or subscription with Extra Usage enabled). If not, Anthropic responds +with `HTTP 429: rate_limit_error: Extra usage is required for long context requests`. + If you authenticate Anthropic with OAuth/subscription tokens (`sk-ant-oat-*`), OpenClaw skips the `context-1m-*` beta header because Anthropic currently rejects that combination with HTTP 401. diff --git a/src/agents/context.test.ts b/src/agents/context.test.ts index 083fc5a8425..267755a8849 100644 --- a/src/agents/context.test.ts +++ b/src/agents/context.test.ts @@ -103,6 +103,27 @@ describe("resolveContextTokensForModel", () => { expect(result).toBe(ANTHROPIC_CONTEXT_1M_TOKENS); }); + it("does not force 1M context when context1m is not enabled", () => { + const result = resolveContextTokensForModel({ + cfg: { + agents: { + defaults: { + models: { + "anthropic/claude-opus-4-6": { + params: {}, + }, + }, + }, + }, + }, + provider: "anthropic", + model: "claude-opus-4-6", + fallbackContextTokens: 200_000, + }); + + expect(result).toBe(200_000); + }); + it("does not force 1M context for non-opus/sonnet Anthropic models", () => { const result = resolveContextTokensForModel({ cfg: { diff --git a/src/agents/pi-embedded-runner-extraparams.test.ts b/src/agents/pi-embedded-runner-extraparams.test.ts index 8689315658e..5f45ebe7caa 100644 --- a/src/agents/pi-embedded-runner-extraparams.test.ts +++ b/src/agents/pi-embedded-runner-extraparams.test.ts @@ -763,6 +763,19 @@ describe("applyExtraParamsToAgent", () => { }); }); + it("does not add Anthropic 1M beta header when context1m is not enabled", () => { + const cfg = buildAnthropicModelConfig("anthropic/claude-opus-4-6", { + temperature: 0.2, + }); + const headers = runAnthropicHeaderCase({ + cfg, + modelId: "claude-opus-4-6", + options: { headers: { "X-Custom": "1" } }, + }); + + expect(headers).toEqual({ "X-Custom": "1" }); + }); + it("skips context1m beta for OAuth tokens but preserves OAuth-required betas", () => { const calls: Array = []; const baseStreamFn: StreamFn = (_model, _context, options) => {