Skip to content

[OpenClaw Plugin] before_tool_call hook not intercepting exec commands #1717

Open

Description

@mismcinffh-svg

Environment

  • OpenClaw: 2026.5.3-1
  • RTK: 0.38.0
  • OS: Linux (WSL2)

Issue Description

The RTK OpenClaw plugin is installed and shows as enabled in openclaw plugins list, but the before_tool_call hook does not intercept exec tool calls. Commands like git status and ls still produce full/uncompressed output rather than RTK-filtered output.

Installation Steps

  1. Installed RTK: curl -fsSL https://raw.githubusercontent.com/rtk-ai/rtk/refs/heads/master/install.sh | sh
  2. Copied index.ts and openclaw.plugin.json to ~/.openclaw/extensions/rtk-rewrite/
  3. Installed plugin: openclaw plugins install ~/.openclaw/extensions/rtk-rewrite
  4. Restarted gateway: openclaw gateway restart

Plugin Status

  • openclaw plugins list -> rtk-rewrite: enabled
  • openclaw plugins doctor -> "hook-only. This remains a supported compatibility path"
  • openclaw hooks list -> Does NOT list rtk-rewrite (only bundled hooks appear)
  • But [plugins] [rtk] OpenClaw hook registered appears in doctor output

Config (openclaw.json)

{
  "plugins": {
    "enabled": true,
    "allow": [
      "telegram",
      "browser",
      "minimax",
      "deepseek",
      "google",
      "memory-core",
      "tavily",
      "volcengine",
      "rtk-rewrite"
    ],
    "entries": {
      "rtk-rewrite": {
        "enabled": true,
        "config": {
          "enabled": true,
          "verbose": true
        }
      }
    }
  }
}

Plugin Source (index.ts)

export default function register(api: any) {
  const pluginConfig = api.config ?? {};
  const enabled = pluginConfig.enabled !== false;
  const verbose = pluginConfig.verbose === true;

  if (!enabled) return;
  if (!checkRtk()) {
    console.warn("[rtk] rtk binary not found in PATH — plugin disabled");
    return;
  }

  api.on(
    "before_tool_call",
    (event: { toolName: string; params: Record<string, unknown> }) => {
      if (event.toolName !== "exec") return;
      const command = event.params?.command;
      if (typeof command !== "string") return;
      const rewritten = tryRewrite(command);
      if (!rewritten) return;
      if (verbose) {
        console.log(`[rtk] ${command} -> ${rewritten}`);
      }
      return { params: { ...event.params, command: rewritten } };
    },
    { priority: 10 }
  );

  if (verbose) {
    console.log("[rtk] OpenClaw plugin registered");
  }
}

Test Results

Command Expected (RTK) Actual
git status ? Untracked: 20 files Full git status output
ls -la Compressed listing Full listing with all details

Questions

  1. Is there an additional step required to ensure before_tool_call fires for exec tool calls?
  2. Is there a compatibility issue between OpenClaw 2026.5.3-1 and the hook-only plugin format?
  3. How can we enable additional debug logs to trace hook execution?

Thank you for this excellent project!

Activity

  1. pszymkowiak commented on May 27, 2026

    @pszymkowiak
    Collaborator

    wshm · Automated triage by AI

    🔍 Automated Triage

    🐛 Category bug
    🟡 Priority medium
    🎯 Confidence 82%

    Summary

    OpenClaw plugin's before_tool_call hook silently fails to intercept exec tool calls despite plugin showing as enabled; investigate hook registration/event routing for exec tools in OpenClaw integration.


    Triaged automatically by wshm · This is an automated analysis, not a human review.

  2. mychataa commented on May 31, 2026

    @mychataa

    I am also experiencing this exact same issue on OpenClaw 2026.4.23 with rtk-rewrite plugin.

    My observation:

    • openclaw plugins list shows rtk-rewrite: enabled
    • openclaw hooks list does NOT show rtk-rewrite (only 4 bundled hooks)
    • Commands like ls -la produce standard output instead of rtk compressed output
    • rtk rewrite ls -la correctly returns rtk ls -la when run directly

    Conclusion: The before_tool_call hook is registered but not firing for exec tool calls. This is a blocking issue for using rtk-rewrite.

    Please let us know if there is a fix or workaround. Thank you!

  3. kzzalews commented on Jul 1, 2026

    @kzzalews
    Contributor

    Opened #2783 with a fix.

    Root cause was twofold:

    1. package.json missing openclaw.extensions — without this field, OpenClaw discovers the plugin via plugins list but cannot resolve its entry point, so the runtime never loads it. before_tool_call never fires.

    2. openclaw.plugin.json missing activation.onStartup — since OpenClaw 2026.6.x, plugins without an explicit activation entry are no longer auto-loaded at startup.

    The PR adds both fields and introduces an approvalMode config option ("auto" / "ask", default "auto") so exit code 3 no longer hard-blocks on requireApproval (120s timeout → deny).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions