@@ -11,13 +11,13 @@ import { TOOL_GROUPS, ALWAYS_AVAILABLE_TOOLS } from "../../shared/tools"
1111 * Note: This does NOT check if the tool is allowed for a specific mode,
1212 * only that the tool actually exists.
1313 */
14- export function isValidToolName ( toolName : string ) : toolName is ToolName {
14+ export function isValidToolName ( toolName : string , experiments ?: Record < string , boolean > ) : toolName is ToolName {
1515 // Check if it's a valid static tool
1616 if ( ( validToolNames as readonly string [ ] ) . includes ( toolName ) ) {
1717 return true
1818 }
1919
20- if ( customToolRegistry . has ( toolName ) ) {
20+ if ( experiments ?. customTools && customToolRegistry . has ( toolName ) ) {
2121 return true
2222 }
2323
@@ -40,7 +40,7 @@ export function validateToolUse(
4040) : void {
4141 // First, check if the tool name is actually a valid/known tool
4242 // This catches completely invalid tool names like "edit_file" that don't exist
43- if ( ! isValidToolName ( toolName ) ) {
43+ if ( ! isValidToolName ( toolName , experiments ) ) {
4444 throw new Error (
4545 `Unknown tool "${ toolName } ". This tool does not exist. Please use one of the available tools: ${ validToolNames . join ( ", " ) } .` ,
4646 )
@@ -94,7 +94,7 @@ export function isToolAllowedForMode(
9494
9595 // For now, allow all custom tools in any mode.
9696 // As a follow-up we should expand the custom tool definition to include mode restrictions.
97- if ( customToolRegistry . has ( tool ) ) {
97+ if ( experiments ?. customTools && customToolRegistry . has ( tool ) ) {
9898 return true
9999 }
100100
0 commit comments