fix(tools): wrap ALL registry tools with hooks, not just active ones

wrappedToolRegistry was only containing activeToolsArray (4 tools).
Now wraps all tools from the registry so hooks can enable any tool.
This commit is contained in:
Mario Zechner 2026-01-04 18:47:57 +01:00
parent 2849623afc
commit 31438fdf2a

View file

@ -656,9 +656,11 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
let wrappedToolRegistry: Map<string, AgentTool> | undefined;
if (hookRunner) {
activeToolsArray = wrapToolsWithHooks(activeToolsArray as AgentTool[], hookRunner);
// Also create a wrapped version of the registry for setTools
// Wrap ALL registry tools (not just active) so hooks can enable any
const allRegistryTools = Array.from(toolRegistry.values());
const wrappedAllTools = wrapToolsWithHooks(allRegistryTools, hookRunner);
wrappedToolRegistry = new Map<string, AgentTool>();
for (const tool of activeToolsArray as AgentTool[]) {
for (const tool of wrappedAllTools) {
wrappedToolRegistry.set(tool.name, tool);
}
}