|
|
@@ -139,18 +139,24 @@ describe("resolveToolProtocol", () => {
|
|
|
})
|
|
|
})
|
|
|
|
|
|
- describe("Precedence Level 3: XML Fallback", () => {
|
|
|
- it("should use XML fallback when no model default is specified", () => {
|
|
|
+ describe("Precedence Level 3: Native Fallback", () => {
|
|
|
+ it("should use Native fallback when no model default is specified and model supports native", () => {
|
|
|
const settings: ProviderSettings = {
|
|
|
apiProvider: "anthropic",
|
|
|
}
|
|
|
- const result = resolveToolProtocol(settings, undefined)
|
|
|
- expect(result).toBe(TOOL_PROTOCOL.XML) // XML fallback
|
|
|
+ const modelInfo: ModelInfo = {
|
|
|
+ maxTokens: 4096,
|
|
|
+ contextWindow: 128000,
|
|
|
+ supportsPromptCache: false,
|
|
|
+ supportsNativeTools: true,
|
|
|
+ }
|
|
|
+ const result = resolveToolProtocol(settings, modelInfo)
|
|
|
+ expect(result).toBe(TOOL_PROTOCOL.NATIVE) // Native fallback
|
|
|
})
|
|
|
})
|
|
|
|
|
|
describe("Complete Precedence Chain", () => {
|
|
|
- it("should respect full precedence: Profile > Model Default > XML Fallback", () => {
|
|
|
+ it("should respect full precedence: Profile > Model Default > Native Fallback", () => {
|
|
|
// Set up a scenario with all levels defined
|
|
|
const settings: ProviderSettings = {
|
|
|
toolProtocol: "native", // Level 1: User profile setting
|
|
|
@@ -186,7 +192,7 @@ describe("resolveToolProtocol", () => {
|
|
|
expect(result).toBe(TOOL_PROTOCOL.XML) // Model default wins
|
|
|
})
|
|
|
|
|
|
- it("should skip to XML fallback when profile and model default are undefined", () => {
|
|
|
+ it("should skip to Native fallback when profile and model default are undefined", () => {
|
|
|
const settings: ProviderSettings = {
|
|
|
apiProvider: "openai-native",
|
|
|
}
|
|
|
@@ -199,7 +205,7 @@ describe("resolveToolProtocol", () => {
|
|
|
}
|
|
|
|
|
|
const result = resolveToolProtocol(settings, modelInfo)
|
|
|
- expect(result).toBe(TOOL_PROTOCOL.XML) // XML fallback
|
|
|
+ expect(result).toBe(TOOL_PROTOCOL.NATIVE) // Native fallback
|
|
|
})
|
|
|
|
|
|
it("should skip to XML fallback when model info is unavailable", () => {
|
|
|
@@ -208,7 +214,7 @@ describe("resolveToolProtocol", () => {
|
|
|
}
|
|
|
|
|
|
const result = resolveToolProtocol(settings, undefined)
|
|
|
- expect(result).toBe(TOOL_PROTOCOL.XML) // XML fallback
|
|
|
+ expect(result).toBe(TOOL_PROTOCOL.XML) // XML fallback (no model info means no native support)
|
|
|
})
|
|
|
})
|
|
|
|
|
|
@@ -216,7 +222,7 @@ describe("resolveToolProtocol", () => {
|
|
|
it("should handle missing provider name gracefully", () => {
|
|
|
const settings: ProviderSettings = {}
|
|
|
const result = resolveToolProtocol(settings)
|
|
|
- expect(result).toBe(TOOL_PROTOCOL.XML) // Falls back to global
|
|
|
+ expect(result).toBe(TOOL_PROTOCOL.XML) // Falls back to XML (no model info)
|
|
|
})
|
|
|
|
|
|
it("should handle undefined model info gracefully", () => {
|
|
|
@@ -224,7 +230,7 @@ describe("resolveToolProtocol", () => {
|
|
|
apiProvider: "openai-native",
|
|
|
}
|
|
|
const result = resolveToolProtocol(settings, undefined)
|
|
|
- expect(result).toBe(TOOL_PROTOCOL.XML) // XML fallback
|
|
|
+ expect(result).toBe(TOOL_PROTOCOL.XML) // XML fallback (no model info)
|
|
|
})
|
|
|
|
|
|
it("should fall back to XML when model doesn't support native", () => {
|
|
|
@@ -243,7 +249,7 @@ describe("resolveToolProtocol", () => {
|
|
|
})
|
|
|
|
|
|
describe("Real-world Scenarios", () => {
|
|
|
- it("should use XML fallback for models without defaultToolProtocol", () => {
|
|
|
+ it("should use Native fallback for models without defaultToolProtocol", () => {
|
|
|
const settings: ProviderSettings = {
|
|
|
apiProvider: "openai-native",
|
|
|
}
|
|
|
@@ -254,7 +260,7 @@ describe("resolveToolProtocol", () => {
|
|
|
supportsNativeTools: true,
|
|
|
}
|
|
|
const result = resolveToolProtocol(settings, modelInfo)
|
|
|
- expect(result).toBe(TOOL_PROTOCOL.XML) // XML fallback
|
|
|
+ expect(result).toBe(TOOL_PROTOCOL.NATIVE) // Native fallback
|
|
|
})
|
|
|
|
|
|
it("should use XML for Claude models with Anthropic provider", () => {
|