Skip to content

Fix #1612: [Bug] memos-local-openclaw-plugin: ctx.registerTools() never called in QClaw des#1880

Merged
syzsunshine219 merged 1 commit into
dev-20260604-v2.0.19from
autodev/MemOS-1612
Jun 4, 2026
Merged

Fix #1612: [Bug] memos-local-openclaw-plugin: ctx.registerTools() never called in QClaw des#1880
syzsunshine219 merged 1 commit into
dev-20260604-v2.0.19from
autodev/MemOS-1612

Conversation

@Memtensor-AI

Copy link
Copy Markdown
Collaborator

Description

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.

Related Issue (Required): Fixes #1612

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Refactor (does not change functionality, e.g. code style improvements, linting)
  • Documentation update

How Has This Been Tested?

Executor did not report tests.

  • Unit Test
  • Test Script Or Test Steps (please provide)
  • Pipeline Automated API Test (please provide)

Checklist

  • I have performed a self-review of my own code
  • I have commented my code in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works
  • I have created related documentation issue/PR in MemOS-Docs (if applicable)
  • I have linked the issue to this PR (if applicable)
  • I have mentioned the person who will review this PR

@MatthewZhuang, @CarltonXiang, @syzsunshine219 please review this PR.

Reviewer Checklist

The QClaw desktop app loads this plugin without calling service.start(),
which used to mean connectToHub() inside startServiceCore() never ran.
The Hub Server saw zero incoming connections from QClaw users and team
sharing was completely non-functional, even though local memory worked.

Split the client-side Hub connection out of startServiceCore() into a
small idempotent helper and fire it eagerly at the end of register(),
independent of the host's service lifecycle. The gateway CLI path still
calls it via service.start() and the guard prevents a duplicate attempt.

Fixes #1612

Cherry-picked from commit a645ddd
@Memtensor-AI

Copy link
Copy Markdown
Collaborator Author

✅ Automated Test Results: PASSED

All tests passed (35/35 executed, 36 skipped). memos_local_plugin/smoke: 0 passed, 1 skipped, memos_local_plugin/contract: 35 passed, 35 skipped. Duration: 4s

Branch: autodev/MemOS-1612

@syzsunshine219 syzsunshine219 merged commit ca8676e into dev-20260604-v2.0.19 Jun 4, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants