Skip to content

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

Open
vaddisrinivas wants to merge 3 commits into
NousResearch:mainfrom
vaddisrinivas:feature/pre-tool-call-approve-action
Open

feat(plugins): add pre_tool_call approve action and plugin mode#11816
vaddisrinivas wants to merge 3 commits into
NousResearch:mainfrom
vaddisrinivas:feature/pre-tool-call-approve-action

Conversation

@vaddisrinivas

Copy link
Copy Markdown
Contributor

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

Closes #11812

@vaddisrinivas vaddisrinivas force-pushed the feature/pre-tool-call-approve-action branch from 5a166e4 to 855fd12 Compare April 17, 2026 21:55
vaddisrinivas and others added 3 commits April 17, 2026 23:43
- Add approval_callback parameter to AIAgent.__init__ for SDK usage pattern
- Add _approval_callback_context context manager for lifecycle management
- Wrap run_conversation execution with approval callback context
- Enables gateway-style approval workflows for SDK integrations

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add "approve" action to get_pre_tool_call_directive for plugin override
- Add "plugin" approval mode to delegate approval to pre_tool_call hooks
- Update terminal_tool to check for approve directive before built-in checks
- Backward compatibility: get_pre_tool_call_block_message wrapper retained

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Add platform_class field to PlatformConfig for custom adapter path
- Update _create_adapter to check for platform_class override
- Enables plugin/third-party platform adapters without code changes
- Supports dynamic class loading via importlib.import_module

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@vaddisrinivas vaddisrinivas force-pushed the feature/pre-tool-call-approve-action branch from 855fd12 to d833eb1 Compare April 18, 2026 03:43
@alt-glitch alt-glitch added type/feature New feature or request P2 Medium — degraded but workaround exists comp/plugins Plugin system and bundled plugins tool/terminal Terminal execution and process management labels Apr 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/plugins Plugin system and bundled plugins P2 Medium — degraded but workaround exists tool/terminal Terminal execution and process management type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(plugins): add pre_tool_call "approve" action and plugin mode

2 participants