Guide
Multi-session memory
Keep conversations isolated and transfer only the context a destination session actually needs.
Overview
Each MemoGrafterAgent owns an independent generated session. Separate sessions prevent accidental context mixing; explicit grafting and absorption provide controlled transfer with provenance.
When to use this
Keep separate conversations or agents isolated.
Move a selected project or preference context into a new workflow.
Audit which source session contributed copied memory.
Avoid inheriting a complete transcript when only a few topics matter.
Step 1: Create independent agents
sessions.ts
const source = new MemoGrafterAgent(config);
const target = new MemoGrafterAgent(config);
await source.initialize();
await target.initialize();
console.log(source.getSessionId() !== target.getSessionId()); // trueStep 2: Select before transferring
select.ts
const preview = await source.graftByRelevance("customer preferences", {
topK: 5,
minSimilarity: 0.55,
expansionStrategy: "none",
});
console.log(preview.nodes);Step 3: Transfer with provenance
transfer.ts
await target.absorbFromAgent(source, {
topicIds: preview.nodes.map((node) => node.id),
});
console.log(await target.getGraftRegistry());Full example
multi-session.ts
const support = new MemoGrafterAgent(config);
const followUp = new MemoGrafterAgent(config);
await support.initialize();
await followUp.initialize();
try {
await support.invoke("I prefer email updates about case 42.");
await followUp.absorbFromAgent(support, {
prompt: "communication preference for case 42",
limit: 3,
});
console.log(await followUp.invoke("How should I send the update?"));
} finally {
await Promise.all([support.close(), followUp.close()]);
}Choose between scope mechanisms
Use separate sessions for independent conversations.
Use tags when related memory should remain searchable without being copied.
Use absorption when selected memory must become part of the destination graph.
Use fleet shared memory for knowledge that every authorized worker should be able to query.
Best practices
Keep the application’s user-to-session mapping outside MemoGrafter.
Authorize both source and destination before transferring memory.
Preview semantic selection before copying.
Retain registry provenance in audit and user-facing inspection tools.
Do not use session IDs or tags alone as authorization controls.
Common mistakes
Sharing one agent instance across unrelated users.
Copying an entire source graph by default.
Losing the application-level mapping between users and sessions.
Treating a generated agent session as a durable login identity.
Using tags to bypass authorization checks.