Skip to content

bug(plugins): plugin tools unavailable in sub-agent sessions due to lifecycle ordering #56208

Description

@GodsBoy

Summary

Plugin-registered tools are unavailable in sub-agent sessions because createOpenClawTools() runs before loadOpenClawPlugins() completes for the sub-agent's execution context. Tools work correctly in the initial gateway session and after a gateway restart.

Reproduction

  1. Configure a plugin that registers tools via api.registerTool() in its register() function (e.g., @honcho-ai/openclaw-honcho)
  2. Add the plugin's tool names to an agent profile's tools.allow or tools.profile allowlist
  3. Start the gateway — tools work in the primary session
  4. Spawn a sub-agent session — tools are reported as unknown

Log Evidence

# Primary session — tools register correctly:
05:26:22 info gateway — Honcho memory plugin loaded
05:26:25 info gateway — Honcho memory ready

# Sub-agent session — tool resolver runs BEFORE plugin loads:
05:30:27 warn tools — tools.profile (coding) allowlist contains unknown entries
  (honcho_search_conclusions, honcho_search_messages, honcho_ask, honcho_context, honcho_session)
05:30:27 warn tools — tools.allow allowlist contains unknown entries
  (honcho_search_conclusions, honcho_search_messages, honcho_ask, honcho_context, honcho_session)

# Plugin loads 23 seconds AFTER tool resolution:
05:30:50 info plugins — Honcho memory plugin loaded

Root Cause

In the sub-agent initialization path, createOpenClawTools() (which calls resolvePluginTools()buildPluginToolGroups()stripPluginOnlyAllowlist()) executes before loadOpenClawPlugins() has called the plugin's register() function. The fresh plugin registry is empty when tool resolution happens.

Code Path (pi-embedded-BaSvmUpW.js)

  1. Tool resolution (line ~115963): applyToolPolicyPipeline() validates allowlist entries against pluginGroups built from currently instantiated tools
  2. Plugin loading (line ~147194): loadOpenClawPlugins() creates registry, calls register() on each plugin
  3. The gap: Step 1 happens before step 2 for sub-agent sessions

Plugin SDK Limitation

The plugin SDK has no static tool declaration mechanism:

  • openclaw.plugin.json manifest has no tools or toolNames field
  • definePluginEntry() only supports register() for tool registration
  • registerTool() options (name, names, optional) don't include a scope or global flag

Expected Behavior

Plugin tools registered during register() should be available to all sessions, including sub-agents spawned after initial gateway startup.

Workaround

Gateway restart makes all tools available. No plugin-side workaround exists.

Suggested Fix

Ensure loadOpenClawPlugins() completes before createOpenClawTools() for sub-agent execution contexts. Alternatively, add a static tool declaration mechanism to the plugin manifest so tool names can be pre-registered before register() runs.

Environment

  • OpenClaw: >=2026.3.22
  • Plugin: @honcho-ai/openclaw-honcho v1.2.1
  • Plugin kind: memory

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions