session_id across recall() calls, Cognee remembers previous questions and answers, enabling contextually aware follow-up questions.
Before You Start
- Complete Quickstart to understand basic operations
- Ensure you have LLM Providers configured
- Read Sessions and Caching for conceptual overview
- Configure your cache adapter before using sessions. See Cache Adapters for Redis and Filesystem setup instructions.
Code in Action
This example works with either Redis or Filesystem adapter. Configure your chosen adapter in the Before you start section above.
What Just Happened
Step 1: Prepare Knowledge Base
cognee.remember() ingests the texts and builds the knowledge graph in one call.
Step 2: Start a Session
session_id parameter on cognee.recall() creates or continues a conversation thread. All recalls with the same session_id share conversation history.
Step 3: Ask Follow-up Questions
session_id, Cognee automatically includes previous Q&A turns in the LLM prompt, so the LLM resolves “she” to Alice from the earlier question.
Step 4: Isolate Conversations
session_id maintains its own conversation history. This recall runs in a fresh session, so no previous turns are sent to the LLM and “she” is ambiguous.
Advanced Usage
Custom Session IDs
Custom Session IDs
Use meaningful session IDs to organize conversations:Session IDs are arbitrary strings—use whatever naming scheme fits your application.
session_id (the default-session behavior), reading session history with get_session(), the include_context flag and SessionManager, disabling sessions entirely, which search types are session-aware, session persistence/clearing, and token usage tracking.
Legacy Guide
Sessions with add(), cognify(), and search()
Sessions with add(), cognify(), and search()
If you are still on the pre-1.0
add() / cognify() / search() surface, the same session behavior is available through cognee.search(). The session_id parameter works exactly as described above. New projects should use remember() and recall() instead — see Search (legacy) for how the legacy surface relates to recall().Sessions and Caching
Understand how sessions work conceptually
Search Basics
Learn about search parameters and types
Setup Configuration
Configure cache adapters and providers