Background
On channels such as Feishu (Lark), multiple real users may DM the same agent. We want long-term memory isolated per user, so user A’s and user B’s memories are not merged into one shared corpus.
Current behavior / problem
The plugin already supports multiple scopes (including user:<id>) and scopes.agentAccess, and tools can pass an explicit scope.
However, on autoCapture / autoRecall hook paths, the default read/write scope comes from getDefaultScope(agentId), typically agent:<agentId>. There is no automatic mapping from OpenClaw session context (channelId, conversationId, channel-specific user ids, etc.) to user:<stable-user-id>.
So when one agent id serves many users in DM, auto-captured memories all land in the same agent:* bucket, which risks cross-user bleed.
Desired behavior (feature)
When enabled via configuration:
- Resolve a per-user scope key (e.g.
user:<id>) from host context using documented, stable fields (e.g. ctx.conversationId, ctx.channelId, accountId, Feishu open_id / user_id, or whatever OpenClaw exposes per channel).
autoCapture writes and autoRecall / before_prompt_build retrieval should default to that scope (subject to scopes / ACL).
- Backward compatibility: when the feature is off, keep today’s semantics (primarily
agent:<id>). Policy for global and shared buckets can be discussed separately.
Possible implementation directions (for maintainers)
- Add configuration, e.g.
scopes.perUserDefaultFromContext: { enabled, field, prefix: "user:" } (exact field names must align with OpenClaw channel contracts).
- Or align with an OpenClaw-level “default scope per session” so behavior is not plugin-only.
Related notes
Related OpenClaw upstream discussions
These track similar multi-user / per-session / channel-aware needs at the host level; linking them here so plugin work can stay aligned with (or delegate to) OpenClaw:
Example environment
- OpenClaw + Feishu channel, multiple users DMing the same bot/agent.
Background
On channels such as Feishu (Lark), multiple real users may DM the same agent. We want long-term memory isolated per user, so user A’s and user B’s memories are not merged into one shared corpus.
Current behavior / problem
The plugin already supports multiple scopes (including
user:<id>) andscopes.agentAccess, and tools can pass an explicitscope.However, on
autoCapture/autoRecallhook paths, the default read/write scope comes fromgetDefaultScope(agentId), typicallyagent:<agentId>. There is no automatic mapping from OpenClaw session context (channelId,conversationId, channel-specific user ids, etc.) touser:<stable-user-id>.So when one agent id serves many users in DM, auto-captured memories all land in the same
agent:*bucket, which risks cross-user bleed.Desired behavior (feature)
When enabled via configuration:
user:<id>) from host context using documented, stable fields (e.g.ctx.conversationId,ctx.channelId,accountId, Feishuopen_id/user_id, or whatever OpenClaw exposes per channel).autoCapturewrites andautoRecall/before_prompt_buildretrieval should default to that scope (subject toscopes/ ACL).agent:<id>). Policy forglobaland shared buckets can be discussed separately.Possible implementation directions (for maintainers)
scopes.perUserDefaultFromContext: { enabled, field, prefix: "user:" }(exact field names must align with OpenClaw channel contracts).Related notes
user:pattern andMemoryScopeManageralready exist in this repo.Related OpenClaw upstream discussions
These track similar multi-user / per-session / channel-aware needs at the host level; linking them here so plugin work can stay aligned with (or delegate to) OpenClaw:
memory_search/memory_getscope leakage).USER.md-style files).Example environment