Skip to content

Commit f65d28f

Browse files
committed
test(bedrock): add low-effort and Fable 5 undefined-maxTokens coverage (#97176)
- Add low reasoning effort test for adaptive-thinking models - Add Fable 5 boundary test when model.maxTokens is undefined - Reorder resolveModelBackedMaxTokens before resolveSimpleBedrockOptions for clarity (caller-after-callee)
1 parent fecb09f commit f65d28f

2 files changed

Lines changed: 34 additions & 7 deletions

File tree

‎extensions/amazon-bedrock/stream.runtime.test.ts‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,19 @@ describe("Bedrock thinking effort mapping", () => {
294294
expect(x.reasoning).toBe("xhigh");
295295
});
296296

297+
it("preserves low effort with model maxTokens (#97176)", () => {
298+
const options = testing.resolveSimpleBedrockOptions(
299+
bedrockModel({
300+
id: "us.anthropic.claude-opus-4-8",
301+
name: "Claude Opus 4.8",
302+
maxTokens: 200_000,
303+
}),
304+
{ reasoning: "low" },
305+
);
306+
expect(options.maxTokens).toBe(200_000);
307+
expect(options.reasoning).toBe("low");
308+
});
309+
297310
it("keeps base default when model.maxTokens is undefined for adaptive-thinking (#97176)", () => {
298311
const options = testing.resolveSimpleBedrockOptions(
299312
bedrockModel({
@@ -368,6 +381,20 @@ describe("Bedrock Fable contract", () => {
368381
expect(opts.maxTokens).toBe(16000);
369382
});
370383

384+
it("keeps base default when model.maxTokens is undefined for Fable 5 (#97176)", () => {
385+
const model = bedrockModel({
386+
id: "production-fable",
387+
name: "Production deployment",
388+
params: { canonicalModelId: "claude-fable-5" },
389+
contextWindow: 1_000_000,
390+
// no maxTokens — should stay at base default 4096
391+
});
392+
const opts = testing.resolveSimpleBedrockOptions(model, {
393+
reasoning: "high",
394+
});
395+
expect(opts.maxTokens).toBe(4096);
396+
});
397+
371398
it("sends model.maxTokens in inferenceConfig for Fable 5 (#97176)", async () => {
372399
const send = vi.spyOn(BedrockRuntimeClient.prototype, "send").mockResolvedValue({
373400
$metadata: { httpStatusCode: 200 },

‎extensions/amazon-bedrock/stream.runtime.ts‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -358,13 +358,6 @@ function formatBedrockError(error: unknown): string {
358358
return message;
359359
}
360360

361-
/** Stream a Bedrock Converse request from the generic OpenClaw stream options. */
362-
export const streamSimpleBedrock: StreamFunction<"bedrock-converse-stream", SimpleStreamOptions> = (
363-
model: Model<"bedrock-converse-stream">,
364-
context: Context,
365-
options?: SimpleStreamOptions,
366-
) => streamBedrock(model, context, resolveSimpleBedrockOptions(model, options));
367-
368361
/** When the caller did not set an explicit maxTokens cap, use the
369362
* model's resolved maxTokens instead of leaving it at the core default
370363
* 4096. This prevents adaptive-thinking and Fable 5 Bedrock requests
@@ -437,6 +430,13 @@ function resolveSimpleBedrockOptions(
437430
} satisfies BedrockOptions;
438431
}
439432

433+
/** Stream a Bedrock Converse request from the generic OpenClaw stream options. */
434+
export const streamSimpleBedrock: StreamFunction<"bedrock-converse-stream", SimpleStreamOptions> = (
435+
model: Model<"bedrock-converse-stream">,
436+
context: Context,
437+
options?: SimpleStreamOptions,
438+
) => streamBedrock(model, context, resolveSimpleBedrockOptions(model, options));
439+
440440
function handleContentBlockStart(
441441
event: ContentBlockStartEvent,
442442
blocks: Block[],

0 commit comments

Comments
 (0)