Преглед изворни кода

fix: exclude apply_diff from native tools when diffEnabled is false (#9920)

Co-authored-by: Roo Code <[email protected]>
roomote[bot] пре 3 недеља
родитељ
комит
375c103bd3

+ 5 - 0
src/core/prompts/tools/filter-tools-for-mode.ts

@@ -153,6 +153,11 @@ export function filterNativeToolsForMode(
 		allowedToolNames.delete("browser_action")
 	}
 
+	// Conditionally exclude apply_diff if diffs are disabled
+	if (settings?.diffEnabled === false) {
+		allowedToolNames.delete("apply_diff")
+	}
+
 	// Conditionally exclude access_mcp_resource if MCP is not enabled or there are no resources
 	if (!mcpHub || !hasAnyMcpResources(mcpHub)) {
 		allowedToolNames.delete("access_mcp_resource")

+ 1 - 0
src/core/task/Task.ts

@@ -3661,6 +3661,7 @@ export class Task extends EventEmitter<TaskEvents> implements TaskLike {
 				maxReadFileLine: state?.maxReadFileLine ?? -1,
 				browserToolEnabled: state?.browserToolEnabled ?? true,
 				modelInfo,
+				diffEnabled: this.diffEnabled,
 			})
 		}
 

+ 3 - 0
src/core/task/build-tools.ts

@@ -14,6 +14,7 @@ interface BuildToolsOptions {
 	maxReadFileLine: number
 	browserToolEnabled: boolean
 	modelInfo?: ModelInfo
+	diffEnabled: boolean
 }
 
 /**
@@ -34,6 +35,7 @@ export async function buildNativeToolsArray(options: BuildToolsOptions): Promise
 		maxReadFileLine,
 		browserToolEnabled,
 		modelInfo,
+		diffEnabled,
 	} = options
 
 	const mcpHub = provider.getMcpHub()
@@ -47,6 +49,7 @@ export async function buildNativeToolsArray(options: BuildToolsOptions): Promise
 		todoListEnabled: apiConfiguration?.todoListEnabled ?? true,
 		browserToolEnabled: browserToolEnabled ?? true,
 		modelInfo,
+		diffEnabled,
 	}
 
 	// Determine if partial reads are enabled based on maxReadFileLine setting