Skip to content

feat: add allowedAgents config for per-agent memory isolation#30

Open
kagura-agent wants to merge 1 commit intosupermemoryai:mainfrom
kagura-agent:fix/per-agent-memory-isolation
Open

feat: add allowedAgents config for per-agent memory isolation#30
kagura-agent wants to merge 1 commit intosupermemoryai:mainfrom
kagura-agent:fix/per-agent-memory-isolation

Conversation

@kagura-agent
Copy link

Summary

Adds an optional allowedAgents config 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 allowedAgents is set, both before_agent_start (recall) and agent_end (capture) hooks check ctx.agentId against the list. Non-matching agents are silently skipped with a debug log.

When allowedAgents is omitted or empty, all agents are allowed (preserving current behavior — no breaking changes).

Changes

  • config.ts: Added allowedAgents field to config type, parsing, JSON schema, and isAgentAllowed() helper
  • hooks/recall.ts: Guard clause using isAgentAllowed()
  • hooks/capture.ts: Guard clause using isAgentAllowed()

3 files changed, +34 lines.

Notes

  • Uses ctx.agentId (not ctx.sessionKey as suggested in Feature request: per-agent memory isolation via allowedAgents config #27) since agentId is the stable identifier for which agent is running
  • Follows the existing SKIPPED_PROVIDERS pattern in capture.ts for guard precedent
  • isAgentAllowed() is exported from config.ts for potential reuse in tools/commands if needed later

…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>
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.

Feature request: per-agent memory isolation via allowedAgents config

1 participant