diff --git a/core/core.ts b/core/core.ts index ae4c352ca..87512ccf5 100644 --- a/core/core.ts +++ b/core/core.ts @@ -1102,26 +1102,14 @@ export class Core { return { policy: basePolicy }; } - // Preprocess args if preprocessor exists - let processedArgs = args; - if (tool.preprocessArgs) { - try { - processedArgs = await tool.preprocessArgs(args, { ide: this.ide }); - } catch (e) { - // If preprocessing fails, use original args - console.warn(`Failed to preprocess args for ${toolName}:`, e); - processedArgs = args; - } - } - // Extract display value for specific tools let displayValue: string | undefined; - if (toolName === "runTerminalCommand" && processedArgs.command) { - displayValue = processedArgs.command as string; + if (toolName === "runTerminalCommand" && args.command) { + displayValue = args.command as string; } if (tool.evaluateToolCallPolicy) { - const evaluatedPolicy = tool.evaluateToolCallPolicy(basePolicy, processedArgs); + const evaluatedPolicy = tool.evaluateToolCallPolicy(basePolicy, args); return { policy: evaluatedPolicy, displayValue }; } return { policy: basePolicy, displayValue }; diff --git a/gui/src/redux/thunks/evaluateToolPolicies.ts b/gui/src/redux/thunks/evaluateToolPolicies.ts index 37c009210..570855261 100644 --- a/gui/src/redux/thunks/evaluateToolPolicies.ts +++ b/gui/src/redux/thunks/evaluateToolPolicies.ts @@ -38,14 +38,14 @@ async function evaluateToolPolicy( )?.defaultToolPolicy ?? DEFAULT_TOOL_SETTING; - // Use already parsed arguments - const parsedArgs = toolCallState.parsedArgs || {}; + // Use preprocessed arguments if available, otherwise fall back to parsed arguments + const args = toolCallState.processedArgs || toolCallState.parsedArgs || {}; const toolName = toolCallState.toolCall.function.name; const result = await ideMessenger.request("tools/evaluatePolicy", { toolName, basePolicy, - args: parsedArgs, + args, }); // Evaluate the policy dynamically