#1925·agent-zero

tool_execute_before extension hook cannot modify tool arguments - tool.args is not re-read after the hook

Author: wgnraiCreated Sep 28, 2026Updated Sep 28, 2026

Is your feature request related to a problem? Please describe.

The tool_execute_before extension hook cannot legitimately transform tool arguments. Hooks receive the tool kwargs and may mutate them, but the framework does not re-read the mutated arguments after the hook completes — the tool is invoked with the original arguments. This makes argument sanitization/transformation hooks (e.g. unmasking secret placeholders in tool inputs) silently ineffective unless the framework is patched locally.

Describe the solution you'd like

Re-assign the (possibly mutated) tool arguments after the tool_execute_before hook runs, so transformations made by hooks are respected when the tool executes. Conceptually: after the hook completes, tool.args = <mutated tool_args> (or the equivalent assignment in the current call path) before invoking tool.execute().

Describe alternatives you've considered

  • Mutating the args object in place — insufficient: the framework does not re-read the reference after the hook.
  • Bypassing hooks with a local fork patch — works but diverges from upstream and must be re-applied on every update.

Additional context

We (wgnr.ai) run a customized Agent Zero deployment that hooks tool_execute_before (extensions/python) to sanitize/unmask tool arguments — e.g. secret placeholder expansion for browser and tool inputs. Our local patch (commit d7ed0efb on our fork) re-assigns the mutated args after tool_execute_before completes and has been tested in production since September 2026.

A reference implementation exists on our fork; happy to open a PR if the direction is accepted.