feat: add allowedAgents config for per-agent memory isolation#30
Open
kagura-agent wants to merge 1 commit intosupermemoryai:mainfrom
Open
feat: add allowedAgents config for per-agent memory isolation#30kagura-agent wants to merge 1 commit intosupermemoryai:mainfrom
kagura-agent wants to merge 1 commit intosupermemoryai:mainfrom
Conversation
…upermemoryai#27) This commit adds an optional 'allowedAgents' config to restrict memory operations to specific agents. When configured, only agents whose agentId is in the allowedAgents list will have memory operations (recall/capture) performed. When allowedAgents is omitted or empty, all agents are allowed (preserves current behavior). Changes: - config.ts: Add allowedAgents field to SupermemoryConfig type, schema, and parsing logic. Add isAgentAllowed() helper function. - hooks/recall.ts: Check isAgentAllowed() in buildRecallHandler before processing recall requests. - hooks/capture.ts: Check isAgentAllowed() in buildCaptureHandler before capturing memories. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an optional
allowedAgentsconfig option to restrict memory operations (recall and capture) to specific agents. Fixes #27.Problem
In multi-agent OpenClaw setups, the supermemory plugin fires for every agent that shares the instance. Memories meant for one agent bleed into unrelated agent sessions.
Solution
New config option:
{ "plugins": { "entries": { "openclaw-supermemory": { "config": { "allowedAgents": ["navi", "research-bot"] } } } } }When
allowedAgentsis set, bothbefore_agent_start(recall) andagent_end(capture) hooks checkctx.agentIdagainst the list. Non-matching agents are silently skipped with a debug log.When
allowedAgentsis omitted or empty, all agents are allowed (preserving current behavior — no breaking changes).Changes
allowedAgentsfield to config type, parsing, JSON schema, andisAgentAllowed()helperisAgentAllowed()isAgentAllowed()3 files changed, +34 lines.
Notes
ctx.agentId(notctx.sessionKeyas suggested in Feature request: per-agent memory isolation via allowedAgents config #27) since agentId is the stable identifier for which agent is runningSKIPPED_PROVIDERSpattern in capture.ts for guard precedentisAgentAllowed()is exported from config.ts for potential reuse in tools/commands if needed later