Skip to content

fix: multi-agent project-level memory isolation#1497

Open
0xsuimi wants to merge 2 commits intoMemTensor:dev-v2.0.14from
0xsuimi:fix/multi-agent-isolation
Open

fix: multi-agent project-level memory isolation#1497
0xsuimi wants to merge 2 commits intoMemTensor:dev-v2.0.14from
0xsuimi:fix/multi-agent-isolation

Conversation

@0xsuimi
Copy link
Copy Markdown

@0xsuimi 0xsuimi commented Apr 19, 2026

Summary

Replace global currentAgentId with sessionContextMap keyed by sessionKey, enforcing strict project-level memory isolation between agents.

Changes

  • Add sessionContextMap keyed by sessionKey for concurrent agent isolation
  • Add extractProjectId() to derive projectId from sessionKey segments (agent:xxx:platform:type:channelId)
  • Add getSessionContext() / setSessionContext() for per-session context tracking
  • Update all tool handlers to use getSessionContext().ownerFilter
  • Remove legacy 'agent:xxx' fallback from ownerFilter (strict project isolation)
  • Owner format: agent:{agentId}:project:{projectId}

OwnerFilter (before)

[agent:{id}:project:{proj}, project:{proj}:shared, agent:{id}, public]
^^^^^ leaky

OwnerFilter (after)

[agent:{id}:project:{proj}, project:{proj}:shared, public]

Closes #XXXX

claw added 2 commits April 19, 2026 17:52
- Replace global currentAgentId with sessionContextMap keyed by sessionKey
- Add extractProjectId() to derive projectId from sessionKey segments
- Add getSessionContext() / setSessionContext() for per-session agentId+projectId tracking
- Update all tool handlers (memory_search, memory_timeline, memory_get, memory_viewer, skill_search) to use getSessionContext().ownerFilter
- Update before_prompt_build and agent_end hooks to set currentSessionKey
- Remove legacy 'agent:xxx' fallback from ownerFilter (strict project isolation)
- Owner format: agent:{agentId}:project:{projectId}

Fixes cross-project memory leakage in multi-agent OpenClaw setups.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants