Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/gorgeous-brooms-exercise.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"kilo-code": patch
---

Improve file edit success rates for non-Claude models with native tool calling
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { CodeIndexManager } from "../../../../../services/code-index/manager"
import { McpServerManager } from "../../../../../services/mcp/McpServerManager"
import { ContextProxy } from "../../../../config/ContextProxy"
import * as vscode from "vscode"
import search_and_replace from "../search_and_replace"

vi.mock("vscode")
vi.mock("../../../../../services/code-index/manager")
Expand Down Expand Up @@ -75,7 +76,7 @@ describe("getAllowedJSONToolsForMode", () => {

const applyDiffTool = tools.find((tool) => "function" in tool && tool.function.name === "apply_diff")
expect(applyDiffTool).toBeDefined()
expect(applyDiffTool).toEqual(apply_diff_single_file)
expect(applyDiffTool).toEqual(search_and_replace)
expect(applyDiffTool).not.toEqual(apply_diff_multi_file)
})

Expand All @@ -98,7 +99,7 @@ describe("getAllowedJSONToolsForMode", () => {
const applyDiffTool = tools.find((tool) => "function" in tool && tool.function.name === "apply_diff")
expect(applyDiffTool).toBeDefined()
expect(applyDiffTool).toEqual(apply_diff_multi_file)
expect(applyDiffTool).not.toEqual(apply_diff_single_file)
expect(applyDiffTool).not.toEqual(search_and_replace)
})

it("should not include apply_diff when diffEnabled is false", async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,10 @@ export async function getAllowedJSONToolsForMode(
// Handle the "apply_diff" logic separately because the same tool has different
// implementations depending on whether multi-file diffs are enabled, but the same name is used.
if (isApplyDiffToolAllowedForMode && diffEnabled) {
if (shouldUseSearchAndReplaceInsteadOfApplyDiff("json", model?.id ?? "")) {
allowedTools.push(search_and_replace)
} else if (providerState?.experiments.multiFileApplyDiff) {
if (providerState?.experiments.multiFileApplyDiff) {
allowedTools.push(apply_diff_multi_file)
} else if (shouldUseSearchAndReplaceInsteadOfApplyDiff("json", model?.id ?? "")) {
allowedTools.push(search_and_replace)
} else {
allowedTools.push(apply_diff_single_file)
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/prompts/tools/native-tools/search_and_replace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type OpenAI from "openai"
import z from "zod/v4"

export function shouldUseSearchAndReplaceInsteadOfApplyDiff(toolStyle: ToolUseStyle, modelId: string) {
return toolStyle === "json" && modelId.toLowerCase().includes("minimax-m2")
return toolStyle === "json" && !modelId.toLowerCase().includes("claude")
}

export const SearchAndReplaceParametersSchema = z.object({
Expand Down