docs: clarify Anthropic context1m long-context requirements

This commit is contained in:
Agent
2026-03-01 22:35:12 +00:00
parent a374325fc2
commit 063c4f00ea
7 changed files with 91 additions and 1 deletions

View File

@@ -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.

View File

@@ -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

View File

@@ -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

View File

@@ -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.

View File

@@ -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.

View File

@@ -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: {

View File

@@ -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<SimpleStreamOptions | undefined> = [];
const baseStreamFn: StreamFn = (_model, _context, options) => {