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
11 changes: 11 additions & 0 deletions packages/types/src/providers/gemini.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const geminiModels = {
supportsReasoningEffort: ["low", "high"],
reasoningEffort: "low",
includedTools: ["write_file", "edit_file"],
excludedTools: ["apply_diff"],
supportsTemperature: true,
defaultTemperature: 1,
inputPrice: 4.0,
Expand Down Expand Up @@ -43,6 +44,7 @@ export const geminiModels = {
supportsReasoningEffort: ["minimal", "low", "medium", "high"],
reasoningEffort: "medium",
includedTools: ["write_file", "edit_file"],
excludedTools: ["apply_diff"],
supportsTemperature: true,
defaultTemperature: 1,
inputPrice: 0.3,
Expand All @@ -59,6 +61,7 @@ export const geminiModels = {
defaultToolProtocol: "native",
supportsPromptCache: true,
includedTools: ["write_file", "edit_file"],
excludedTools: ["apply_diff"],
inputPrice: 2.5, // This is the pricing for prompts above 200k tokens.
outputPrice: 15,
cacheReadsPrice: 0.625,
Expand Down Expand Up @@ -89,6 +92,7 @@ export const geminiModels = {
defaultToolProtocol: "native",
supportsPromptCache: true,
includedTools: ["write_file", "edit_file"],
excludedTools: ["apply_diff"],
inputPrice: 2.5, // This is the pricing for prompts above 200k tokens.
outputPrice: 15,
cacheReadsPrice: 0.625,
Expand Down Expand Up @@ -118,6 +122,7 @@ export const geminiModels = {
defaultToolProtocol: "native",
supportsPromptCache: true,
includedTools: ["write_file", "edit_file"],
excludedTools: ["apply_diff"],
inputPrice: 2.5, // This is the pricing for prompts above 200k tokens.
outputPrice: 15,
cacheReadsPrice: 0.625,
Expand Down Expand Up @@ -145,6 +150,7 @@ export const geminiModels = {
defaultToolProtocol: "native",
supportsPromptCache: true,
includedTools: ["write_file", "edit_file"],
excludedTools: ["apply_diff"],
inputPrice: 2.5, // This is the pricing for prompts above 200k tokens.
outputPrice: 15,
cacheReadsPrice: 0.625,
Expand Down Expand Up @@ -176,6 +182,7 @@ export const geminiModels = {
defaultToolProtocol: "native",
supportsPromptCache: true,
includedTools: ["write_file", "edit_file"],
excludedTools: ["apply_diff"],
inputPrice: 0.3,
outputPrice: 2.5,
cacheReadsPrice: 0.075,
Expand All @@ -191,6 +198,7 @@ export const geminiModels = {
defaultToolProtocol: "native",
supportsPromptCache: true,
includedTools: ["write_file", "edit_file"],
excludedTools: ["apply_diff"],
inputPrice: 0.3,
outputPrice: 2.5,
cacheReadsPrice: 0.075,
Expand All @@ -206,6 +214,7 @@ export const geminiModels = {
defaultToolProtocol: "native",
supportsPromptCache: true,
includedTools: ["write_file", "edit_file"],
excludedTools: ["apply_diff"],
inputPrice: 0.3,
outputPrice: 2.5,
cacheReadsPrice: 0.075,
Expand All @@ -223,6 +232,7 @@ export const geminiModels = {
defaultToolProtocol: "native",
supportsPromptCache: true,
includedTools: ["write_file", "edit_file"],
excludedTools: ["apply_diff"],
inputPrice: 0.1,
outputPrice: 0.4,
cacheReadsPrice: 0.025,
Expand All @@ -238,6 +248,7 @@ export const geminiModels = {
defaultToolProtocol: "native",
supportsPromptCache: true,
includedTools: ["write_file", "edit_file"],
excludedTools: ["apply_diff"],
inputPrice: 0.1,
outputPrice: 0.4,
cacheReadsPrice: 0.025,
Expand Down
19 changes: 19 additions & 0 deletions packages/types/src/providers/vertex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export const vertexModels = {
supportsReasoningEffort: ["low", "high"],
reasoningEffort: "low",
includedTools: ["write_file", "edit_file"],
excludedTools: ["apply_diff"],
supportsTemperature: true,
defaultTemperature: 1,
inputPrice: 4.0,
Expand Down Expand Up @@ -43,6 +44,7 @@ export const vertexModels = {
supportsReasoningEffort: ["minimal", "low", "medium", "high"],
reasoningEffort: "medium",
includedTools: ["write_file", "edit_file"],
excludedTools: ["apply_diff"],
supportsTemperature: true,
defaultTemperature: 1,
inputPrice: 0.3,
Expand All @@ -58,6 +60,7 @@ export const vertexModels = {
defaultToolProtocol: "native",
supportsPromptCache: true,
includedTools: ["write_file", "edit_file"],
excludedTools: ["apply_diff"],
inputPrice: 0.15,
outputPrice: 3.5,
maxThinkingTokens: 24_576,
Expand All @@ -72,6 +75,7 @@ export const vertexModels = {
defaultToolProtocol: "native",
supportsPromptCache: true,
includedTools: ["write_file", "edit_file"],
excludedTools: ["apply_diff"],
inputPrice: 0.15,
outputPrice: 0.6,
},
Expand All @@ -83,6 +87,7 @@ export const vertexModels = {
defaultToolProtocol: "native",
supportsPromptCache: true,
includedTools: ["write_file", "edit_file"],
excludedTools: ["apply_diff"],
inputPrice: 0.3,
outputPrice: 2.5,
cacheReadsPrice: 0.075,
Expand All @@ -98,6 +103,7 @@ export const vertexModels = {
defaultToolProtocol: "native",
supportsPromptCache: false,
includedTools: ["write_file", "edit_file"],
excludedTools: ["apply_diff"],
inputPrice: 0.15,
outputPrice: 3.5,
maxThinkingTokens: 24_576,
Expand All @@ -112,6 +118,7 @@ export const vertexModels = {
defaultToolProtocol: "native",
supportsPromptCache: false,
includedTools: ["write_file", "edit_file"],
excludedTools: ["apply_diff"],
inputPrice: 0.15,
outputPrice: 0.6,
},
Expand All @@ -123,6 +130,7 @@ export const vertexModels = {
defaultToolProtocol: "native",
supportsPromptCache: true,
includedTools: ["write_file", "edit_file"],
excludedTools: ["apply_diff"],
inputPrice: 2.5,
outputPrice: 15,
},
Expand All @@ -134,6 +142,7 @@ export const vertexModels = {
defaultToolProtocol: "native",
supportsPromptCache: true,
includedTools: ["write_file", "edit_file"],
excludedTools: ["apply_diff"],
inputPrice: 2.5,
outputPrice: 15,
},
Expand All @@ -145,6 +154,7 @@ export const vertexModels = {
defaultToolProtocol: "native",
supportsPromptCache: true,
includedTools: ["write_file", "edit_file"],
excludedTools: ["apply_diff"],
inputPrice: 2.5,
outputPrice: 15,
maxThinkingTokens: 32_768,
Expand All @@ -158,6 +168,7 @@ export const vertexModels = {
defaultToolProtocol: "native",
supportsPromptCache: true,
includedTools: ["write_file", "edit_file"],
excludedTools: ["apply_diff"],
inputPrice: 2.5,
outputPrice: 15,
maxThinkingTokens: 32_768,
Expand Down Expand Up @@ -186,6 +197,7 @@ export const vertexModels = {
defaultToolProtocol: "native",
supportsPromptCache: false,
includedTools: ["write_file", "edit_file"],
excludedTools: ["apply_diff"],
inputPrice: 0,
outputPrice: 0,
},
Expand All @@ -197,6 +209,7 @@ export const vertexModels = {
defaultToolProtocol: "native",
supportsPromptCache: false,
includedTools: ["write_file", "edit_file"],
excludedTools: ["apply_diff"],
inputPrice: 0,
outputPrice: 0,
},
Expand All @@ -208,6 +221,7 @@ export const vertexModels = {
defaultToolProtocol: "native",
supportsPromptCache: true,
includedTools: ["write_file", "edit_file"],
excludedTools: ["apply_diff"],
inputPrice: 0.15,
outputPrice: 0.6,
},
Expand All @@ -219,6 +233,7 @@ export const vertexModels = {
defaultToolProtocol: "native",
supportsPromptCache: false,
includedTools: ["write_file", "edit_file"],
excludedTools: ["apply_diff"],
inputPrice: 0.075,
outputPrice: 0.3,
},
Expand All @@ -230,6 +245,7 @@ export const vertexModels = {
defaultToolProtocol: "native",
supportsPromptCache: false,
includedTools: ["write_file", "edit_file"],
excludedTools: ["apply_diff"],
inputPrice: 0,
outputPrice: 0,
},
Expand All @@ -241,6 +257,7 @@ export const vertexModels = {
defaultToolProtocol: "native",
supportsPromptCache: true,
includedTools: ["write_file", "edit_file"],
excludedTools: ["apply_diff"],
inputPrice: 0.075,
outputPrice: 0.3,
},
Expand All @@ -252,6 +269,7 @@ export const vertexModels = {
defaultToolProtocol: "native",
supportsPromptCache: false,
includedTools: ["write_file", "edit_file"],
excludedTools: ["apply_diff"],
inputPrice: 1.25,
outputPrice: 5,
},
Expand Down Expand Up @@ -400,6 +418,7 @@ export const vertexModels = {
defaultToolProtocol: "native",
supportsPromptCache: true,
includedTools: ["write_file", "edit_file"],
excludedTools: ["apply_diff"],
inputPrice: 0.1,
outputPrice: 0.4,
cacheReadsPrice: 0.025,
Expand Down
1 change: 1 addition & 0 deletions packages/types/src/tool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const toolNames = [
"apply_diff",
"search_and_replace",
"search_replace",
"edit_file",
"apply_patch",
"search_files",
"list_files",
Expand Down
1 change: 1 addition & 0 deletions src/api/providers/utils/router-tool-preferences.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export function applyRouterToolPreferences(modelId: string, info: ModelInfo): Mo
if (modelId.includes("gemini")) {
result = {
...result,
excludedTools: [...new Set([...(result.excludedTools || []), "apply_diff"])],
includedTools: [...new Set([...(result.includedTools || []), "write_file", "edit_file"])],
}
}
Expand Down
32 changes: 31 additions & 1 deletion src/core/assistant-message/NativeToolCallParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,21 @@ export class NativeToolCallParser {
}
break

case "edit_file":
if (
partialArgs.file_path !== undefined ||
partialArgs.old_string !== undefined ||
partialArgs.new_string !== undefined
) {
nativeArgs = {
file_path: partialArgs.file_path,
old_string: partialArgs.old_string,
new_string: partialArgs.new_string,
expected_replacements: partialArgs.expected_replacements,
}
}
break

default:
break
}
Expand Down Expand Up @@ -562,7 +577,7 @@ export class NativeToolCallParser {
return this.parseDynamicMcpTool(toolCall)
}

// Resolve tool alias to canonical name (e.g., "edit_file" -> "apply_diff", "temp_edit_file" -> "search_and_replace")
// Resolve tool alias to canonical name
const resolvedName = resolveToolAlias(toolCall.name as string) as TName

// Validate tool name (after alias resolution)
Expand Down Expand Up @@ -785,6 +800,21 @@ export class NativeToolCallParser {
}
break

case "edit_file":
if (
args.file_path !== undefined &&
args.old_string !== undefined &&
args.new_string !== undefined
) {
nativeArgs = {
file_path: args.file_path,
old_string: args.old_string,
new_string: args.new_string,
expected_replacements: args.expected_replacements,
} as NativeArgsFor<TName>
}
break

default:
break
}
Expand Down
13 changes: 13 additions & 0 deletions src/core/assistant-message/presentAssistantMessage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { writeToFileTool } from "../tools/WriteToFileTool"
import { applyDiffTool } from "../tools/MultiApplyDiffTool"
import { searchAndReplaceTool } from "../tools/SearchAndReplaceTool"
import { searchReplaceTool } from "../tools/SearchReplaceTool"
import { editFileTool } from "../tools/EditFileTool"
import { applyPatchTool } from "../tools/ApplyPatchTool"
import { searchFilesTool } from "../tools/SearchFilesTool"
import { browserActionTool } from "../tools/BrowserActionTool"
Expand Down Expand Up @@ -403,6 +404,8 @@ export async function presentAssistantMessage(cline: Task) {
return `[${block.name} for '${block.params.path}']`
case "search_replace":
return `[${block.name} for '${block.params.file_path}']`
case "edit_file":
return `[${block.name} for '${block.params.file_path}']`
case "apply_patch":
return `[${block.name}]`
case "list_files":
Expand Down Expand Up @@ -872,6 +875,16 @@ export async function presentAssistantMessage(cline: Task) {
toolProtocol,
})
break
case "edit_file":
await checkpointSaveAndMark(cline)
await editFileTool.handle(cline, block as ToolUse<"edit_file">, {
askApproval,
handleError,
pushToolResult,
removeClosingTag,
toolProtocol,
})
break
case "apply_patch":
await checkpointSaveAndMark(cline)
await applyPatchTool.handle(cline, block as ToolUse<"apply_patch">, {
Expand Down
11 changes: 10 additions & 1 deletion src/core/prompts/tools/__tests__/filter-tools-for-mode.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,14 @@ describe("filterMcpToolsForMode", () => {
parameters: {},
},
},
{
type: "function",
function: {
name: "edit_file",
description: "Edit file",
parameters: {},
},
},
]

it("should exclude tools when model specifies excludedTools", () => {
Expand Down Expand Up @@ -823,7 +831,7 @@ describe("filterMcpToolsForMode", () => {
expect(toolNames).not.toContain("apply_diff") // Excluded
})

it("should rename tools to alias names when model includes aliases", () => {
it("should honor included aliases while respecting exclusions", () => {
const codeMode: ModeConfig = {
slug: "code",
name: "Code",
Expand All @@ -834,6 +842,7 @@ describe("filterMcpToolsForMode", () => {
const modelInfo: ModelInfo = {
contextWindow: 100000,
supportsPromptCache: false,
excludedTools: ["apply_diff"],
includedTools: ["edit_file", "write_file"],
}

Expand Down
Loading
Loading