openclaw - ✅(Solved) Fix [Bug] Feishu plugin registers tools multiple times on gateway startup [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
openclaw/openclaw#55429Fetched 2026-04-08 01:39:36
View on GitHub
Comments
0
Participants
1
Timeline
2
Reactions
0
Author
Participants
Timeline (top)
cross-referenced ×1referenced ×1

Root Cause

🔍 Root Cause Analysis

Fix Action

Fixed

PR fix notes

PR #55446: fix(plugins): deduplicate tool registration on startup

Description (problem / solution / changelog)

Summary

Fixes #55429

  • Add deduplication guard to registerTool in src/plugins/registry.ts that skips re-registration when the same tool name is already registered by the same plugin, matching the existing pattern used by registerHook
  • Emits a warn-level diagnostic when a duplicate registration is skipped, aiding debuggability

Root Cause

The gateway startup's deferred channel plugin reload pattern (loadGatewayStartupPluginsreloadDeferredGatewayPlugins) can call a plugin's register() function multiple times. While registerTool was gated on registrationMode === "full", plugins loaded in "full" mode on both passes (e.g., when they lack startupDeferConfiguredChannelFullLoadUntilAfterListen) would register their tools twice. Unlike registerHook, registerTool had no uniqueness check.

Test plan

  • Verified existing src/plugins/tools.optional.test.ts (8 tests) pass
  • Verified existing src/plugins/loader.test.ts (57 tests) pass
  • Verified existing src/plugins/runtime.test.ts and src/plugins/voice-call.plugin.test.ts (12 tests) pass
  • pnpm check passes (format, lint, typecheck, all boundary checks)
  • Manual: confirm Feishu tools appear once in gateway logs on startup

Changed files

  • src/plugins/registry.ts (modified, +15/-0)

Code Example

08:24:47+08:00 [gateway] feishu_doc: Registered feishu_doc, feishu_app_scopes
08:24:47+08:00 [gateway] feishu_chat: Registered feishu_chat tool
08:24:47+08:00 [gateway] feishu_wiki: Registered feishu_wiki tool
08:24:47+08:00 [gateway] feishu_drive: Registered feishu_drive tool
08:24:47+08:00 [gateway] feishu_bitable: Registered bitable tools
08:24:50+08:00 [plugins] feishu_doc: Registered feishu_doc, feishu_app_scopes
08:24:50+08:00 [plugins] feishu_chat: Registered feishu_chat tool
... (same 5 tools repeat)
08:24:51+08:00 [plugins] feishu_doc: Registered feishu_doc, feishu_app_scopes
08:24:51+08:00 [plugins] feishu_chat: Registered feishu_chat tool
... (same 5 tools repeat again, 100ms later)
RAW_BUFFERClick to expand / collapse

🐛 Bug Description

On every Gateway startup, the Feishu plugin registers its tools (feishu_doc, feishu_chat, feishu_wiki, feishu_drive, feishu_bitable) multiple times — typically 2 to 4 rounds of registration in rapid succession (~3 seconds apart).

📋 Logs

08:24:47+08:00 [gateway] feishu_doc: Registered feishu_doc, feishu_app_scopes
08:24:47+08:00 [gateway] feishu_chat: Registered feishu_chat tool
08:24:47+08:00 [gateway] feishu_wiki: Registered feishu_wiki tool
08:24:47+08:00 [gateway] feishu_drive: Registered feishu_drive tool
08:24:47+08:00 [gateway] feishu_bitable: Registered bitable tools
08:24:50+08:00 [plugins] feishu_doc: Registered feishu_doc, feishu_app_scopes
08:24:50+08:00 [plugins] feishu_chat: Registered feishu_chat tool
... (same 5 tools repeat)
08:24:51+08:00 [plugins] feishu_doc: Registered feishu_doc, feishu_app_scopes
08:24:51+08:00 [plugins] feishu_chat: Registered feishu_chat tool
... (same 5 tools repeat again, 100ms later)

🔍 Root Cause Analysis

The duplication appears to come from two separate plugin loading mechanisms in OpenClaw:

  1. First load: Gateway subsystem loads bundled plugins during initial startup
  2. Second load (~3s later): The plugins subsystem re-discovers and re-loads bundled plugins because plugins.allow is empty (no explicit allowlist configured)

Additionally, within the second load, the Feishu plugin's multiple entry points (api.js, setup-api.js, runtime-api.js, setup-entry.js) each independently call the registration function, causing the same 5 tools to be registered 4 times in rapid succession (~100ms apart).

🐙 Environment

  • OpenClaw: 2026.3.24 (cff6dc9)
  • Node.js: v24.14.0
  • OS: Windows_NT 10.0.26200 (x64)
  • Feishu plugin: bundled at dist/extensions/feishu/

✅ Expected Behavior

Each tool should be registered exactly once per Gateway session.

💢 Impact

  • Log noise: Every startup produces ~20–40 duplicate "Registered" log lines for Feishu tools
  • No functional impact observed: Tools work correctly despite repeated registration
  • Potential memory leak: Repeated registration of the same handlers may accumulate over restart cycles

🔧 Suggested Fixes

  1. Short-term (log noise): Add a guard in the Feishu plugin (or its entry modules) to skip re-registration if tools are already registered
  2. Long-term (architecture): Prevent the plugins subsystem from re-loading bundled plugins that were already loaded by the gateway subsystem at startup

📎 Full Gateway Startup Log

See original issue description with full terminal output from openclaw gateway command.

The log shows the Feishu plugin being registered 4 times within ~4 seconds on every startup, across both the gateway and plugins subsystems.

extent analysis

Fix Plan

To address the issue of multiple registrations, we'll implement a short-term fix by adding a guard in the Feishu plugin to skip re-registration if tools are already registered.

Step-by-Step Solution

  1. Create a registration tracker: Introduce a mechanism to track whether each tool has been registered.
  2. Check registration status: Before registering a tool, check the tracker to see if it has already been registered.
  3. Skip registration if already done: If a tool is found to be already registered, skip its registration process.

Example Code

// feishu_plugin.js
const registeredTools = {};

function registerTool(toolName) {
  if (registeredTools[toolName]) {
    console.log(`Tool ${toolName} is already registered, skipping.`);
    return;
  }
  // Registration logic here
  console.log(`Registered ${toolName} tool`);
  registeredTools[toolName] = true;
}

// Example usage
registerTool('feishu_doc');
registerTool('feishu_doc'); // This will be skipped

Verification

To verify that the fix worked, start the Gateway and observe the logs. The "Registered" log lines for Feishu tools should appear only once per tool per Gateway session.

Extra Tips

  • Consider implementing the long-term architectural fix to prevent the plugins subsystem from re-loading bundled plugins that were already loaded by the gateway subsystem at startup.
  • Review the plugin loading mechanisms to ensure they are optimized and do not cause unnecessary re-registrations.
  • Monitor the Gateway's performance and logs after applying the fix to ensure no new issues arise.

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

openclaw - ✅(Solved) Fix [Bug] Feishu plugin registers tools multiple times on gateway startup [1 pull requests, 1 participants]