diff --git a/src/api/providers/__tests__/anthropic-vertex.spec.ts b/src/api/providers/__tests__/anthropic-vertex.spec.ts index 6890e4178b..0644ffc547 100644 --- a/src/api/providers/__tests__/anthropic-vertex.spec.ts +++ b/src/api/providers/__tests__/anthropic-vertex.spec.ts @@ -1200,8 +1200,9 @@ describe("VertexHandler", () => { ) }) - it("should include tools even when toolProtocol is set to xml (user preference now ignored)", async () => { - // XML protocol deprecation: user preference is now ignored when model supports native tools + it("should NOT include tools when toolProtocol is set to xml (user preference is now respected)", async () => { + // User preference is now respected: when XML protocol is selected, tools are NOT sent to the API + // (tools are handled via XML in the system prompt instead) handler = new AnthropicVertexHandler({ apiModelId: "claude-3-5-sonnet-v2@20241022", vertexProjectId: "test-project", @@ -1242,14 +1243,10 @@ describe("VertexHandler", () => { // Just consume } - // Native is forced when supportsNativeTools===true, so tools should still be included + // User preference for XML is now respected, so tools should NOT be included expect(mockCreate).toHaveBeenCalledWith( - expect.objectContaining({ - tools: expect.arrayContaining([ - expect.objectContaining({ - name: "get_weather", - }), - ]), + expect.not.objectContaining({ + tools: expect.anything(), }), undefined, ) diff --git a/src/api/providers/__tests__/anthropic.spec.ts b/src/api/providers/__tests__/anthropic.spec.ts index 3fa5baf81b..d9fba62f51 100644 --- a/src/api/providers/__tests__/anthropic.spec.ts +++ b/src/api/providers/__tests__/anthropic.spec.ts @@ -451,8 +451,9 @@ describe("AnthropicHandler", () => { ) }) - it("should include tools even when toolProtocol is set to xml (user preference now ignored)", async () => { - // XML protocol deprecation: user preference is now ignored when model supports native tools + it("should NOT include tools when toolProtocol is set to xml (user preference is now respected)", async () => { + // User preference is now respected: when XML protocol is selected, tools are NOT sent to the API + // (tools are handled via XML in the system prompt instead) const xmlHandler = new AnthropicHandler({ ...mockOptions, toolProtocol: "xml", @@ -468,14 +469,10 @@ describe("AnthropicHandler", () => { // Just consume } - // Native is forced when supportsNativeTools===true, so tools should still be included + // User preference for XML is now respected, so tools should NOT be included expect(mockCreate).toHaveBeenCalledWith( - expect.objectContaining({ - tools: expect.arrayContaining([ - expect.objectContaining({ - name: "get_weather", - }), - ]), + expect.not.objectContaining({ + tools: expect.anything(), }), expect.anything(), ) diff --git a/src/utils/resolveToolProtocol.ts b/src/utils/resolveToolProtocol.ts index 88f53e850d..9bc3b124fd 100644 --- a/src/utils/resolveToolProtocol.ts +++ b/src/utils/resolveToolProtocol.ts @@ -39,7 +39,7 @@ export function resolveToolProtocol( // 2. User/Profile Preference - allow users to explicitly force XML protocol // This is useful for models that don't handle native tool calling well // (e.g., some OpenAI-compatible models like Qwen3, Kimi2) - if (providerSettings.toolProtocol) { + if (providerSettings?.toolProtocol) { return providerSettings.toolProtocol }