Skip to content

[BUG] [pre_tool_call] hook silently skipped in Hermes v0.19+ — rewrite never fires #16

Description

@todddhunter

Describe the bug

The rtk-hermes plugin registers correctly and rtk rewrite works when called manually, but command rewriting never happens during live tool execution on Hermes v0.19.0+. The pre_tool_call hook is wired up via ctx.register_hook() but never invoked because Hermes changed its tool dispatch to pass skip_pre_tool_call_hook=True.

To Reproduce

Install rtk-hermes v1.2.3 on Hermes v0.19.0 (or v0.20.0)
Enable in config.yaml: plugins.enabled: [rtk-rewrite]
Restart Hermes — logs confirm [rtk] Hermes plugin registered
Run any shell command via the terminal tool, e.g. ls -la /opt/data
Output is full GNU format — rewrite did not fire
Expected behavior

Terminal commands should be rewritten by RTK (e.g., ls -la → rtk ls -la) before execution, producing compact output.

Actual behavior

Commands execute unmodified. The hook is registered but never called during tool dispatch.

Root cause

In Hermes v0.19.0, tool_executor.py calls handle_function_call() with skip_pre_tool_call_hook=True on both execution paths (lines ~1517, ~1559). Additionally, agent_runtime_helpers.py passes the same flag (~line 2600). The pre_tool_call hook contract was changed to block/approve-only ({action: "block"|"approve"}), and in-place arg mutation (which rtk-hermes relies on) is no longer read by the executor.

Evidence

Code
· python

Hermes v0.19 tool_executor.py — both paths skip the hook:

await handle_function_call(..., skip_pre_tool_call_hook=True, ...)

rtk-hermes init.py — registers pre_tool_call expecting arg mutation:

ctx.register_hook("pre_tool_call", _pre_tool_call)

_pre_tool_call mutates args in-place, which Hermes no longer reads:

args["command"] = rewritten_command
return True # (no-op under skip_pre_tool_call_hook=True)
Environment

Hermes Agent: v0.19.0 (2026.7.20), confirmed also on v0.20.0 (2026.8.3)
RTK: v0.44.2
rtk-hermes: v1.2.3
Python: 3.13
Suggested fix

Switch from pre_tool_call arg mutation to a hook that Hermes v0.19+ actually invokes for command transformation — e.g. transform_terminal_output, tool_request_middleware, or whatever the current mechanism is for modifying tool args before dispatch. The pre_tool_call block/approve pattern is no longer suitable for this use case.

This was prepared by my Hermes Agent

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions