Skip to main content
A minimal guide to enabling conversational memory with sessions. When you use the same session_id across recall() calls, Cognee remembers previous questions and answers, enabling contextually aware follow-up questions.

Before You Start

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

Before you can use sessions, you need data in your knowledge base. cognee.remember() ingests the texts and builds the knowledge graph in one call.

Step 2: Start a Session

The 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

When you use the same 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

Each 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

Use meaningful session IDs to organize conversations:
Session IDs are arbitrary strings—use whatever naming scheme fits your application.
See Sessions and Caching for what happens when you omit 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

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