Skip to content

feat(memory): add scope_mode config and strictAgentIsolation for full agent memory isolation#1123

Open
gaomind wants to merge 1 commit intovolcengine:mainfrom
gaomind:feat/memory-scope-mode-isolation-clean
Open

feat(memory): add scope_mode config and strictAgentIsolation for full agent memory isolation#1123
gaomind wants to merge 1 commit intovolcengine:mainfrom
gaomind:feat/memory-scope-mode-isolation-clean

Conversation

@gaomind
Copy link
Copy Markdown

@gaomind gaomind commented Mar 31, 2026

Summary

Adds memory.scope_mode on the server side and strictAgentIsolation on the OpenClaw plugin side, enabling full inter-agent memory isolation in multi-agent deployments.

Currently, user-level memory categories (PROFILE, PREFERENCES, ENTITIES, EVENTS) are routed to shared user scope, meaning different agents on the same account can see each other's profile. This PR adds an opt-in "isolated" mode that routes all categories to agent scope.

Related: #1069, #954

What Changed

Server side

  • memory_config.py: Added scope_mode field (Literal["default", "isolated"], default "default") with field_validator
  • memory_extractor.py: _get_owner_space(), create_memory(), _append_to_profile() now accept and respect scope_mode
  • compressor.py: Reads scope_mode from config and passes it through the extraction pipeline

Plugin side (examples/openclaw-plugin)

  • config.ts: Added strictAgentIsolation boolean config option
  • index.ts: When enabled, memory_recall and auto-recall only search viking://agent/memories
  • openclaw.plugin.json: Schema and UI hints for the new option

Documentation

  • Updated English and Chinese configuration guides
  • Clarified relationship between scope_mode and agent_scope_mode

Tests

  • tests/session/test_memory_scope_mode.py: 10 tests (owner_space routing + config validation)
  • examples/openclaw-plugin/__tests__/strict-agent-isolation.test.ts: 6 tests (config parsing)

Behavior

Default behavior is unchanged. When scope_mode is set to "isolated", all categories route to viking://agent/{agent_space}/memories/.

scope_mode vs agent_scope_mode

Config Controls Default
agent_scope_mode How agent space hash is computed "user+agent"
scope_mode Which categories route to agent vs user scope "default"

These are independent. Typical combinations:

scope_mode agent_scope_mode Result
default user+agent Original behavior
isolated user+agent Full isolation per user per agent
isolated agent Full isolation, shared across users of same agent

Example

Server (ov.conf):

{
  "memory": {
    "scope_mode": "isolated"
  }
}

Plugin (openclaw.json):

{
  "plugins": {
    "entries": {
      "openviking": {
        "config": {
          "strictAgentIsolation": true
        }
      }
    }
  }
}

Testing

python -m pytest tests/session/test_memory_scope_mode.py -v
cd examples/openclaw-plugin && npx vitest run __tests__/strict-agent-isolation.test.ts

Checklist

  • Code follows the project's coding style
  • Self-reviewed
  • Documentation updated
  • Tests added and passing
  • No new warnings
  • Backward compatible (default behavior unchanged)

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 31, 2026

CLA assistant check
All committers have signed the CLA.

@github-actions
Copy link
Copy Markdown

Failed to generate code suggestions for PR

… agent memory isolation

Server side:
- Add memory.scope_mode ("default" | "isolated") to MemoryConfig with Literal type and field_validator
- Update _get_owner_space(), create_memory(), and _append_to_profile() to respect scope_mode
- When "isolated", all memory categories (including PROFILE/PREFERENCES) route to agent scope
- Read scope_mode from config in compressor and pass through extraction pipeline

Plugin side (examples/openclaw-plugin):
- Add strictAgentIsolation boolean config option
- When enabled, memory_recall tool and auto-recall only search viking://agent/memories
- Add configSchema and uiHints entries

Tests:
- tests/session/test_memory_scope_mode.py: 10 tests for owner_space routing and config validation
- examples/openclaw-plugin/__tests__/strict-agent-isolation.test.ts: 6 tests for config parsing

Docs:
- Updated English and Chinese configuration guides with scope_mode field
- Clarified relationship between scope_mode and agent_scope_mode
@gaomind gaomind force-pushed the feat/memory-scope-mode-isolation-clean branch from 74a8427 to 1168ca5 Compare March 31, 2026 09:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog

Development

Successfully merging this pull request may close these issues.

2 participants