Skip to content

Commit 6f41417

Browse files
feat(anthropic): add Claude Opus 5 model support
Wire claude-opus-5 through the Claude 5 contract seams: adaptive-by-default thinking with the full low..max effort range, default-sampling and prefill stripping, streaming refusal contract, model-bound thinking replay, and 1M/128k catalog metadata across anthropic, claude-cli, Vertex, Bedrock, and Mantle. Co-Authored-By: Claude Fable 5 <[email protected]>
1 parent e9b3252 commit 6f41417

29 files changed

Lines changed: 256 additions & 50 deletions

‎docs/providers/anthropic.md‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,15 @@ remain read-only even on a continuation-enabled node.
281281
See [Nodes: Claude sessions and transcripts](/nodes#claude-sessions-and-transcripts)
282282
for the node command and security boundary.
283283

284-
## Thinking defaults (Claude Sonnet 5, Mythos 5, Fable 5, 4.8, and 4.6)
284+
## Thinking defaults (Claude Opus 5, Sonnet 5, Mythos 5, Fable 5, 4.8, and 4.6)
285+
286+
`anthropic/claude-opus-5` uses adaptive thinking at `high` effort by default
287+
and supports the full `low` through `max` effort range. Use `/think off` to
288+
disable thinking (Anthropic allows that only at effort `high` or below), or
289+
`/think xhigh|max` for the higher native effort levels. OpenClaw omits manual
290+
thinking budgets, custom sampling parameters, and assistant prefills for
291+
Opus 5 because Anthropic rejects those request features on this model. The 1M
292+
context window is the model default — no `[1m]` opt-in is needed.
285293

286294
`anthropic/claude-sonnet-5` uses adaptive thinking at `high` effort by default.
287295
Use `/think off` to disable thinking, or `/think xhigh|max` for the model's

‎extensions/amazon-bedrock-mantle/mantle-anthropic.runtime.ts‎

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
import {
1414
requiresClaudeDefaultSampling,
1515
resolveClaudeMythos5ModelIdentity,
16+
resolveClaudeOpus5ModelIdentity,
1617
resolveClaudeSonnet5ModelIdentity,
1718
} from "openclaw/plugin-sdk/provider-model-shared";
1819
import { buildGuardedModelFetch } from "openclaw/plugin-sdk/provider-transport-runtime";
@@ -37,6 +38,10 @@ function isClaudeSonnet5Model(model: Model): boolean {
3738
return resolveClaudeSonnet5ModelIdentity(model) !== undefined;
3839
}
3940

41+
function isClaudeOpus5Model(model: Model): boolean {
42+
return resolveClaudeOpus5ModelIdentity(model) !== undefined;
43+
}
44+
4045
function requiresDefaultSampling(model: Model): boolean {
4146
return requiresClaudeDefaultSampling(model);
4247
}
@@ -69,11 +74,14 @@ function resolveMantleReasoning(
6974
if (model.id.includes("claude-opus-4-7")) {
7075
return undefined;
7176
}
72-
const sonnet5 = isClaudeSonnet5Model(model);
77+
// Sonnet 5 and Opus 5 default thinking on and keep it enabled on Bedrock,
78+
// matching resolveBedrockNativeThinkingLevelMap's off->low remap.
79+
const adaptiveDefaultClaude5 = isClaudeSonnet5Model(model) || isClaudeOpus5Model(model);
7380
const mythosPreview = isClaudeMythosPreviewModel(model);
7481
const mandatoryMythos = isClaudeMythos5Model(model) || mythosPreview;
75-
const reasoning = options?.reasoning ?? (mandatoryMythos || sonnet5 ? "high" : undefined);
76-
if (sonnet5) {
82+
const reasoning =
83+
options?.reasoning ?? (mandatoryMythos || adaptiveDefaultClaude5 ? "high" : undefined);
84+
if (adaptiveDefaultClaude5) {
7785
return reasoning === "off" || reasoning === "minimal" ? "low" : reasoning;
7886
}
7987
if (!mandatoryMythos) {
@@ -85,7 +93,7 @@ function resolveMantleReasoning(
8593
return mythosPreview && (reasoning === "xhigh" || reasoning === "max") ? "high" : reasoning;
8694
}
8795

88-
function mapSonnet5Effort(
96+
function mapClaude5Effort(
8997
reasoning: NonNullable<SimpleStreamOptions["reasoning"]>,
9098
): "low" | "medium" | "high" | "xhigh" | "max" {
9199
if (reasoning === "minimal" || reasoning === "low") {
@@ -118,7 +126,7 @@ function buildMantleAnthropicBaseOptions(
118126
...(requiresDefaultSampling(model) ? {} : { temperature: options?.temperature }),
119127
maxTokens:
120128
options?.maxTokens ||
121-
(isClaudeSonnet5Model(model) || isClaudeMythos5Model(model)
129+
(isClaudeSonnet5Model(model) || isClaudeOpus5Model(model) || isClaudeMythos5Model(model)
122130
? model.maxTokens
123131
: Math.min(model.maxTokens, 32_000)),
124132
signal: options?.signal,
@@ -185,7 +193,7 @@ export function createMantleAnthropicStreamFn(deps?: {
185193
// The client API is the same, but the SDK class private field makes types nominal.
186194
const streamClient = client as unknown as Anthropic;
187195
const reasoning = resolveMantleReasoning(model, options);
188-
const sonnet5 = isClaudeSonnet5Model(model);
196+
const claude5Effort = isClaudeSonnet5Model(model) || isClaudeOpus5Model(model);
189197
const mythos5 = isClaudeMythos5Model(model);
190198
if (!reasoning || reasoning === "off") {
191199
return streamFn(model as Model<"anthropic-messages">, context, {
@@ -195,12 +203,12 @@ export function createMantleAnthropicStreamFn(deps?: {
195203
});
196204
}
197205

198-
if (sonnet5 || mythos5) {
206+
if (claude5Effort || mythos5) {
199207
return streamFn(model as Model<"anthropic-messages">, context, {
200208
...base,
201209
client: streamClient,
202210
thinkingEnabled: true,
203-
effort: sonnet5 ? mapSonnet5Effort(reasoning) : reasoning,
211+
effort: claude5Effort ? mapClaude5Effort(reasoning) : reasoning,
204212
});
205213
}
206214

‎extensions/amazon-bedrock/discovery.ts‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
resolveClaudeFable5ModelIdentity,
2323
resolveClaudeModelIdentity,
2424
resolveClaudeMythos5ModelIdentity,
25+
resolveClaudeOpus5ModelIdentity,
2526
resolveClaudeSonnet5ModelIdentity,
2627
supportsClaudeAdaptiveThinking,
2728
} from "openclaw/plugin-sdk/provider-model-shared";
@@ -71,6 +72,7 @@ const KNOWN_CONTEXT_WINDOWS: Record<string, number> = {
7172
"anthropic.claude-mythos-5": 1_000_000,
7273
// AWS publishes Sonnet 5 on both bedrock-runtime (Invoke/Converse) and Mantle.
7374
"anthropic.claude-sonnet-5": 1_000_000,
75+
"anthropic.claude-opus-5": 1_000_000,
7476
"anthropic.claude-3-7-sonnet-20250219-v1:0": 200_000,
7577
"anthropic.claude-opus-4-8": 1_000_000,
7678
"anthropic.claude-opus-4-7": 1_000_000,
@@ -149,7 +151,8 @@ function resolveKnownContextWindow(modelId: string): number | undefined {
149151
if (
150152
resolveClaudeFable5ModelIdentity({ id: candidate }) ||
151153
resolveClaudeMythos5ModelIdentity({ id: candidate }) ||
152-
resolveClaudeSonnet5ModelIdentity({ id: candidate })
154+
resolveClaudeSonnet5ModelIdentity({ id: candidate }) ||
155+
resolveClaudeOpus5ModelIdentity({ id: candidate })
153156
) {
154157
return 1_000_000;
155158
}
@@ -186,15 +189,17 @@ function resolveKnownThinkingLevelMap(
186189
function resolveKnownMaxTokens(modelId: string): number | undefined {
187190
return resolveClaudeFable5ModelIdentity({ id: modelId }) ||
188191
resolveClaudeMythos5ModelIdentity({ id: modelId }) ||
189-
resolveClaudeSonnet5ModelIdentity({ id: modelId })
192+
resolveClaudeSonnet5ModelIdentity({ id: modelId }) ||
193+
resolveClaudeOpus5ModelIdentity({ id: modelId })
190194
? 128_000
191195
: undefined;
192196
}
193197

194198
function resolveKnownInput(modelId: string): ModelDefinitionConfig["input"] | undefined {
195199
return resolveClaudeFable5ModelIdentity({ id: modelId }) ||
196200
resolveClaudeMythos5ModelIdentity({ id: modelId }) ||
197-
resolveClaudeSonnet5ModelIdentity({ id: modelId })
201+
resolveClaudeSonnet5ModelIdentity({ id: modelId }) ||
202+
resolveClaudeOpus5ModelIdentity({ id: modelId })
198203
? ["text", "image"]
199204
: undefined;
200205
}

‎extensions/amazon-bedrock/thinking-policy.ts‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
resolveClaudeFable5ModelIdentity,
1111
resolveClaudeModelIdentity,
1212
resolveClaudeMythos5ModelIdentity,
13+
resolveClaudeOpus5ModelIdentity,
1314
resolveClaudeSonnet5ModelIdentity,
1415
} from "openclaw/plugin-sdk/provider-model-shared";
1516

@@ -62,6 +63,7 @@ export function isLatestAdaptiveBedrockModelRef(
6263
resolveClaudeFable5ModelIdentity(modelRef) !== undefined ||
6364
resolveClaudeMythos5ModelIdentity(modelRef) !== undefined ||
6465
resolveClaudeSonnet5ModelIdentity(modelRef) !== undefined ||
66+
resolveClaudeOpus5ModelIdentity(modelRef) !== undefined ||
6567
[modelId, canonicalModelId].some(
6668
(candidate) =>
6769
isOpus47OrNewerBedrockModelRef(candidate) || isMythosPreviewBedrockModelRef(candidate),
@@ -77,7 +79,8 @@ export function supportsBedrockNativeMaxEffort(
7779
if (
7880
resolveClaudeFable5ModelIdentity({ id: modelId, params }) ||
7981
resolveClaudeMythos5ModelIdentity({ id: modelId, params }) ||
80-
resolveClaudeSonnet5ModelIdentity({ id: modelId, params })
82+
resolveClaudeSonnet5ModelIdentity({ id: modelId, params }) ||
83+
resolveClaudeOpus5ModelIdentity({ id: modelId, params })
8184
) {
8285
return true;
8386
}
@@ -96,7 +99,7 @@ export function resolveBedrockNativeThinkingLevelMap(
9699
if (resolveClaudeFable5ModelIdentity(modelRef) || resolveClaudeMythos5ModelIdentity(modelRef)) {
97100
return { off: "low", minimal: "low", xhigh: "xhigh", max: "max" };
98101
}
99-
if (resolveClaudeSonnet5ModelIdentity(modelRef)) {
102+
if (resolveClaudeSonnet5ModelIdentity(modelRef) || resolveClaudeOpus5ModelIdentity(modelRef)) {
100103
return { off: "low", minimal: "low", xhigh: "xhigh", max: "max" };
101104
}
102105
if (!supportsBedrockNativeMaxEffort(modelId, params)) {
@@ -120,7 +123,8 @@ export function resolveBedrockClaudeThinkingProfile(
120123
if (
121124
resolveClaudeFable5ModelIdentity({ id: trimmed, params }) ||
122125
resolveClaudeMythos5ModelIdentity({ id: trimmed, params }) ||
123-
resolveClaudeSonnet5ModelIdentity({ id: trimmed, params })
126+
resolveClaudeSonnet5ModelIdentity({ id: trimmed, params }) ||
127+
resolveClaudeOpus5ModelIdentity({ id: trimmed, params })
124128
) {
125129
return {
126130
levels: [...BASE_CLAUDE_THINKING_LEVELS, { id: "xhigh" }, { id: "adaptive" }, { id: "max" }],

‎extensions/anthropic-vertex/index.test.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ describe("anthropic-vertex provider plugin", () => {
8181
expect(result.provider.models.map((model) => model.id)).toEqual([
8282
"claude-fable-5",
8383
"claude-mythos-5",
84+
"claude-opus-5",
8485
"claude-opus-4-8",
8586
"claude-opus-4-6",
8687
"claude-sonnet-4-6",
@@ -98,8 +99,9 @@ describe("anthropic-vertex provider plugin", () => {
9899
max: "max",
99100
});
100101
expect(result.provider.models[2]?.thinkingLevelMap).toEqual({ xhigh: "xhigh", max: "max" });
101-
expect(result.provider.models[3]?.thinkingLevelMap).toEqual({ xhigh: null, max: "max" });
102+
expect(result.provider.models[3]?.thinkingLevelMap).toEqual({ xhigh: "xhigh", max: "max" });
102103
expect(result.provider.models[4]?.thinkingLevelMap).toEqual({ xhigh: null, max: "max" });
104+
expect(result.provider.models[5]?.thinkingLevelMap).toEqual({ xhigh: null, max: "max" });
103105
});
104106

105107
it.each(["global", "us", "eu"])("publishes Sonnet 5 for the %s endpoint", (region) => {

‎extensions/anthropic-vertex/provider-catalog.ts‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,18 @@ function buildAnthropicVertexCatalog(region: string, nowMs: number): ModelDefini
111111
thinkingLevelMap: { off: "low", minimal: "low", xhigh: "xhigh", max: "max" },
112112
}),
113113
...sonnet5,
114+
buildAnthropicVertexModel({
115+
id: "claude-opus-5",
116+
name: "Claude Opus 5",
117+
reasoning: true,
118+
input: ["text", "image"],
119+
cost: { input: 5, output: 25, cacheRead: 0.5, cacheWrite: 6.25 },
120+
maxTokens: ANTHROPIC_VERTEX_CLAUDE_5_MAX_TOKENS,
121+
mediaInput: {
122+
image: { maxSidePx: 2576, preferredSidePx: 2576, tokenMode: "provider" },
123+
},
124+
thinkingLevelMap: { xhigh: "xhigh", max: "max" },
125+
}),
114126
buildAnthropicVertexModel({
115127
id: "claude-opus-4-8",
116128
name: "Claude Opus 4.8",

‎extensions/anthropic-vertex/stream-runtime.ts‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
resolveClaudeFable5ModelIdentity,
1717
resolveClaudeModelIdentity,
1818
resolveClaudeMythos5ModelIdentity,
19+
resolveClaudeOpus5ModelIdentity,
1920
resolveClaudeSonnet5ModelIdentity,
2021
requiresClaudeMandatoryAdaptiveThinking,
2122
supportsClaudeAdaptiveThinking,
@@ -87,6 +88,10 @@ function isClaudeSonnet5Model(modelId: string): boolean {
8788
return resolveClaudeSonnet5ModelIdentity({ id: modelId }) !== undefined;
8889
}
8990

91+
function isClaudeOpus5Model(modelId: string): boolean {
92+
return resolveClaudeOpus5ModelIdentity({ id: modelId }) !== undefined;
93+
}
94+
9095
function isClaudeMythos5Model(modelId: string): boolean {
9196
return resolveClaudeMythos5ModelIdentity({ id: modelId }) !== undefined;
9297
}
@@ -193,15 +198,18 @@ export function createAnthropicVertexStreamFn(
193198
requestedMaxTokens: options?.maxTokens,
194199
});
195200
const contractModelId = resolveClaudeModelIdentity(model);
196-
const sonnet5 = isClaudeSonnet5Model(contractModelId);
201+
// Sonnet 5 and Opus 5 default thinking on when the caller omits reasoning.
202+
const adaptiveDefaultClaude5 =
203+
isClaudeSonnet5Model(contractModelId) || isClaudeOpus5Model(contractModelId);
197204
const mandatoryAdaptiveThinking = requiresClaudeMandatoryAdaptiveThinking({
198205
id: contractModelId,
199206
});
200207
const requestedReasoning = options?.reasoning;
201208
const reasoning =
202209
requestedReasoning === "off" && mandatoryAdaptiveThinking
203210
? "low"
204-
: (requestedReasoning ?? (mandatoryAdaptiveThinking || sonnet5 ? "high" : undefined));
211+
: (requestedReasoning ??
212+
(mandatoryAdaptiveThinking || adaptiveDefaultClaude5 ? "high" : undefined));
205213
const adaptiveThinking =
206214
mandatoryAdaptiveThinking ||
207215
Boolean(reasoning && reasoning !== "off" && supportsAdaptiveThinking(contractModelId));

‎extensions/anthropic/cli-catalog.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@ import { CLAUDE_CLI_BACKEND_ID, CLAUDE_CLI_DEFAULT_ALLOWLIST_REFS } from "./cli-
88
// Claude CLI auth is subscription-backed, so catalog rows only need picker metadata.
99
const CLAUDE_CLI_DEFAULT_CONTEXT_WINDOW = 200_000;
1010
const CLAUDE_CLI_CONTEXT_WINDOWS: Record<string, number> = {
11+
"claude-opus-5": 1_000_000,
1112
"claude-sonnet-5": 1_000_000,
1213
"claude-fable-5": 1_000_000,
1314
};
1415
const CLAUDE_CLI_DEFAULT_MAX_OUTPUT_TOKENS = 64_000;
1516
const CLAUDE_CLI_MAX_OUTPUT_TOKENS: Record<string, number> = {
17+
"claude-opus-5": 128_000,
1618
"claude-opus-4-8": 128_000,
1719
"claude-opus-4-7": 128_000,
1820
"claude-opus-4-6": 128_000,
@@ -22,6 +24,7 @@ const CLAUDE_CLI_MAX_OUTPUT_TOKENS: Record<string, number> = {
2224
};
2325

2426
const CLAUDE_CLI_MODEL_LABELS: Record<string, string> = {
27+
"claude-opus-5": "Claude Opus 5 (Claude CLI)",
2528
"claude-opus-4-8": "Claude Opus 4.8 (Claude CLI)",
2629
"claude-opus-4-7": "Claude Opus 4.7 (Claude CLI)",
2730
"claude-opus-4-6": "Claude Opus 4.6 (Claude CLI)",
@@ -32,6 +35,7 @@ const CLAUDE_CLI_MODEL_LABELS: Record<string, string> = {
3235

3336
function resolveClaudeCliImageMediaInput(id: string): ModelCatalogEntry["mediaInput"] {
3437
const maxSidePx =
38+
id === "claude-opus-5" ||
3539
id === "claude-opus-4-8" ||
3640
id === "claude-opus-4-7" ||
3741
id === "claude-sonnet-5" ||

‎extensions/anthropic/cli-constants.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export const CLAUDE_CLI_CANONICAL_DEFAULT_MODEL_REF = `anthropic/${CLAUDE_CLI_CA
1919
/** Default Claude CLI models allowed when setup seeds the model allowlist. */
2020
export const CLAUDE_CLI_DEFAULT_ALLOWLIST_REFS = [
2121
CLAUDE_CLI_DEFAULT_MODEL_REF,
22+
`${CLAUDE_CLI_BACKEND_ID}/claude-opus-5`,
2223
`${CLAUDE_CLI_BACKEND_ID}/claude-sonnet-5`,
2324
`${CLAUDE_CLI_BACKEND_ID}/claude-fable-5`,
2425
`${CLAUDE_CLI_BACKEND_ID}/claude-opus-4-7`,
@@ -29,6 +30,8 @@ export const CLAUDE_CLI_DEFAULT_ALLOWLIST_REFS = [
2930
/** User-facing Claude CLI model aliases normalized before execution. */
3031
export const CLAUDE_CLI_MODEL_ALIASES: Record<string, string> = {
3132
opus: "opus",
33+
"opus-5": "claude-opus-5",
34+
"claude-opus-5": "claude-opus-5",
3235
"opus-4.8": "claude-opus-4-8",
3336
"opus-4.7": "claude-opus-4-7",
3437
"opus-4.6": "claude-opus-4-6",

‎extensions/anthropic/cli-migration.test.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ describe("anthropic cli migration", () => {
186186
},
187187
"openai/gpt-5.2": {},
188188
"anthropic/claude-opus-4-8": { agentRuntime: { id: "claude-cli" } },
189+
"anthropic/claude-opus-5": { agentRuntime: { id: "claude-cli" } },
189190
"anthropic/claude-sonnet-5": { agentRuntime: { id: "claude-cli" } },
190191
"anthropic/claude-fable-5": { agentRuntime: { id: "claude-cli" } },
191192
"anthropic/claude-sonnet-4-6": { agentRuntime: { id: "claude-cli" } },
@@ -276,6 +277,7 @@ describe("anthropic cli migration", () => {
276277
"openai/gpt-5.2": {},
277278
"anthropic/claude-opus-4-7": { agentRuntime: { id: "claude-cli" } },
278279
"anthropic/claude-opus-4-8": { agentRuntime: { id: "claude-cli" } },
280+
"anthropic/claude-opus-5": { agentRuntime: { id: "claude-cli" } },
279281
"anthropic/claude-sonnet-5": { agentRuntime: { id: "claude-cli" } },
280282
"anthropic/claude-fable-5": { agentRuntime: { id: "claude-cli" } },
281283
"anthropic/claude-sonnet-4-6": { agentRuntime: { id: "claude-cli" } },
@@ -322,6 +324,7 @@ describe("anthropic cli migration", () => {
322324
models: {
323325
"anthropic/claude-opus-4-7": { agentRuntime: { id: "claude-cli" } },
324326
"anthropic/claude-opus-4-8": { agentRuntime: { id: "claude-cli" } },
327+
"anthropic/claude-opus-5": { agentRuntime: { id: "claude-cli" } },
325328
"anthropic/claude-sonnet-5": { agentRuntime: { id: "claude-cli" } },
326329
"anthropic/claude-fable-5": { agentRuntime: { id: "claude-cli" } },
327330
"anthropic/claude-sonnet-4-6": { agentRuntime: { id: "claude-cli" } },

0 commit comments

Comments
 (0)