What You’ll Build
Two shoppers’ order histories, the store’s returns policy, and its footwear fit notes go into cognee memory, each customer in their own node set and the store’s documents in a shared one. Then two support scenes play out for one shopper, Maya. Live attributes in the shape Snowplow Signals returns go into the query text. Every chat message is answered twice with the samerecall(): once over the store’s documents only (“Signals only”) and once with Maya’s memory added (“Signals + cognee”). After the first scene, the chat outcome and a narrative of her on-site behavior are remembered too. Two weeks later, that memory changes the size the agent recommends.
The complete runnable script is
examples/demos/agentic/live_context_support_agent.py —
this page walks through its key moments rather than reproducing it.
Features in Play
- NodeSets: keep each customer’s memory in its own node set next to a shared
storenode set, and choose per recall whose memory is in scope - Remember: stores the order histories and store documents up front, then the chat outcome and behavior narrative after scene 1
- Recall: answers each chat message with
node_namescoping, a customsystem_promptfor the agent, and a freshsession_idper answer - Forget: deletes only the demo’s own dataset before each run, so reruns start clean
How It Looks
In scene 1 (Oct 26), Maya bought Talusworks Ridgeline trail shoes in the Autumn Sale in her usual EU 39, and they are too small. The script prints four Signals snapshots as she browses. Whenreturns_page_views_10m reaches 3, the trigger fires and the agent opens the chat before she has typed anything. She asks to return the shoes. Sale items are final sale, but size exchanges are free, and the fit notes say the Ridgeline runs a size small. With her memory in scope, the expected answer is a free exchange for EU 40.
In scene 2 (Nov 9), she is looking at Northpeak Summit Hiker shoes and asks which size to take. Signals only knows which product she is viewing. Cognee remembers that she wears 39 and needed a 40 only because the Ridgeline runs small, and the fit notes say the Summit Hiker runs true to size. The expected “Signals + cognee” answer is to keep her usual EU 39. The answers are live LLM calls, so their wording changes from run to run.
Before You Start
- Complete Quickstart to understand basic operations
- Configure LLM Providers. With the bundled samples,
LLM_API_KEYis the only setting the script needs - Use a graph store that supports node-set filtering, such as Ladybug (the default), Neo4j, Postgres, or Turso. Customers are kept apart with node sets
- Run it from a checkout of the cognee repo. It reads its inputs from the sibling
live_context_support_agent_data/folder: order histories for two customers, the returns policy, fit notes, the scene 1 chat outcome, a sample behavior narrative, andsignals_snapshots.json. It also loads your.envwithload_dotenv()and setsLOG_LEVEL=ERRORunless you set it yourself - The script deletes and rebuilds only its own dataset,
live_context_support_agent_demo, withcognee.forget(dataset=...). It leaves your other datasets alone. See Forget - Optional: to read real behavior instead of the samples, see Connect Real Snowplow Signals below
How It Works
Stage 1: Separate Customers by Node Set
store. A recall can then include the store’s documents for everyone and add one customer’s history only when answering that customer. Node sets are a retrieval filter, not an isolation boundary: both customers bought the Ridgeline, so that shared entity, and relationships Leo’s orders created between in-scope entities, can still reach Maya’s answers. For customer data that must never mix, use separate datasets, as NodeSets explains.
Stage 2: Open the Chat When the Trigger Fires
get_live_context() returns each one, from the bundled samples or from real Signals (see Connect Real Snowplow Signals). wants_help_with_return() is the trigger rule: it fires once returns_page_views_10m reaches 3. In production, this rule would be a Signals intervention on the site. When it fires, the agent opens the chat before Maya has written anything. The query holds only her live attributes and an instruction to open the chat, and node_name includes both the store’s node set and hers. Live behavior decides when the agent speaks, and memory decides what it says.
Stage 3: Answer the Same Message With and Without Memory
describe() turns the attributes into a Live behavior from Snowplow Signals: block of JSON, and the query adds today’s date and the customer’s message. Cognee doesn’t store any of it. The two answers use the same query, prompt, and dataset. The only difference is node_name. Each answer gets a fresh session_id, so earlier answers cached in the default session can’t leak into the comparison.
Stage 4: Remember What Happened
get_agentic_context(..., format="narrative"). This is the memory that changes the scene 2 answer. Live attributes from two weeks ago are gone by then, but what they led to is now in her history.
Stage 5: Ask Again Two Weeks Later
Run It
Resetting the demo dataset and building memory..., then a === Scene 1 ... === header, one [signals] snapshot N: line per snapshot, the [signals] trigger fired line, and the agent’s unprompted opener. Each customer message is followed by two labeled answers, --- Signals only ... --- and --- Signals + cognee ... ---. After Remembering the chat outcome and Maya's on-site behavior..., scene 2 prints its snapshot and the two answers to the sizing question. A successful run recommends an exchange to EU 40 in scene 1 and staying with EU 39 in scene 2 in the “Signals + cognee” answers.
Connect Real Snowplow Signals
By default the scenes read the bundled samples.get_live_context() switches to the snowplow-signals SDK when SNOWPLOW_SIGNALS_API_URL is set in your .env (the script loads it with load_dotenv()) or in the environment:
last_product_viewed, last_order_status_viewed, size_guide_views_10m, and returns_page_views_10m. The real path also needs these variables, set the same way:
The SDK isn’t a cognee dependency, so add it for the run:
The real Signals path needs your own Signals deployment and credentials. The bundled samples don’t exercise it. The scene messages and dates stay hardcoded, so adapt them to your visitor’s data.
NodeSets
How node-set labels are written and how
node_name filters retrieval by them.Recall
The retrieval call behind every agent answer, including
system_prompt and session_id.Agentic Procurement Decisions
Another agent that scopes each recall to one node-set category.