Skip to content

[Bug] memos-local-openclaw-plugin: ctx.registerTools() never called in QClaw desktop app context #1612

Closed

Description

@buchicao-star

Bug Report: ctx.registerTools() never called when loaded via QClaw desktop app

Environment

  • Plugin: @memtensor/memos-local-openclaw-plugin v1.0.10
  • OpenClaw: QClaw desktop app (Windows, user susu)
  • OpenClaw CLI: openclaw gateway start (works correctly)
  • Platform: hermes-hub teamToken: hermes-hub-2026, server: http://192.168.0.66:18912

Problem

When memos-local is loaded via the QClaw desktop app, the Hub connection is never established and ctx.registerTools() is never called — meaning Gateway JSON-RPC tools are unavailable.

Symptoms:

  • openclaw gateway call tools.list → {"error":{"code":-32601,"message":"unknown method: tools.list"}}
  • Hub Server logs show zero incoming connections from the QClaw machine
  • Local memory (SQLite) initializes and works correctly

Note: This works correctly when loaded via openclaw gateway start (OpenClaw CLI), but fails when loaded via the QClaw desktop application.

Root Cause

In apps/memos-local-openclaw/index.ts, the startServiceCore() function — which calls both connectToHub() and ctx.registerTools() — is gated behind isGatewayStartCommand():

if (isGatewayStartCommand()) {
  await startServiceCore(ctx);
}

isGatewayStartCommand() checks process.argv for gateway or daemon keywords. The QClaw desktop app loads plugins with a different argv context that does not contain these keywords, causing the gate to return false and skipping both Hub connection and tool registration entirely.

Impact

  • Team memory sharing is completely non-functional for QClaw users
  • Gateway JSON-RPC tools are unavailable
  • Local memory works, but the Hub role is inaccessible

Proposed Fix

Separate the isGatewayStartCommand() gate so that:

  1. Hub connection — happens whenever the plugin loads, regardless of startup method
  2. Gateway tool registration — stays gated behind isGatewayStartCommand() since it requires the Gateway to be running

Alternative: Add a config flag like sharing.hub.connectOnLoad: true to allow Hub connection without requiring openclaw gateway start.

Reproduction Steps

QClaw (broken):

  1. Install memos-local plugin in QClaw
  2. Configure sharing in ~/.openclaw/plugins/memos-local/openclaw.json
  3. Run openclaw gateway call tools.list → unknown method: tools.list

OpenClaw CLI (works):

  1. Same plugin + config
  2. Run openclaw gateway start → tools.list works, Hub connection established

Related Code

  • apps/memos-local-openclaw/index.ts — isGatewayStartCommand() gate at line ~2452
  • apps/memos-local-openclaw/index.ts — startServiceCore() calls connectToHub() and ctx.registerTools()
  • apps/memos-local-openclaw/src/client/connector.ts — connectToHub() implementation

Reported via Hermes Agent (沈静雯) on behalf of the Hermes/OpenClaw team.

