Skip to content

fix(plugin): filter reserved Cloud info keys - #2486

Open
sufan721 wants to merge 1 commit into
MemTensor:mainfrom
sufan721:fix/cloud-info-reserved-keys
Open

sufan721 wants to merge 1 commit into
MemTensor:mainfrom
sufan721:fix/cloud-info-reserved-keys

Conversation

@sufan721

Copy link
Copy Markdown

Description

The OpenClaw plugin passed user-configured info fields directly to the MemOS Cloud /add/message endpoint. Cloud Hub rejects the reserved keys local_state, state, and localStats, regardless of their values, causing the add request to fail.

This change filters those three reserved keys when building the request payload. Other custom info fields and plugin-generated metadata are preserved. The plugin README files in English and Chinese have been updated, and a regression test verifies the filtering behavior.

This PR fixes the client-side payload issue only. Cloud Hub server-side delete schema and behavior, and long synchronous request timeouts, are outside this repository’s implementation scope.

Dependencies: None.

Related Issue (Required): Fixes #2423

Type of change

  • 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?

node --test apps/MemOS-Cloud-OpenClaw-Plugin/test/direct-session-user-id.test.mjs
node --test apps/MemOS-Cloud-OpenClaw-Plugin/test/*.test.mjs
git diff --check
  •  Unit Test
  •  Test Script Or Test Steps (please provide)
  •  Pipeline Automated API Test (please provide)

Results: focused tests passed (9/9); full plugin suite passed (64/64); git diff --check passed.

Checklist

  •  I have performed a self-review of my own code.
  •  I have commented my code in hard-to-understand areas, if needed.
  •  I have added tests that prove my fix is effective.
  •  I have created a related documentation issue/PR in [MemOS-Docs](https://github.com/MemTensor/MemOS-Docs), if applicable.
  •  I have linked the issue to this PR, if applicable.
  •  I have mentioned the person who will review this PR: @

Reviewer Checklist

@Memtensor-AI Memtensor-AI added area:plugin OpenClaw & Hermes status:in-progress Someone or AI is working on it | 人工或 AI 正在处理 labels Oct 12, 2026
@Memtensor-AI

Copy link
Copy Markdown
Collaborator

🤖 Open Code Review

Target: PR #2486
Task: 85e56e4106eb57a4
Base: main
Head: fix/cloud-info-reserved-keys

🔍 OpenCodeReview found 3 issue(s) in this PR.


1. apps/MemOS-Cloud-OpenClaw-Plugin/test/direct-session-user-id.test.mjs (L99)

Hardcoded platform-specific value. MEMOS_SOURCE in index.js is derived from process.platform (win32 → openclaw_win, darwin → openclaw_mac, linux → openclaw_linux, otherwise openclaw), so this assertion fails on macOS/Linux CI — which is exactly how the existing test at line 124 already avoids the problem by computing expectedSource dynamically. Derive the expected value the same way here.

💡 Suggested Change

Before:

  assert.equal(payload.info.source, "openclaw_win");

After:

  const expectedSource =
    process.platform === "win32"
      ? "openclaw_win"
      : process.platform === "darwin"
        ? "openclaw_mac"
        : process.platform === "linux"
          ? "openclaw_linux"
          : "openclaw";
  assert.equal(payload.info.source, expectedSource);

2. apps/MemOS-Cloud-OpenClaw-Plugin/index.js (L198)

local_state, state and localStats are magic strings with no indication of why they are reserved, and this Set is rebuilt on every buildAddMessagePayload call. Consider hoisting it to a module-level constant next to MEMOS_SOURCE and adding a one-line comment, so the reason these keys must never reach the Cloud API is documented in one place (the keys originate from the OpenClaw host config, which the plugin does not control).

💡 Suggested Change

Before:

  const reservedInfoKeys = new Set(["local_state", "state", "localStats"]);

After:

  // Keys injected by the OpenClaw host config; forwarding them to the Cloud API is not intended.
  const reservedInfoKeys = new Set(["local_state", "state", "localStats"]);

3. apps/MemOS-Cloud-OpenClaw-Plugin/index.js (L206)

Because customInfo is spread last, keys the plugin sets itself (source, sessionKey, agentId) can still be silently overwritten by user config — e.g. info: { source: "other" } replaces the platform tag openclaw_win/openclaw_mac. That is the same class of collision this change is guarding against. If those three fields are meant to be authoritative, extend the reserved list to cover them (or spread customInfo before them); if user override is intentional, a short comment noting that would help future readers.

Generated by cloud-assistant via Open Code Review.

@Memtensor-AI

Copy link
Copy Markdown
Collaborator

✅ Automated Test Results: PASSED

All tests passed (6/6 executed). common/smoke: 6/6. Duration: 2s [advisory, non-gating] AI-generated tests on branch test/auto-gen-85e56e4106eb57a4-20261012204343: 41/44 passed, 3 failed — these do NOT affect the PR verdict; review the branch manually.

Branch: fix/cloud-info-reserved-keys

@Memtensor-AI Memtensor-AI added status:ready Ready for implementation; waiting for assignee or AI dispatch | 可进入实现,等待认领或派发 and removed status:in-progress Someone or AI is working on it | 人工或 AI 正在处理 labels Oct 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:plugin OpenClaw & Hermes status:ready Ready for implementation; waiting for assignee or AI dispatch | 可进入实现,等待认领或派发

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MemOS Cloud API — 4 个未文档化 schema 坑(实测 2026-09-26)

3 participants