Skip to main content
A minimal guide to session node sets: tag a session’s first write with a node_set, and the session is pinned to it. Use this when several projects share one dataset and you want each project’s session memory to be recalled only within that project.

Before You Start

Code in Action

What Just Happened

Step 1: Pin a Session With a Typed Entry

The first write to session-project-a carries node_set=["project-a"], which pins that set on the session. The later TraceEntry in the same session repeats the set, which is allowed; omitting it would be allowed too.

Step 2: Pin a Session With the Call-Level Kwarg

Plain text pins a session too: the node_set kwarg on remember() means the same thing as the node_set field on a QAEntry or TraceEntry. Awaiting the returned result lets the background session bridge finish before improve() runs.

Step 3: See a Conflicting Set Refused

Writing a different set to an already-pinned session raises cognee.SessionNodeSetConflictError (HTTP 409 over the API; check for the error name in the response, since the remember endpoints return 409 for other failures too). A session never spans two projects, so start a new session for a different one.

Step 4: Bridge the Sessions and Recall Per Project

improve() copies each session into the graph and keeps its pinned set on everything it bridges: Q&A, agent traces, and distilled lessons. A recall scoped with node_name then sees only that project’s memory, so the same question gets Ingrid for project A and Teodor for project B.

Rules and Limits

The list must hold non-empty names; a bare string is refused, so pass ["project-a"] for one name. It is stored sorted and deduplicated. An empty list pins nothing.
The pin is checked under an in-process lock, so the one-set-per-session guarantee holds within one worker process. With several workers, route a session’s writes to one worker: two workers taking the same session’s first write at the same moment can each pin a set, and the last write wins.

NodeSet Grouping

Tag graph memory with node sets and scope recall by them

Session Distillation

Learn more about bridging sessions into the graph with improve()