tool_execute_before hook cannot modify tool arguments (mutated args not re-read)
Author: wgnraiCreated Sep 28, 2026Updated Sep 28, 2026
- Problem: Extensions hooking
tool_execute_before(extensions/python) mutate tool kwargs (e.g., sanitizing or expanding placeholders in tool inputs), but the framework invokes the tool with the ORIGINAL arguments — the mutated kwargs are never re-assigned after the hook completes. This makes argument transformation hooks impossible without core edits. - Reproduction: Register a
tool_execute_beforeextension that changes a tool's args; the executed tool receives the pre-hook values. - Proposed fix: Re-assign the mutated arguments after the
tool_execute_beforehook chain runs (one line:tool.args = tool_args/ equivalent re-read of hook output). We run this as a local patch in production (fork commit d7ed0efb) since 2026-09 with no regressions. - Offer: Happy to open a PR if the direction is accepted.
Source: agent0ai/agent-zero