From accba2c4e22b5c00102fc3adc9668fbb71f30e55 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Mon, 11 May 2026 11:35:26 +0100 Subject: [PATCH] test: tighten anthropic vertex stream assertions --- .../anthropic-vertex/stream-runtime.test.ts | 48 +++++++------------ 1 file changed, 18 insertions(+), 30 deletions(-) diff --git a/extensions/anthropic-vertex/stream-runtime.test.ts b/extensions/anthropic-vertex/stream-runtime.test.ts index d8e11a96f61..ee71dde5d95 100644 --- a/extensions/anthropic-vertex/stream-runtime.test.ts +++ b/extensions/anthropic-vertex/stream-runtime.test.ts @@ -141,13 +141,10 @@ describe("createAnthropicVertexStreamFn", () => { void streamFn(model, { messages: [] }, {}); - expect(streamAnthropicMock).toHaveBeenCalledWith( - model, - { messages: [] }, - expect.objectContaining({ - maxTokens: 128000, - }), - ); + const transportOptions = streamAnthropicMock.mock.calls[0]?.[2] as + | { maxTokens?: number } + | undefined; + expect(transportOptions?.maxTokens).toBe(128000); }); it("clamps explicit maxTokens to the selected model limit", () => { @@ -157,13 +154,10 @@ describe("createAnthropicVertexStreamFn", () => { void streamFn(model, { messages: [] }, { maxTokens: 999999 }); - expect(streamAnthropicMock).toHaveBeenCalledWith( - model, - { messages: [] }, - expect.objectContaining({ - maxTokens: 128000, - }), - ); + const transportOptions = streamAnthropicMock.mock.calls[0]?.[2] as + | { maxTokens?: number } + | undefined; + expect(transportOptions?.maxTokens).toBe(128000); }); it("maps xhigh reasoning to max effort for adaptive Opus models", () => { @@ -173,14 +167,11 @@ describe("createAnthropicVertexStreamFn", () => { void streamFn(model, { messages: [] }, { reasoning: "xhigh" }); - expect(streamAnthropicMock).toHaveBeenCalledWith( - model, - { messages: [] }, - expect.objectContaining({ - thinkingEnabled: true, - effort: "max", - }), - ); + const transportOptions = streamAnthropicMock.mock.calls[0]?.[2] as + | { effort?: string; thinkingEnabled?: boolean } + | undefined; + expect(transportOptions?.thinkingEnabled).toBe(true); + expect(transportOptions?.effort).toBe("max"); }); it("maps xhigh reasoning to xhigh effort for Opus 4.7", () => { @@ -190,14 +181,11 @@ describe("createAnthropicVertexStreamFn", () => { void streamFn(model, { messages: [] }, { reasoning: "xhigh" }); - expect(streamAnthropicMock).toHaveBeenCalledWith( - model, - { messages: [] }, - expect.objectContaining({ - thinkingEnabled: true, - effort: "xhigh", - }), - ); + const transportOptions = streamAnthropicMock.mock.calls[0]?.[2] as + | { effort?: string; thinkingEnabled?: boolean } + | undefined; + expect(transportOptions?.thinkingEnabled).toBe(true); + expect(transportOptions?.effort).toBe("xhigh"); }); it("applies Anthropic cache-boundary shaping before forwarding payload hooks", async () => {