hermes - ✅(Solved) Fix feat(plugins): add pre_tool_call "approve" action and plugin mode [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
NousResearch/hermes-agent#11812Fetched 2026-04-18 05:58:47
View on GitHub
Comments
0
Participants
1
Timeline
1
Reactions
0
Participants
Timeline (top)
cross-referenced ×1

Extend the pre_tool_call hook system to support an {"action": "approve"} directive, allowing plugins to override built-in approval checks (e.g., dangerous command detection).

Root Cause

Extend the pre_tool_call hook system to support an {"action": "approve"} directive, allowing plugins to override built-in approval checks (e.g., dangerous command detection).

Fix Action

Fixed

PR fix notes

PR #11816: feat(plugins): add pre_tool_call approve action and plugin mode

Description (problem / solution / changelog)

Summary

Extend pre_tool_call hooks to support {"action": "approve"} directive, allowing plugins to override built-in approval checks (e.g., dangerous command detection). Also adds "plugin" approval mode.

What changed

  • hermes_cli/plugins.py:

    • Rename get_pre_tool_call_block_message()get_pre_tool_call_directive()
    • Return tuple (directive, message) where directive is "block", "approve", or None
  • tools/terminal_tool.py:

    • Check for "approve" directive before security checks
    • Skip dangerous-command guard when plugin approves
  • tools/approval.py:

    • Add "plugin" to documented approval modes
    • Return early with {"approved": True, "plugin_mode": True} when in plugin mode
  • tests/: Updated for new function signature

How to test

# Plugin that approves specific commands
def my_pre_tool_call(hook_name, **kwargs):
    if hook_name == "pre_tool_call":
        tool = kwargs.get("tool_name")
        args = kwargs.get("args", {})
        if tool == "terminal" and "echo" in args.get("command", ""):
            return {"action": "approve", "message": "Echo is safe"}
    return []

# Set approval mode to plugin
# In config.yaml: approvals: {mode: "plugin"}

Platforms tested

  • macOS (Darwin 25.3.0)

Related

  • Builds on existing {"action": "block"} mechanism
  • See #9388 for pre_tool_call hook discussion

Closes #11812

Changed files

  • gateway/config.py (modified, +9/-1)
  • gateway/run.py (modified, +14/-2)
  • hermes_cli/plugins.py (modified, +29/-12)
  • run_agent.py (modified, +48/-2)
  • tools/approval.py (modified, +6/-1)
  • tools/terminal_tool.py (modified, +17/-0)
RAW_BUFFERClick to expand / collapse

Summary

Extend the pre_tool_call hook system to support an {"action": "approve"} directive, allowing plugins to override built-in approval checks (e.g., dangerous command detection).

Changes

  • hermes_cli/plugins.py:

    • Rename get_pre_tool_call_block_message()get_pre_tool_call_directive()
    • Return tuple (directive, message) where directive is "block", "approve", or None
  • tools/terminal_tool.py:

    • Check for "approve" directive before security checks
    • Skip dangerous-command guard when plugin approves
  • tools/approval.py:

    • Add "plugin" to approval modes
    • Return early with {"approved": True, "plugin_mode": True} when in plugin mode

Related

  • Builds on existing {"action": "block"} mechanism
  • See #9388 for discussion on pre_tool_call hook semantics

extent analysis

TL;DR

To support plugin-based approval checks, update the pre_tool_call hook system to handle an "approve" directive and modify relevant modules to respect this new directive.

Guidance

  • Review the changes in hermes_cli/plugins.py to ensure the get_pre_tool_call_directive() function correctly returns the (directive, message) tuple, supporting both "block" and "approve" directives.
  • Verify that tools/terminal_tool.py checks for the "approve" directive before performing security checks and skips the dangerous-command guard when a plugin approves.
  • Ensure tools/approval.py correctly implements the "plugin" approval mode, returning early with {"approved": True, "plugin_mode": True} when in this mode.
  • Test the updated system with various plugins to confirm they can effectively override built-in approval checks.

Example

# Example usage in a plugin
def pre_tool_call(tool):
    # Plugin logic to determine if the tool should be approved
    if should_approve(tool):
        return ("approve", None)
    # Otherwise, return None or a "block" directive as needed
    return None

Notes

The implementation details of the should_approve function in the example are left to the plugin developer, as they depend on the specific requirements and logic of each plugin.

Recommendation

Apply the workaround by implementing the "approve" directive support as described, allowing plugins to override built-in approval checks. This approach provides flexibility and customization for approval logic through plugins.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

hermes - ✅(Solved) Fix feat(plugins): add pre_tool_call "approve" action and plugin mode [1 pull requests, 1 participants]