Cognee-Integration-Strands
A powerful integration between Cognee and Strands that provides intelligent knowledge management and retrieval capabilities for AI agents.
Note: This package requires Python 3.10+.
Overview
cognee-integration-strands combines Cognee's memory layer with the Strands Agents framework. Build agents that store, search, and recall information from a persistent knowledge graph — plus a fast session cache.
Features
- Smart Knowledge Storage: Persist information into Cognee's knowledge graph.
- Semantic Search: Retrieve relevant information with natural-language queries.
- Two memory tiers: a permanent knowledge graph plus a fast session cache you persist with
improve(). - Strands Integration: Drop-in tools for the Strands
Agent. - Background Async Support: Cognee's async API is driven on a background thread, so the synchronous Strands tools just work.
Upgrading from 0.1.x ⚠️
0.2.0 moves the integration to cognee v1.0 and replaces the old tool API. It's a breaking change with no compatibility shim — update your imports:
| 0.1.x | 0.2.0 |
|---|---|
from cognee_integration_strands import add_tool, search_tool |
from cognee_integration_strands import cognee_tools |
add_tool, search_tool = get_sessionized_cognee_tools("user-1") |
tools = cognee_tools(session_id="user-1") |
Agent(tools=[add_tool, search_tool]) |
Agent(tools=cognee_tools()) |
cognee>=0.4.0,<0.5.4 |
cognee>=1.0.0,<=1.1.2 |
strands-agents>=1.18.0 |
strands-agents>=1.42.0 |
In 0.1.x a session_id tagged data to isolate it per user. In 0.2.0 it routes writes to cognee's session cache; run cognee.improve(session_ids=[session_id]) to persist a session into the permanent graph (see Session Management).
Installation
pip install cognee-integration-strands
The examples drive an OpenAI model, which needs the Strands openai extra:
pip install "strands-agents[openai]"
Quick Start
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?"))
Available Tools
from cognee_integration_strands import cognee_tools
# cognee_tools() -> [remember, recall]
# remember: store information (cognee.remember)
# recall: retrieve information (cognee.recall)
Pass cognee_tools(session_id=...) to route writes through cognee's session cache.
Session Management
A session_id selects cognee's session cache tier instead of the permanent graph:
- No
session_id→rememberwrites straight to the permanent knowledge graph. - With
session_id→rememberwrites to that session's cache (cheap, no graph extraction); recall is session-aware. cognee.improve(session_ids=[session_id])→ promotes a session's cached entries into the permanent graph.
So an agent can capture context cheaply during a session, then persist the useful parts later. Pass remember_kwargs={"self_improvement": False} to keep cached writes out of the graph until you call improve() (otherwise cognee bridges them in the background).
import cognee
from cognee_integration_strands import cognee_tools, run_cognee_task
from strands import Agent
SESSION_ID = "mission-briefing"
session_agent = Agent(
model=model,
tools=cognee_tools(session_id=SESSION_ID, remember_kwargs={"self_improvement": False}),
)
# ... use session_agent to remember/recall during the session ...
# Persist everything captured in the session into the permanent graph:
run_cognee_task(cognee.improve(session_ids=[SESSION_ID]))
For a full runnable walkthrough, see examples/session_example.py.
Tool Reference
cognee_tools(session_id=None, *, remember_kwargs=None, recall_kwargs=None)
Builds the remember and recall Strands tools. Pass the result to Agent(tools=...). With session_id, writes go to cognee's session cache (persist later with cognee.improve(session_ids=[session_id])); without it, writes go straight to the permanent graph. remember_kwargs / recall_kwargs bind extra cognee params per call (e.g. remember_kwargs={"self_improvement": False}).
Returns: [remember, recall]
remember(data, **kwargs) / recall(query_text, **kwargs)
Synchronous passthroughs to cognee.remember / cognee.recall for direct use outside an agent (they run cognee on a background loop). No defaults are imposed — pass any cognee parameter. recall returns cognee's native RecallResponse list; flatten it with render_results(...).
run_cognee_task(coro, timeout=300)
Runs any async cognee coroutine (e.g. cognee.improve(...), cognee.forget(...)) from synchronous code and returns the result.
Configuration
Copy .env.template to .env and set your key:
cp .env.template .env
LLM_API_KEY=your-openai-api-key-here
Examples
examples/example.py: store contracts with an agent, then recall them from a fresh agent.examples/session_example.py: the session cache →improve()→ permanent graph flow, with before/after graph visualizations.
Requirements
- Python 3.10+
- Cognee
>=1.0.0,<=1.1.2 - Strands Agents
>=1.42.0(strands-agents[openai]for the examples) - OpenAI API key (for the example model)
Metadata
Release files for cognee-integration-strands 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| cognee_integration_strands-0.2.0.tar.gz | 5.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| cognee_integration_strands-0.2.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.5 kB
Release files / cognee_integration_strands-0.2.0.tar.gz
| Download URL | cognee_integration_strands-0.2.0.tar.gz |
|---|---|
| Size | 5.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
eaf0a76074f9f02a0d9f7d5161f60f6fd5d76cbdcc85ca6e73187fe0c0ebc45c
|
|
BLAKE2b-256 checksum How to use checksums |
7416965c9620073c983335fb0b0f2824f9385d433b028e20cbd37bd5443cd8b4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.8
|
Release files / cognee_integration_strands-0.2.0-py3-none-any.whl
| Download URL | cognee_integration_strands-0.2.0-py3-none-any.whl |
|---|---|
| Size | 5.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6454870cab36b99f01b77c1633c1ee2cad9d9de7607c565b253a5c38459fb387
|
|
BLAKE2b-256 checksum How to use checksums |
46b19872d8dd5c6ad3c34c18b7830b99560c6f49821986e9c960175f4d158e95
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.8
|
Security for cognee-integration-strands 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.