diff --git a/integration-tests/hooks-system.test.ts b/integration-tests/hooks-system.test.ts index 0840b2cdb7..a3d3821c01 100644 --- a/integration-tests/hooks-system.test.ts +++ b/integration-tests/hooks-system.test.ts @@ -2017,6 +2017,10 @@ console.log(JSON.stringify({ // 3. Final setup with full settings rig.setup('Hook Disabling Multiple Ops', { + fakeResponsesPath: join( + import.meta.dirname, + 'hooks-system.multiple-ops.responses', + ), settings: { hooksConfig: { enabled: true, diff --git a/packages/core/src/core/coreToolHookTriggers.ts b/packages/core/src/core/coreToolHookTriggers.ts index 8ebaf7a64c..bb96b2134d 100644 --- a/packages/core/src/core/coreToolHookTriggers.ts +++ b/packages/core/src/core/coreToolHookTriggers.ts @@ -76,6 +76,7 @@ export async function executeToolWithHooks( setExecutionIdCallback?: (executionId: number) => void, config?: Config, originalRequestName?: string, + skipBeforeHook?: boolean, ): Promise { // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion const toolInput = (invocation.params || {}) as Record; @@ -86,7 +87,7 @@ export async function executeToolWithHooks( const mcpContext = config ? extractMcpContext(invocation, config) : undefined; const hookSystem = config?.getHookSystem(); - if (hookSystem) { + if (hookSystem && !skipBeforeHook) { const beforeOutput = await hookSystem.fireBeforeToolEvent( toolName, toolInput, diff --git a/packages/core/src/scheduler/tool-executor.ts b/packages/core/src/scheduler/tool-executor.ts index 541e42d9ed..138bfabaf8 100644 --- a/packages/core/src/scheduler/tool-executor.ts +++ b/packages/core/src/scheduler/tool-executor.ts @@ -116,6 +116,7 @@ export class ToolExecutor { setExecutionIdCallback, this.config, request.originalRequestName, + true, // skipBeforeHook ); const toolResult: ToolResult = await promise;