Skip to content

Commit 0068d1f

Browse files
authored
Revert "feat: change defaultToolProtocol default from xml to native" (#9956)
1 parent 83787a7 commit 0068d1f

File tree

4 files changed

+17
-24
lines changed

4 files changed

+17
-24
lines changed

src/core/task/__tests__/Task.spec.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -981,7 +981,6 @@ describe("Cline", () => {
981981
getState: vi.fn().mockResolvedValue({
982982
apiConfiguration: mockApiConfig,
983983
}),
984-
getMcpHub: vi.fn().mockReturnValue(undefined),
985984
say: vi.fn(),
986985
postStateToWebview: vi.fn().mockResolvedValue(undefined),
987986
postMessageToWebview: vi.fn().mockResolvedValue(undefined),

src/utils/__tests__/resolveToolProtocol.spec.ts

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -139,24 +139,18 @@ describe("resolveToolProtocol", () => {
139139
})
140140
})
141141

142-
describe("Precedence Level 3: Native Fallback", () => {
143-
it("should use Native fallback when no model default is specified and model supports native", () => {
142+
describe("Precedence Level 3: XML Fallback", () => {
143+
it("should use XML fallback when no model default is specified", () => {
144144
const settings: ProviderSettings = {
145145
apiProvider: "anthropic",
146146
}
147-
const modelInfo: ModelInfo = {
148-
maxTokens: 4096,
149-
contextWindow: 128000,
150-
supportsPromptCache: false,
151-
supportsNativeTools: true,
152-
}
153-
const result = resolveToolProtocol(settings, modelInfo)
154-
expect(result).toBe(TOOL_PROTOCOL.NATIVE) // Native fallback
147+
const result = resolveToolProtocol(settings, undefined)
148+
expect(result).toBe(TOOL_PROTOCOL.XML) // XML fallback
155149
})
156150
})
157151

158152
describe("Complete Precedence Chain", () => {
159-
it("should respect full precedence: Profile > Model Default > Native Fallback", () => {
153+
it("should respect full precedence: Profile > Model Default > XML Fallback", () => {
160154
// Set up a scenario with all levels defined
161155
const settings: ProviderSettings = {
162156
toolProtocol: "native", // Level 1: User profile setting
@@ -192,7 +186,7 @@ describe("resolveToolProtocol", () => {
192186
expect(result).toBe(TOOL_PROTOCOL.XML) // Model default wins
193187
})
194188

195-
it("should skip to Native fallback when profile and model default are undefined", () => {
189+
it("should skip to XML fallback when profile and model default are undefined", () => {
196190
const settings: ProviderSettings = {
197191
apiProvider: "openai-native",
198192
}
@@ -205,7 +199,7 @@ describe("resolveToolProtocol", () => {
205199
}
206200

207201
const result = resolveToolProtocol(settings, modelInfo)
208-
expect(result).toBe(TOOL_PROTOCOL.NATIVE) // Native fallback
202+
expect(result).toBe(TOOL_PROTOCOL.XML) // XML fallback
209203
})
210204

211205
it("should skip to XML fallback when model info is unavailable", () => {
@@ -214,23 +208,23 @@ describe("resolveToolProtocol", () => {
214208
}
215209

216210
const result = resolveToolProtocol(settings, undefined)
217-
expect(result).toBe(TOOL_PROTOCOL.XML) // XML fallback (no model info means no native support)
211+
expect(result).toBe(TOOL_PROTOCOL.XML) // XML fallback
218212
})
219213
})
220214

221215
describe("Edge Cases", () => {
222216
it("should handle missing provider name gracefully", () => {
223217
const settings: ProviderSettings = {}
224218
const result = resolveToolProtocol(settings)
225-
expect(result).toBe(TOOL_PROTOCOL.XML) // Falls back to XML (no model info)
219+
expect(result).toBe(TOOL_PROTOCOL.XML) // Falls back to global
226220
})
227221

228222
it("should handle undefined model info gracefully", () => {
229223
const settings: ProviderSettings = {
230224
apiProvider: "openai-native",
231225
}
232226
const result = resolveToolProtocol(settings, undefined)
233-
expect(result).toBe(TOOL_PROTOCOL.XML) // XML fallback (no model info)
227+
expect(result).toBe(TOOL_PROTOCOL.XML) // XML fallback
234228
})
235229

236230
it("should fall back to XML when model doesn't support native", () => {
@@ -249,7 +243,7 @@ describe("resolveToolProtocol", () => {
249243
})
250244

251245
describe("Real-world Scenarios", () => {
252-
it("should use Native fallback for models without defaultToolProtocol", () => {
246+
it("should use XML fallback for models without defaultToolProtocol", () => {
253247
const settings: ProviderSettings = {
254248
apiProvider: "openai-native",
255249
}
@@ -260,7 +254,7 @@ describe("resolveToolProtocol", () => {
260254
supportsNativeTools: true,
261255
}
262256
const result = resolveToolProtocol(settings, modelInfo)
263-
expect(result).toBe(TOOL_PROTOCOL.NATIVE) // Native fallback
257+
expect(result).toBe(TOOL_PROTOCOL.XML) // XML fallback
264258
})
265259

266260
it("should use XML for Claude models with Anthropic provider", () => {

src/utils/resolveToolProtocol.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type { ProviderSettings, ModelInfo } from "@roo-code/types"
66
*
77
* 1. User Preference - Per-Profile (explicit profile setting)
88
* 2. Model Default (defaultToolProtocol in ModelInfo)
9-
* 3. Native Fallback (final fallback)
9+
* 3. XML Fallback (final fallback)
1010
*
1111
* Then check support: if protocol is "native" but model doesn't support it, use XML.
1212
*
@@ -31,6 +31,6 @@ export function resolveToolProtocol(providerSettings: ProviderSettings, modelInf
3131
return modelInfo.defaultToolProtocol
3232
}
3333

34-
// 3. Native Fallback
35-
return TOOL_PROTOCOL.NATIVE
34+
// 3. XML Fallback
35+
return TOOL_PROTOCOL.XML
3636
}

webview-ui/src/components/settings/ApiOptions.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -420,8 +420,8 @@ const ApiOptions = ({
420420
// Mirrors the simplified logic in resolveToolProtocol.ts:
421421
// 1. User preference (toolProtocol) - handled by the select value binding
422422
// 2. Model default - use if available
423-
// 3. Native fallback
424-
const defaultProtocol = selectedModelInfo?.defaultToolProtocol || TOOL_PROTOCOL.NATIVE
423+
// 3. XML fallback
424+
const defaultProtocol = selectedModelInfo?.defaultToolProtocol || TOOL_PROTOCOL.XML
425425

426426
// Show the tool protocol selector when model supports native tools
427427
const showToolProtocolSelector = selectedModelInfo?.supportsNativeTools === true

0 commit comments

Comments
 (0)