- Complete Quickstart or have Cognee installed and configured
- Ensure you have LLM Providers configured
- Be familiar with the
remember()workflow - Keep caching enabled — it is on by default, and the session options used below require it:
Shared Setup
Both agents use the sameLLMGateway helper. The updated example starts clean with forget(everything=True), stores one baseline fact with remember(), and then compares session memory against graph memory.
LLMGateway.acreate_structured_output() automatically picks up whatever memory the decorator retrieved and prepends it to the text input. In this flow, save_session_traces=True records each of the support agent’s turns into the session cache, and persist_session_trace_after=3 is what bridges those traces into the knowledge graph.
Compare the Agents
- Support Agent
- FAQ Bot
From Session Traces to the Permanent Graph
The two agents above read from different places, so it helps to know which store each parameter touches:save_session_traces=True alone keeps traces in the session cache, where only with_session_memory can see them. Adding persist_session_trace_after=N is what bridges them into the permanent graph: after every Nth trace step in the session, Cognee runs a memify pass that writes the trace summaries into dataset_name under the agent_trace_feedbacks node set. That is why faq_bot — which reads only the graph — answers correctly only after support_agent has taken three turns.
Trace persistence is best-effort: failures are logged and never propagate out of your agent function. See the decorator parameters for the options that control what gets persisted and where.
Full Example
Guide
Guide
The decorator does not create memory by itself. The example works because baseline graph memory is stored first with
remember(), and the session-aware support agent persists traces only after those conversation turns happen.Agent Memory Decorator
Concept overview and parameter reference
Low-Level LLM
LLMGateway for direct model callsRemember
Store memory before using the decorator
Sessions
Learn how trace-backed session context behaves