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

Co-authored-by: Roo Code <roomote@roocode.com>
This commit is contained in:
roomote[bot] 2025-12-08 17:20:44 -08:00 committed by GitHub
parent ee48b3a1ae
commit 375c103bd3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 9 additions and 0 deletions

View file

@ -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")

View file

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

View file

@ -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