don't confirm invalid params in terminal tool, or in general (added comments to base class) (#187)

This commit is contained in:
Olcan 2025-04-27 10:25:12 -07:00 committed by GitHub
parent 7828e813a8
commit 9de2e82b8f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 0 deletions

View File

@ -244,6 +244,9 @@ Use this tool for running build steps (\`npm install\`, \`make\`), linters (\`es
async shouldConfirmExecute(
params: TerminalToolParams,
): Promise<ToolCallConfirmationDetails | false> {
if (this.validateToolParams(params)) {
return false; // skip confirmation, execute call will fail immediately
}
const rootCommand =
params.command
.trim()

View File

@ -36,6 +36,8 @@ export interface Tool<
/**
* Validates the parameters for the tool
* Should be called from both `shouldConfirmExecute` and `execute`
* `shouldConfirmExecute` should return false immediately if invalid
* @param params Parameters to validate
* @returns An error message string if invalid, null otherwise
*/
@ -102,6 +104,8 @@ export abstract class BaseTool<
/**
* Validates the parameters for the tool
* This is a placeholder implementation and should be overridden
* Should be called from both `shouldConfirmExecute` and `execute`
* `shouldConfirmExecute` should return false immediately if invalid
* @param params Parameters to validate
* @returns An error message string if invalid, null otherwise
*/