> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cognee.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Strands

> Add persistent memory to Strands agents with Cognee.

Give your [Strands](https://strandsagents.com/) 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

```bash theme={null}
pip install cognee-integration-strands
```

<Info>
  Requires Python 3.10+. Pins `cognee>=1.0.0,<=1.1.2` and `strands-agents>=1.42.0,<2.0.0`.
</Info>

## Quick Start

Set your LLM key (cognee extracts knowledge with an LLM), then attach the tools:

```bash theme={null}
export LLM_API_KEY="your-openai-api-key-here"   # used by cognee
```

```python theme={null}
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:

| Tool       | Description                                                                          |
| ---------- | ------------------------------------------------------------------------------------ |
| `remember` | Store information in memory for later retrieval (wraps `cognee.remember`)            |
| `recall`   | Search 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:

```python theme={null}
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]))
```

<Info>
  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.
</Info>

## 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

***

<CardGroup cols={2}>
  <Card title="GitHub Repository" icon="github" href="https://github.com/topoteretes/cognee-integrations/tree/main/integrations/strands">
    View source code and examples
  </Card>

  <Card title="Examples" icon="book" href="https://github.com/topoteretes/cognee-integrations/tree/main/integrations/strands/examples">
    Runnable example scripts
  </Card>
</CardGroup>
