Skip to content

🀯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

πŸ› fix(model-runtime): handle Claude Opus 5.5 always-on thinking (#19867)

YuTengjingaa461c6b075d
diff --git a/packages/model-runtime/src/core/anthropicCompatibleFactory/resolveThinkingConfig.ts b/packages/model-runtime/src/core/anthropicCompatibleFactory/resolveThinkingConfig.ts
index a0a77e60a38..92746608d10 100644
--- a/packages/model-runtime/src/core/anthropicCompatibleFactory/resolveThinkingConfig.ts
+++ b/packages/model-runtime/src/core/anthropicCompatibleFactory/resolveThinkingConfig.ts
@@ -59,9 +59,9 @@ export const resolveClaudeThinkingConfig = ({
}
case 'disabled': {
- // Fable 5 / Mythos 5 reject `disabled` with a 400. Omitting the config is the documented
- // fallback: they think regardless, and their `omitted` display default already keeps the
- // reasoning text out of the response, which is what turning the switch off asks for.
+ // Fable 5 / Mythos 5 / Opus 5.5 reject `disabled` with a 400. Omitting the config is the
+ // documented fallback: they think regardless, and their `omitted` display default already
+ // keeps the reasoning text out of the response, which is what turning the switch off asks for.
if (isAlwaysThinkingClaudeModel(model)) return undefined;
// `display` is invalid alongside `disabled` β€” there is nothing to display β€” so any caller
diff --git a/packages/model-runtime/src/providers/anthropic/modelId.test.ts b/packages/model-runtime/src/providers/anthropic/modelId.test.ts
index 2ba9ad1790a..022db943b8c 100644
--- a/packages/model-runtime/src/providers/anthropic/modelId.test.ts
+++ b/packages/model-runtime/src/providers/anthropic/modelId.test.ts
@@ -160,6 +160,13 @@ describe('isAlwaysThinkingClaudeModel', () => {
expect(isAlwaysThinkingClaudeModel('global.anthropic.claude-fable-5')).toBe(true);
});
+ it('should return true for Opus 5.5 and later', () => {
+ expect(isAlwaysThinkingClaudeModel('claude-opus-5-5')).toBe(true);
+ expect(isAlwaysThinkingClaudeModel('global.anthropic.claude-opus-5-5')).toBe(true);
+ expect(isAlwaysThinkingClaudeModel('anthropic/claude-opus-5.5')).toBe(true);
+ expect(isAlwaysThinkingClaudeModel('claude-opus-6')).toBe(true);
+ });
+
it('should return false for models that accept disabled thinking', () => {
expect(isAlwaysThinkingClaudeModel('claude-opus-5')).toBe(false);
expect(isAlwaysThinkingClaudeModel('claude-sonnet-5')).toBe(false);
@@ -215,6 +222,13 @@ describe('rejectsForcedToolChoice', () => {
expect(rejectsForcedToolChoice('anthropic/claude-fable-5-1')).toBe(true);
});
+ it('should reject forced tool_choice on Opus 5.5 and later', () => {
+ expect(rejectsForcedToolChoice('claude-opus-5-5')).toBe(true);
+ expect(rejectsForcedToolChoice('global.anthropic.claude-opus-5-5')).toBe(true);
+ expect(rejectsForcedToolChoice('anthropic/claude-opus-5.5')).toBe(true);
+ expect(rejectsForcedToolChoice('claude-opus-6')).toBe(true);
+ });
+
it('should keep forced tool_choice valid on Fable 5 / Mythos 5 and other families', () => {
expect(rejectsForcedToolChoice('claude-fable-5')).toBe(false);
expect(rejectsForcedToolChoice('claude-mythos-5')).toBe(false);
diff --git a/packages/model-runtime/src/providers/anthropic/modelId.ts b/packages/model-runtime/src/providers/anthropic/modelId.ts
index fd587f3fd93..8c3299fc6c5 100644
--- a/packages/model-runtime/src/providers/anthropic/modelId.ts
+++ b/packages/model-runtime/src/providers/anthropic/modelId.ts
@@ -140,6 +140,15 @@ export const isAdaptiveThinkingDefaultOnModel = (model: string): boolean => {
return !!parsed && parsed.majorVersion >= 5;
};
+/**
+ * Claude Opus 5.5 and later carry the Fable 5.1 contract: thinking is always on and forced
+ * tool use is rejected. Opus 5 still accepts both.
+ * @see https://platform.claude.com/docs/en/models/opus-5-5/whats-new-opus-5-5#breaking-changes
+ */
+const isOpus55OrLater = (parsed: ParsedClaudeModelId): boolean =>
+ parsed.family === 'opus' &&
+ (parsed.majorVersion > 5 || (parsed.majorVersion === 5 && hasMinorVersionAtLeast(parsed, 5)));
+
/**
* Thinking cannot be turned off on these models β€” `thinking: {type: 'disabled'}` returns a 400.
* Callers should omit the thinking config instead; `display` is the way to hide reasoning text.
@@ -150,7 +159,9 @@ export const isAlwaysThinkingClaudeModel = (model: string): boolean => {
if (!parsed) return false;
// Claude Fable 5 and Claude Mythos 5 (and Claude Mythos Preview) always think.
- return isClaudeFamily(parsed, ['fable', 'mythos']) && parsed.majorVersion >= 5;
+ if (isClaudeFamily(parsed, ['fable', 'mythos']) && parsed.majorVersion >= 5) return true;
+
+ return isOpus55OrLater(parsed);
};
/**
@@ -218,14 +229,17 @@ export const supportsClaudeEffortLevel = (
};
/**
- * Claude Fable 5.1 / Mythos 5.1 reject forced tool use. `tool_choice` of type `any`
- * or `tool` returns a 400; keep `auto` (or `none`) and use `strict: true` for schema
- * enforcement instead. Fable 5 / Mythos 5 still accept forced choice.
+ * Claude Fable 5.1 / Mythos 5.1 / Opus 5.5 reject forced tool use. `tool_choice` of type
+ * `any` or `tool` returns a 400; keep `auto` (or `none`) and use `strict: true` for schema
+ * enforcement instead. Fable 5 / Mythos 5 / Opus 5 still accept forced choice.
* @see https://platform.claude.com/docs/en/models/fable-5-1/whats-new-fable-5-1#forced-tool-use-is-not-supported
+ * @see https://platform.claude.com/docs/en/models/opus-5-5/whats-new-opus-5-5#forced-tool-use-is-not-supported
*/
export const rejectsForcedToolChoice = (model: string): boolean => {
const parsed = parseClaudeModelId(model);
- if (!parsed || !isClaudeFamily(parsed, ['fable', 'mythos'])) return false;
+ if (!parsed) return false;
+ if (isOpus55OrLater(parsed)) return true;
+ if (!isClaudeFamily(parsed, ['fable', 'mythos'])) return false;
if (parsed.majorVersion > 5) return true;
return parsed.majorVersion === 5 && hasMinorVersionAtLeast(parsed, 1);