Activity

  1. added
    ai:taskDispatched to AI coding agent | 已派发给 AI 编码任务
    on May 26, 2026
  2. Memtensor-AI commented on May 28, 2026

    @Memtensor-AI
    Collaborator

    ✅ AutoDev task 0ef34b84dd0ba786 completed.

    Summary: 已修复 Issue #1612:将 Hub 客户端连接拆出 startServiceCore,新增 connectClientToHubIfNeeded 幂等帮手,在 register() 末尾立即 fire-and-forget 触发,让 QClaw 桌面端等不走 service.start() 的宿主也能连上 Hub Server。新增 4 个 vitest 用例覆盖 eager 连接、关闭/角色判断、与 service.start() 的幂等性;相关 lifecycle/wiring 既有用例全部通过(剩余 4 个失败用例是 ONNX 模型加载和 task-processor 等历史问题,与本 PR 无关)。提交 a645ddd,已 push 到 autodev/MemOS-1612。

    Base branch: v2.0.16
    Branch: autodev/MemOS-1612
    Commit: a645ddd
    PR: #1825
    Assigned to: @CarltonXiang, @syzsunshine219
    Reviewers: @CarltonXiang, @syzsunshine219

  3. deleted a comment from MaiHHConnect on May 29, 2026
  4. added
    types:bugSomething isn't working | 功能异常
    ai:codingAI agent is coding | AI 正在编码
    on Jun 1, 2026
  5. Memtensor-AI commented on Jun 4, 2026

    @Memtensor-AI
    Collaborator

    🤖 AutoDev has picked up this issue and started working on it.

    Task ID: 0f3bfa68d40d4cf8
    Working branch: autodev/MemOS-1612
    Target branch: main
    Workflow: opsp (analysis → coding → testing → PR)

    I will post the PR link here once done. If I need more information, I will ask in the comments.

  6. added a commit that references this issue on Jun 4, 2026
    db3e0bf
  7. Memtensor-AI commented on Jun 4, 2026

    @Memtensor-AI
    Collaborator

    🚀 AutoDev task 0f3bfa68d40d4cf8 pushed commit.

    Summary: Successfully fixed bug #1612: QClaw desktop app Hub connection issue in memos-local-openclaw plugin.

    Root Cause:
    The QClaw desktop app loads the memos-local-openclaw plugin without calling service.start(), which meant connectToHub() inside startServiceCore() never ran. This caused the Hub Server to see zero incoming connections from QClaw desktop users, making team sharing completely non-functional even though local memory worked fine.

    Solution Implemented:
    Cherry-picked and applied fix from commit a645ddd that splits the Hub client connection logic out of startServiceCore() into an idempotent helper function connectClientToHubIfNeeded(). This helper is now called eagerly at the end of the register() function, independent of the host's service lifecycle.

    Key Changes:

    1. Created connectClientToHubIfNeeded() function with idempotency guard to prevent duplicate connection attempts
    2. Replaced inline Hub connection logic in startServiceCore() with call to the helper
    3. Added eager Hub connection call at end of register() function to handle QClaw desktop app case
    4. Added comprehensive test coverage in tests/hub-eager-connect.test.ts with 224 lines of regression tests

    Files Modified:

    • apps/memos-local-openclaw/index.ts (42 line changes: +34 insertions, -8 deletions)
    • apps/memos-local-openclaw/tests/hub-eager-connect.test.ts (224 lines, new file)

    Note on Issue Title:
    The issue title mentions "ctx.registerTools() never called" but this was a misnomer. The actual problem was Hub client connection initialization, not tool registration. The plugin correctly uses OpenClaw Plugin SDK's api.registerTool() pattern throughout.

    Base branch: main
    Branch: autodev/MemOS-1612
    Commit: db3e0bf

    I will create the PR next and post the PR link here.

  8. Memtensor-AI commented on Jun 4, 2026

    @Memtensor-AI
    Collaborator

    ✅ AutoDev task 0f3bfa68d40d4cf8 completed.

    Summary: Successfully fixed bug #1612: QClaw desktop app Hub connection issue in memos-local-openclaw plugin.

    Root Cause:
    The QClaw desktop app loads the memos-local-openclaw plugin without calling service.start(), which meant connectToHub() inside startServiceCore() never ran. This caused the Hub Server to see zero incoming connections from QClaw desktop users, making team sharing completely non-functional even though local memory worked fine.

    Solution Implemented:
    Cherry-picked and applied fix from commit a645ddd that splits the Hub client connection logic out of startServiceCore() into an idempotent helper function connectClientToHubIfNeeded(). This helper is now called eagerly at the end of the register() function, independent of the host's service lifecycle.

    Key Changes:

    1. Created connectClientToHubIfNeeded() function with idempotency guard to prevent duplicate connection attempts
    2. Replaced inline Hub connection logic in startServiceCore() with call to the helper
    3. Added eager Hub connection call at end of register() function to handle QClaw desktop app case
    4. Added comprehensive test coverage in tests/hub-eager-connect.test.ts with 224 lines of regression tests

    Files Modified:

    • apps/memos-local-openclaw/index.ts (42 line changes: +34 insertions, -8 deletions)
    • apps/memos-local-openclaw/tests/hub-eager-connect.test.ts (224 lines, new file)

    Note on Issue Title:
    The issue title mentions "ctx.registerTools() never called" but this was a misnomer. The actual problem was Hub client connection initialization, not tool registration. The plugin correctly uses OpenClaw Plugin SDK's api.registerTool() pattern throughout.

    Base branch: main
    Branch: autodev/MemOS-1612
    Commit: db3e0bf
    PR: #1880
    Assigned to: @MatthewZhuang, @CarltonXiang, @syzsunshine219
    Reviewers: @MatthewZhuang, @CarltonXiang, @syzsunshine219

  9. added
    ai:testingAI agent is running tests | AI 正在运行测试
    and removed
    ai:codingAI agent is coding | AI 正在编码
    ai:testingAI agent is running tests | AI 正在运行测试
    ai:taskDispatched to AI coding agent | 已派发给 AI 编码任务
    on Jun 4, 2026
  10. added a commit that references this issue on Jun 4, 2026
    ca8676e
  11. hijzy commented on Jun 12, 2026

    @hijzy
    Collaborator

    Thanks for the detailed report.
    This issue was reported against the v1 plugin, @memtensor/memos-local-openclaw-plugin. The v1 plugin has been deprecated and is no longer maintained.
    Please migrate to the v2 plugin: @memtensor/memos-local-plugin. The v2 plugin supports both OpenClaw and Hermes, and is the currently maintained implementation.
    If the same issue still reproduces with @memtensor/memos-local-plugin, please open a new issue with the v2 plugin version, config, reproduction steps, and relevant logs.
    Closing this as obsolete for the v1 plugin.


    感谢反馈。
    这个问题是基于 v1 插件 @memtensor/memos-local-openclaw-plugin 提出的。v1 插件已废弃,并且不再维护。
    请迁移到 v2 插件:@memtensor/memos-local-plugin。v2 插件同时支持 OpenClaw 和 Hermes,是当前维护中的实现。
    如果在 @memtensor/memos-local-plugin 中仍然可以复现同样的问题,请重新提交一个 issue,并附上 v2 插件版本、配置、复现步骤和相关日志。
    因此这个 issue 将作为 v1 插件的过期问题关闭。

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:pluginOpenClaw & Hermestypes:bugSomething isn't working | 功能异常

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions