Skip to content

A self-improving RLM agent for coding workflows and long-running autonomous tasks.

Rust

add claude fable 5 support (#302)

kt9f7c8ff1f916
diff --git a/packages/ai/scripts/generate-models.ts b/packages/ai/scripts/generate-models.ts
index ad472bf44c..74246a929e 100644
--- a/packages/ai/scripts/generate-models.ts
+++ b/packages/ai/scripts/generate-models.ts
@@ -227,7 +227,8 @@ function applyThinkingLevelMetadata(model: Model<any>): void {
model.id.includes("opus-4-7") ||
model.id.includes("opus-4.7") ||
model.id.includes("opus-4-8") ||
- model.id.includes("opus-4.8")
+ model.id.includes("opus-4.8") ||
+ model.id.includes("sonnet-5")
) {
mergeThinkingLevelMap(model, { xhigh: "xhigh", max: "max" });
}
diff --git a/packages/ai/src/providers/amazon-bedrock.ts b/packages/ai/src/providers/amazon-bedrock.ts
index 47ff3f76c2..9d93a9023d 100644
--- a/packages/ai/src/providers/amazon-bedrock.ts
+++ b/packages/ai/src/providers/amazon-bedrock.ts
@@ -202,7 +202,8 @@ export const streamBedrock: StreamFunction<"bedrock-converse-stream", BedrockOpt
system: buildSystemPrompt(context.systemPrompt, model, cacheRetention),
inferenceConfig: {
...(options.maxTokens !== undefined && { maxTokens: options.maxTokens }),
- ...(options.temperature !== undefined && { temperature: options.temperature }),
+ ...(options.temperature !== undefined &&
+ !supportsAlwaysOnAdaptiveThinking(model.id, model.name) && { temperature: options.temperature }),
},
toolConfig: convertToolConfig(context.tools, options.toolChoice),
additionalModelRequestFields: buildAdditionalModelRequestFields(model, options),
@@ -497,12 +498,21 @@ function supportsAdaptiveThinking(modelId: string, modelName?: string): boolean
s.includes("opus-4-7") ||
s.includes("opus-4-8") ||
s.includes("sonnet-4-6") ||
+ s.includes("sonnet-5") ||
s.includes("fable-5") ||
s.includes("mythos-5") ||
s.includes("mythos-preview"),
);
}
+/**
+ * Fable/Mythos models think every turn and reject sampling params with a 400.
+ */
+function supportsAlwaysOnAdaptiveThinking(modelId: string, modelName?: string): boolean {
+ const candidates = getModelMatchCandidates(modelId, modelName);
+ return candidates.some((s) => s.includes("fable-5") || s.includes("mythos-5") || s.includes("mythos-preview"));
+}
+
function mapThinkingLevelToEffort(
model: Model<"bedrock-converse-stream">,
level: SimpleStreamOptions["reasoning"],
diff --git a/packages/ai/src/providers/anthropic.ts b/packages/ai/src/providers/anthropic.ts
index 3dafdf9d49..712536e90c 100644
--- a/packages/ai/src/providers/anthropic.ts
+++ b/packages/ai/src/providers/anthropic.ts
@@ -675,6 +675,14 @@ export const streamAnthropic: StreamFunction<"anthropic-messages", AnthropicOpti
return stream;
};
+/**
+ * Fable/Mythos models think every turn and reject an explicit
+ * `thinking: {type: "disabled"}` (and any sampling params) with a 400.
+ */
+function isAlwaysOnAdaptiveThinkingModel(modelId: string): boolean {
+ return modelId.includes("fable-5") || modelId.includes("mythos-5") || modelId.includes("mythos-preview");
+}
+
/**
* Check if a model supports adaptive thinking (Opus 4.6+, Sonnet 4.6)
*/
@@ -689,6 +697,7 @@ function supportsAdaptiveThinking(modelId: string): boolean {
modelId.includes("opus-4.8") ||
modelId.includes("sonnet-4-6") ||
modelId.includes("sonnet-4.6") ||
+ modelId.includes("sonnet-5") ||
modelId.includes("fable-5") ||
modelId.includes("mythos-5") ||
modelId.includes("mythos-preview")
@@ -920,8 +929,9 @@ function buildParams(
];
}
- // Temperature is incompatible with extended thinking (adaptive or budget-based).
- if (options?.temperature !== undefined && !options?.thinkingEnabled) {
+ // Temperature is incompatible with extended thinking (adaptive or budget-based),
+ // and always-on models reject sampling params outright.
+ if (options?.temperature !== undefined && !options?.thinkingEnabled && !isAlwaysOnAdaptiveThinkingModel(model.id)) {
params.temperature = options.temperature;
}
@@ -961,7 +971,7 @@ function buildParams(
display,
};
}
- } else if (options?.thinkingEnabled === false) {
+ } else if (options?.thinkingEnabled === false && !isAlwaysOnAdaptiveThinkingModel(model.id)) {
params.thinking = { type: "disabled" };
}
}
diff --git a/packages/ai/test/anthropic-thinking-disable.test.ts b/packages/ai/test/anthropic-thinking-disable.test.ts
index 6fbf3c1d61..543e409326 100644
--- a/packages/ai/test/anthropic-thinking-disable.test.ts
+++ b/packages/ai/test/anthropic-thinking-disable.test.ts
@@ -6,6 +6,7 @@ import type { Context, Model, SimpleStreamOptions } from "../src/types.js";
interface AnthropicThinkingPayload {
thinking?: { type: string; budget_tokens?: number; display?: string };
output_config?: { effort?: string };
+ temperature?: number;
}
function makePayloadCaptureContext(): Context {
@@ -165,6 +166,34 @@ describe("Anthropic thinking disable payload", () => {
expect(payload.thinking).toEqual({ type: "adaptive", display: "summarized" });
expect(payload.output_config).toEqual({ effort: "max" });
});
+
+ it("omits the thinking param for Claude Fable 5 when reasoning is off (explicit disabled is a 400)", async () => {
+ const payload = await capturePayload(getModel("anthropic", "claude-fable-5"));
+
+ expect(payload.thinking).toBeUndefined();
+ expect(payload.output_config).toBeUndefined();
+ });
+
+ it("drops temperature for Claude Fable 5 (sampling params are rejected)", async () => {
+ const payload = await capturePayload(getModel("anthropic", "claude-fable-5"), { temperature: 0.5 });
+
+ expect(payload.temperature).toBeUndefined();
+ expect(payload.thinking).toBeUndefined();
+ });
+
+ it("uses adaptive thinking with effort=xhigh for Claude Fable 5", async () => {
+ const payload = await capturePayload(getModel("anthropic", "claude-fable-5"), { reasoning: "xhigh" });
+
+ expect(payload.thinking).toEqual({ type: "adaptive", display: "summarized" });
+ expect(payload.output_config).toEqual({ effort: "xhigh" });
+ });
+
+ it("maps max reasoning to effort=max for Claude Fable 5", async () => {
+ const payload = await capturePayload(getModel("anthropic", "claude-fable-5"), { reasoning: "max" });
+
+ expect(payload.thinking).toEqual({ type: "adaptive", display: "summarized" });
+ expect(payload.output_config).toEqual({ effort: "max" });
+ });
});
describe.skipIf(!process.env.ANTHROPIC_API_KEY)("Anthropic thinking disable E2E", () => {
diff --git a/packages/ai/test/bedrock-thinking-payload.test.ts b/packages/ai/test/bedrock-thinking-payload.test.ts
index 54b348138d..0b2151f693 100644
--- a/packages/ai/test/bedrock-thinking-payload.test.ts
+++ b/packages/ai/test/bedrock-thinking-payload.test.ts
@@ -4,6 +4,7 @@ import { type BedrockOptions, streamBedrock } from "../src/providers/amazon-bedr
import type { Context, Model } from "../src/types.js";
interface BedrockThinkingPayload {
+ inferenceConfig?: { maxTokens?: number; temperature?: number };
additionalModelRequestFields?: {
thinking?: { type: string; budget_tokens?: number; display?: string };
output_config?: { effort?: string };
@@ -89,6 +90,23 @@ describe("Bedrock thinking payload", () => {
expect(payload.additionalModelRequestFields?.anthropic_beta).toBeUndefined();
});
+ it("uses adaptive thinking with effort for Claude Fable 5", async () => {
+ const model = getModel("amazon-bedrock", "global.anthropic.claude-fable-5");
+
+ const payload = await capturePayload(model, { reasoning: "xhigh" });
+
+ expect(payload.additionalModelRequestFields?.thinking).toEqual({ type: "adaptive", display: "summarized" });
+ expect(payload.additionalModelRequestFields?.output_config).toEqual({ effort: "xhigh" });
+ });
+
+ it("drops temperature for Claude Fable 5 (sampling params are rejected)", async () => {
+ const model = getModel("amazon-bedrock", "global.anthropic.claude-fable-5");
+
+ const payload = await capturePayload(model, { reasoning: "high", temperature: 0.5 });
+
+ expect(payload.inferenceConfig?.temperature).toBeUndefined();
+ });
+
it("omits display for GovCloud model ids on non-adaptive Claude thinking", async () => {
const baseModel = getModel("amazon-bedrock", "us.anthropic.claude-sonnet-4-5-20250929-v1:0");
const model: Model<"bedrock-converse-stream"> = {