Skip to content

feat(integrations/OpenClaw): add OpenClaw PowerContext memory plugin - #1282

Open
XnLemon wants to merge 5 commits into
oceanbase:masterfrom
XnLemon:feat/openclaw-memory-integration
Open

feat(integrations/OpenClaw): add OpenClaw PowerContext memory plugin#1282
XnLemon wants to merge 5 commits into
oceanbase:masterfrom
XnLemon:feat/openclaw-memory-integration

Conversation

@XnLemon

@XnLemon XnLemon commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Which issue or RFC does this PR close?

Closes #1281.

Rationale for this change

OpenClaw needs a memory provider that can use PowerContext's durable, scoped memory backend without modifying OpenClaw core. OpenClaw remains responsible for agent identity, privacy decisions, transcripts, and lifecycle hooks, while PowerContext provides memory storage, search, recall, and processing.

What changes are included in this PR?

  • Add an external OpenClaw memory plugin backed by PowerContext HTTP APIs.
  • Register the exclusive memory provider slot.
  • Add memory_search, memory_store, memory_revise, and memory_retire.
  • Add lifecycle integration for prompt recall, source capture, compaction flush, and session-end flush.
  • Enforce agent/project scopes and private-session restrictions.
  • Validate citations and treat recalled memory as untrusted context.
  • Add English and Chinese installation and configuration documentation.
  • Add plugin tests, TypeScript configuration, package metadata, and build/pack targets.
  • Add Apache-2.0 license headers to plugin source files.

Evidence(Currently filling in the missing details)

713f558181b1523af40051a57daf86ce

Are there any user-facing changes?

Yes.

Users can install the plugin through OpenClaw's standard managed local-plugin flow:

openclaw plugins install . --force

After publication, it can be installed from npm:

openclaw plugins install npm:@oceanbase/openclaw-memory-powercontext

The plugin requires OpenClaw 2026.8.1-beta.2 or newer. No OpenClaw core source changes or public PowerContext API breaking changes are introduced.

How was this change tested?

  • pnpm typecheck
  • pnpm test with 6 tests passing
  • pnpm build
  • pnpm pack:local
  • uv run prek run -a
  • uv run zensical build -s
  • PowerContext API contract and client tests with 37 tests passing
  • OpenClaw runtime inspection confirming that the plugin was loaded, selected as the memory provider, and registered four lifecycle hooks and four memory tools with no diagnostics

AI usage statement

AI tools were used during development and validation. Codex based on GPT-5 was used to inspect the repositories, implement the integration and documentation, run tests, and validate the OpenClaw plugin installation and runtime behavior.

中文翻译

此 PR 关闭哪个 Issue 或 RFC?

关闭 #1281

变更原因

OpenClaw 需要一个能够使用 PowerContext 持久化、隔离 Memory 的提供方,同时不修改 OpenClaw 核心代码。OpenClaw 继续负责 Agent 身份、隐私判断、transcript 和生命周期钩子,PowerContext 负责 Memory 的存储、搜索、召回和处理。

此 PR 包含哪些变更?

  • 新增基于 PowerContext HTTP API 的外部 OpenClaw Memory 插件。
  • 注册独占的 memory provider slot。
  • 新增 memory_searchmemory_storememory_revisememory_retire 工具。
  • 接入提示词召回、Source 采集、压缩前 flush 和会话结束 flush。
  • 支持 agent/project scope 和私有会话限制。
  • 校验 Memory citation,并将召回内容视为不可信上下文。
  • 新增中英文安装与配置文档。
  • 新增插件测试、TypeScript 配置、包元数据以及构建和打包目标。
  • 为插件源码补充 Apache-2.0 许可证头。

是否有面向用户的变更?

有。

用户可以使用 OpenClaw 标准的托管本地插件流程安装:

openclaw plugins install . --force

发布到 npm 后,可以使用:

openclaw plugins install npm:@oceanbase/openclaw-memory-powercontext

插件要求 OpenClaw 2026.8.1-beta.2 或更高版本。不修改 OpenClaw 核心代码,也不改变 PowerContext 的公共 API。

如何测试?

  • pnpm typecheck
  • pnpm test,6 个测试通过
  • pnpm build
  • pnpm pack:local
  • uv run prek run -a
  • uv run zensical build -s
  • PowerContext API contract 和 client 测试,37 个测试通过
  • OpenClaw runtime inspection,确认插件已加载、已选为 Memory provider,并注册了 4 个生命周期钩子和 4 个 Memory 工具,且没有诊断错误

AI 使用声明

本 PR 的开发和验证过程中使用了 AI 工具。Codex(GPT-5)用于检查代码库、实现集成和文档、运行测试,以及验证 OpenClaw 插件的安装和运行时行为。

runtime: createPowerContextMemoryRuntime(dependencies),
});

api.registerTool((ctx) =>

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OpenClaw already creates its own memory_search before loading plugin tools, so this registration is dropped as a name conflict on 2026.8.1-beta.2. In a managed-install E2E, memory_store and automatic recall reached PowerContext, but an explicit memory_search used the built-in file index instead. This also leaves memory_revise and memory_retire without a reliable way to obtain their required citation. Please either use a non-conflicting tool name and update the prompt, manifest, and docs, or require a host version whose built-in tool delegates to this memory runtime, with an exact-host regression test.

};
const rememberScope = (sessionId: string | undefined, scopeId: string) => {
if (sessionId) {
sessionScopes.set(sessionId, scopeId);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sessionScopes keeps only one scope per session. In project mode, if a session sees project A and then project B, B overwrites A, so session_end flushes only B. I reproduced this against the built plugin: two captured project scopes produced a single flush for the second scope. Please retain a bounded set of observed scopes and flush each one, or flush on project transitions, and add a regression test for a session that changes projects.

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.

feat(integrations/OpenClaw): research on OpenClaw memory and how to integrate PowerContext as a multi-session Memory Provider

2 participants