Skip to content

Multi-Agent Collaboration

memtomem supports knowledge sharing between agents through namespace-based isolation and sharing. As a runtime-agnostic memory layer, it enables Human→Agent, Agent→Agent, and Agent→Human knowledge flows.

agent-runtime:{agent-id} # Agent-private — only that agent can access
shared # Shared — accessible by all agents

Each agent works in its own private namespace but can export useful knowledge to the shared namespace.

mem_agent_register(agent_id="analyzer", description="Code analysis agent")
mem_session_start(agent_id="analyzer")

The session record’s namespace auto-derives to agent-runtime:analyzer. Subsequent calls in this session inherit the agent scope without re-passing agent_id:

  • Writesmem_add(content="...") and mem_batch_add(...) write to agent-runtime:analyzer automatically. Pass namespace="shared" explicitly to publish cross-agent on a single call.
  • Readsmem_agent_search / mem_agent_share resolve to the agent scope without agent_id=. (mem_search itself stays single-agent — use mem_agent_search to read inside the agent scope.)
mem_agent_search(query="auth module structure", include_shared=true)

With include_shared=true, searches both the agent’s own namespace and the shared namespace.

mem_agent_share(chunk_id="...", target="shared")
mem_session_end(summary="...")

agent_id is not auto-detected. The principle is the same across runtimes — pass it explicitly when a session starts, and it is inherited by subsequent calls through session context.

The MCP server does not identify which client is calling, so fix the session-start rule in the agent’s instructions (CLAUDE.md · AGENTS.md · system prompt).

Example instruction:

At the start of a conversation, call mem_session_start(agent_id="claude-code") first to register the session. When acting as a new agent role, use mem_agent_register(agent_id="planner", description="...").

Once registered, later calls to mem_search, mem_add, and so on are routed to the agent-runtime:{agent-id} namespace without having to pass agent_id again.

from memtomem.integrations.langgraph import MemtomemStore
store = MemtomemStore()
await store.start_agent_session(agent_id="analyzer")
# Subsequent store.search / store.put calls are isolated to the analyzer namespace

In multi-agent graphs, each node starts its own session with its own agent_id. Use mem_agent_share to publish outputs that need to cross agents to the shared namespace.

Use this to pre-register a session outside the server process.

Terminal window
mm session start --agent-id planner

See mm session for the full subcommand surface (start, end, list, events, wrap).

mm ingest claude-memory, mm ingest gemini-memory, and mm ingest codex-memory do not assign an agent_id. They load memories into fixed namespaces — claude-memory:<slug>, gemini-memory:<slug>, and codex-memory:<slug> — to consolidate per-editor memories into one searchable index. For per-agent isolation, use the MCP/adapter/CLI paths above to set agent_id explicitly.

When a developer works in Claude Code or Cursor, architecture decisions, coding patterns, and debugging history from previous sessions are automatically surfaced.

In LangGraph/CrewAI workflows, when an agent chain runs, the “code analysis agent” discovers codebase structure and the “test generation agent” references it. Intermediate outputs and decision history are automatically passed through the shared LTM store.

Knowledge accumulated by agents can be searched and browsed through the Web UI dashboard. When onboarding new team members, they can review architecture decisions, bug resolution patterns, and coding conventions at a glance.

Consolidate each AI editor’s memory directory into a single searchable knowledge base. Re-runs are incremental — content-hash matching skips unchanged files.

Terminal window
mm ingest claude-memory --source ~/.claude/projects/
mm ingest gemini-memory --source ~/.gemini/GEMINI.md
mm ingest codex-memory --source ~/.codex/memories/

For Claude, pointing at ~/.claude/projects/ discovers per-project slug directories and indexes each under claude-memory:<slug>. Codex is loaded from a single directory into codex-memory:<slug>.

Use the MemtomemStore class for direct memory access from LangGraph/CrewAI:

from memtomem.integrations.langgraph import MemtomemStore
store = MemtomemStore()
# Search/store/manage sessions in LangGraph workflows