diff --git a/packages/coding-agent/CHANGELOG.md b/packages/coding-agent/CHANGELOG.md index 1c1e94df..7919de4d 100644 --- a/packages/coding-agent/CHANGELOG.md +++ b/packages/coding-agent/CHANGELOG.md @@ -2,6 +2,10 @@ ## [Unreleased] +### Fixed + +- **Hooks wrap custom tools**: Custom tools are now executed through the hook wrapper, so `tool_call`/`tool_result` hooks can observe, block, and modify custom tool executions (consistent with hook type docs). + ## [0.24.0] - 2025-12-19 ### Added diff --git a/packages/coding-agent/docs/hooks.md b/packages/coding-agent/docs/hooks.md index 7e4c9d26..84192330 100644 --- a/packages/coding-agent/docs/hooks.md +++ b/packages/coding-agent/docs/hooks.md @@ -645,7 +645,7 @@ main.ts ## Tool Wrapping -Tools are wrapped with hook callbacks before the agent is created: +Tools (built-in and custom) are wrapped with hook callbacks after tool discovery/selection, before the agent is created: ``` main.ts diff --git a/packages/coding-agent/src/main.ts b/packages/coding-agent/src/main.ts index 0a43cbe4..2deb5d5d 100644 --- a/packages/coding-agent/src/main.ts +++ b/packages/coding-agent/src/main.ts @@ -315,9 +315,6 @@ export async function main(args: string[]) { if (hooks.length > 0) { const timeout = settingsManager.getHookTimeout(); hookRunner = new HookRunner(hooks, cwd, timeout); - - // Wrap tools with hook callbacks - selectedTools = wrapToolsWithHooks(selectedTools, hookRunner); } // Discover and load custom tools from: @@ -344,6 +341,11 @@ export async function main(args: string[]) { selectedTools = [...selectedTools, ...customToolInstances] as typeof selectedTools; } + // Wrap tools with hook callbacks (built-in and custom) + if (hookRunner) { + selectedTools = wrapToolsWithHooks(selectedTools, hookRunner); + } + // Create agent const agent = new Agent({ initialState: {