Skip to main content
Give your Strands agents persistent memory powered by cognee. Built on cognee v1.0, the integration exposes two tools — remember and recall — that write to a permanent knowledge graph or a lightweight session cache, and survive across agent instances.

Why Use This Integration

  • Two memory tiers: Write straight to the permanent knowledge graph, or to a cheap per-session cache that you promote later
  • Natural language recall: Retrieve stored knowledge with graph traversal and vector similarity
  • Cross-session memory: Context persists across agent instances and restarts
  • Drop-in tools: cognee_tools() returns ready-to-use Strands tools

Installation

pip install cognee-integration-strands
Requires Python 3.10+. Pins cognee>=1.0.0,<=1.1.2 and strands-agents>=1.42.0,<2.0.0.

Quick Start

Set your LLM key (cognee extracts knowledge with an LLM), then attach the tools:
export LLM_API_KEY="your-openai-api-key-here"   # used by cognee
import os
import cognee
from cognee_integration_strands import cognee_tools, run_cognee_task
from strands import Agent
from strands.models.openai import OpenAIModel

run_cognee_task(cognee.forget(everything=True))  # optional: start fresh

model = OpenAIModel(client_args={"api_key": os.getenv("LLM_API_KEY")}, model_id="gpt-4o")
agent = Agent(model=model, tools=cognee_tools())

# Store information
agent("Remember that we signed a contract with Meditech Solutions for £1.2M.")

# Retrieve it (even from a fresh agent — memory is persistent)
print(agent("What is the value of the Meditech Solutions contract?"))

Tools

cognee_tools(session_id=None, *, remember_kwargs=None, recall_kwargs=None) returns a list of two tools:
ToolDescription
rememberStore information in memory for later retrieval (wraps cognee.remember)
recallSearch and retrieve stored information with natural language (wraps cognee.recall)

Session Memory

By default, remember writes straight to the permanent knowledge graph. Pass a session_id to write to that session’s lightweight cache instead, then promote the cache into the graph when you’re ready:
SESSION_ID = "mission-briefing"

session_agent = Agent(
    model=model,
    tools=cognee_tools(session_id=SESSION_ID, remember_kwargs={"self_improvement": False}),
)
# ... use session_agent throughout the session ...

# Promote the session cache into the permanent graph
run_cognee_task(cognee.improve(session_ids=[SESSION_ID]))
Passing remember_kwargs={"self_improvement": False} keeps session writes in cache-only mode until you call cognee.improve(...). Without a session_id, writes go directly to the permanent graph.

How It Works

  1. Remember: Stores data in cognee’s memory — the permanent graph, or a session cache when session_id is set
  2. Recall: Retrieves relevant information via cognee’s recall pipeline
  3. Auto-Processing: cognee extracts entities, relationships, and context automatically
  4. Background loop: cognee’s async API runs on a dedicated background event loop; run_cognee_task() handles this transparently

GitHub Repository

View source code and examples

Examples

Runnable example scripts