Skip to content

feat(memory): support agent-only agent memory scope#954

Merged
qin-ctx merged 2 commits intovolcengine:mainfrom
liberion1994:feat/agent-memory-scope-mode
Mar 27, 2026
Merged

feat(memory): support agent-only agent memory scope#954
qin-ctx merged 2 commits intovolcengine:mainfrom
liberion1994:feat/agent-memory-scope-mode

Conversation

@liberion1994
Copy link
Copy Markdown
Contributor

Summary

This PR adds a new OpenViking memory configuration field: memory.agent_scope_mode.

It allows agent-level memory namespaces to be isolated in two ways:

  • user+agent (default): isolate by (user_id, agent_id)
  • agent: isolate only by agent_id, so users of the same agent share the same agent memory space

This change is implemented inside OpenViking, not only at the bot layer.

What Changed

  • Added memory.agent_scope_mode to OpenViking memory config
  • Updated UserIdentifier.agent_space_name() to derive agent space from config
  • Kept existing behavior as default with user+agent
  • Added tests for both isolation modes
  • Updated docs affected by this change:
    • configuration guide
    • Viking URI concept
    • multi-tenant design doc

Behavior

Default behavior remains unchanged:

  • memory.agent_scope_mode = "user+agent"
  • agent space is derived from md5(f"{user_id}:{agent_id}")[:12]

New optional behavior:

  • memory.agent_scope_mode = "agent"
  • agent space is derived from md5(agent_id)[:12]

This affects agent-level namespaces such as:

  • viking://agent/{agent_space}/memories/...
  • viking://agent/{agent_space}/skills/...
  • viking://agent/{agent_space}/instructions/...

It does not affect user memory namespaces under:

  • viking://user/{user_space}/memories/...

Example

{
  "memory": {
    "agent_scope_mode": "agent"
  }
}

Testing

Validated with:

uv run --no-project --with pytest --with json-repair --with pydantic python -m pytest --noconftest -o addopts='' -q tests/cli/test_user_identifier.py

Also verified changed Python files with py_compile.

Notes

This PR only updates documentation directly impacted by this change.
It does not attempt to clean up unrelated pre-existing documentation gaps.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 25, 2026

CLA assistant check
All committers have signed the CLA.

@MaojiaSheng MaojiaSheng requested a review from qin-ctx March 27, 2026 08:07
@MaojiaSheng
Copy link
Copy Markdown
Collaborator

some conflicts need to be resolved, and please double check the retrieval filters

@qin-ctx qin-ctx merged commit f81419c into volcengine:main Mar 27, 2026
2 checks passed
@github-project-automation github-project-automation bot moved this from Backlog to Done in OpenViking project Mar 27, 2026
zeattacker pushed a commit to zeattacker/OpenViking that referenced this pull request Mar 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants