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
- Complete Quickstart to understand basic operations
- Ensure you have LLM Providers configured (
LLM_API_KEY) - Read Persistent Memory Across Sessions for how
session_idworks - Read NodeSet Grouping for how node sets tag memory and scope recall
Code in Action
What Just Happened
Step 1: Pin a Session With a Typed Entry
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
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
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
What a valid node set looks like
What a valid node set looks like
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.Running several worker processes
Running several worker processes
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()