CogneeMemoryAdapter and every room your agent joins gets persistent, shared memory. Context is recalled before your adapter sees a message, the question and reply are stored after it answers, and a closed room is promoted into the permanent knowledge graph. Your adapter, prompts, and framework do not change.
The
cognee-integration-band package is not published on PyPI. Install it from the integrations/band directory of cognee-integrations, as shown below.Why Use This Integration
- One line of code:
CogneeMemoryAdapter(inner)wraps an adapter you already built - Framework agnostic: works with any band-sdk adapter built on
SimpleAdapter, which covers every built-in adapter — Anthropic, Claude SDK, LangGraph, CrewAI, Pydantic AI, and others - Rooms become memory: Band room
r1maps to Cognee sessionband-r1instead of a transcript that disappears - Shared brain: every Band agent on the same dataset shares one graph, and you can opt in to the dataset the Claude Code and Codex plugins use
- Never breaks a turn: every memory failure is logged and swallowed
Install
You need a Band agent from the agent console, a reachable Cognee server, a model provider key for your adapter, and Python 3.11+. Cognee can be Cloud, self-hosted, or local — this is a thin HTTP client and never starts a server for you.band-sdk extra matching the adapter you plan to wrap. The memory package depends only on band-sdk 6.0.1 or later; its Cognee client uses the standard library. To work from a clone instead, run pip install -e integrations/band from the repository root.
Configure
Point at your Cognee server once in~/.cognee/.env — the same file the Claude Code and Codex plugins read:
BAND_AGENT_ID, BAND_AGENT_API_KEY, ANTHROPIC_API_KEY — exported in the shell instead.
The default URL is Cognee’s agent-mode port, where the Claude Code and Codex plugins bootstrap a local API. A standard local server listens on
8000, so set COGNEE_BASE_URL to match. Those plugins also mint an API key for you, while this integration only ever sends the COGNEE_API_KEY you give it. If the server is local and no key is set, the agent logs a warning at startup and, on a Cognee server that enforces auth on localhost, runs without memory.CogneeSettings.resolve(recall_timeout=5.0, session_prefix="prod"). Explicit overrides beat both the environment and the file.
Quick Start
Wrap the adapter you already pass toAgent.create:
CogneeMemoryAdapter resolves settings from the environment. It composes your adapter the way band-sdk’s own SlackAdapter does, so your adapter keeps its features, model selection, control handling, and resource cleanup, and the Band runtime starts and stops it as it would unwrapped. Passing anything that is not a band-sdk SimpleAdapter raises a TypeError.
To confirm it works, store a fact in one room and ask for it back in a different room — same-room recall could just be conversation history. For the demo worth showing someone, tell the Cognee Claude Code plugin a fact in a terminal, let it sync, then ask your Band agent. The plugin writes to agent_sessions by default, so start the agent with COGNEE_BAND_DATASET=agent_sessions and the answer comes back.
Explicit Memory Tools
Automatic recall runs on every text message. To also let the model make deliberate memory calls, build one client and share it, which keeps the tools and the wrapper on one dataset:cognee_search(query), which runs a targeted search of the dataset’s graph, and cognee_remember(content), which writes durably under the band_memory node set with the graph built in the background. The prompt section is optional: the injected block already says it was not written by the sender, and the section only tells the model how to use it. cognee_tools works with any adapter that accepts additional_tools.
integrations/band/examples/memory_agent.py is a complete agent built this way. Its inline script metadata installs band-sdk and this package from GitHub, so run it with uv run examples/memory_agent.py from integrations/band.How It Works
Recall is the only memory operation on the critical path, since the result is needed before your adapter runs. Writes never block the event loop. Recall reads the knowledge graph only, not the room’s own session, which your adapter already holds in its history. Each result is cut down to the retrieved context, and the whole block is capped at about 8,000 characters (
CogneeSettings.max_memory_chars).
Some messages pass through untouched and are never stored: non-text events such as tool calls and thoughts, slash commands such as @bot /model gpt-5 (so your adapter still parses them), and Band’s own system notices such as contact requests. A turn that ends without a reply — band_no_reply, or an adapter error before anything was sent — is not stored either. The stored question is the sender’s name and original message, never the injected block, so recalled context is not re-ingested turn after turn.
Turns that wait on an approval are stored once the reply is sent. Codex and Claude Agent SDK adapters report when the turn ends; Cursor and OpenCode do not, so their turn is stored at the room’s next message, when the room closes, or when the agent stops, with whatever reply was sent by then.
This is what the model receives, and when recall finds nothing, nothing is injected:
Choosing Your Memory Scope
COGNEE_BAND_DATASET is the isolation control. Recall reads exactly one dataset, so this is a hard boundary and not a ranking preference. Leave the default band_sessions for one shared brain across all your Band agents, set agent_sessions to share with the Claude Code and Codex plugins, or set one dataset name per team or per agent to isolate them. Decide before your agents start writing, since moving content between datasets afterwards is a Cognee-side job.
Troubleshooting
Memory degrades to a no-op and never breaks a turn, which means failures are quiet by design. Adapter problems are logged on thecognee_band logger and transport problems also write a [cognee-band] line to standard error, so configure logging before debugging anything below. Start with the line the wrapper logs at startup, cognee memory active: dataset=... server=..., which catches a wrong endpoint before you chase anything else.
TypeError: CogneeMemoryAdapter wraps a band-sdk SimpleAdapter
TypeError: CogneeMemoryAdapter wraps a band-sdk SimpleAdapter
You passed something other than a band-sdk adapter instance. Wrap the constructed adapter object, such as
AnthropicAdapter(), not its class or its config.Nothing is recalled
Nothing is recalled
Look for a warning on the
cognee_band logger or a [cognee-band] line on standard error. No warning means the server searched and found nothing, which is expected on a cold dataset or right after a room was bridged. An empty result is never confused with a failure. If you expected memory from the Claude Code or Codex plugins, check COGNEE_BAND_DATASET — this integration does not read COGNEE_PLUGIN_DATASET.Server unreachable, or HTTP 401 and 403
Server unreachable, or HTTP 401 and 403
For an unreachable server, check that
COGNEE_BASE_URL works from the agent process, remembering that the default points at the agent-mode port. For an authorization failure, set COGNEE_API_KEY — this integration never mints one for you, and recent Cognee versions enforce auth even on localhost.TLS or certificate errors
TLS or certificate errors
Usually a macOS Python install missing root CAs. Run
pip install certifi in the agent environment; the client uses it automatically when it is importable.Configuration seems ignored
Configuration seems ignored
Parsing never raises, so a malformed file is skipped silently. Check the format is
KEY=VALUE, one per line, with an optional export prefix and optional quotes, and no interpolation. Check nothing in your shell already exports the same variable, since exports win. The file is read once per process, so restart the agent after editing it.Turns missing from memory
Turns missing from memory
Turns without a reply are not stored. Replies are captured from both ways an adapter can post one: a direct
tools.send_message call, and a band_send_message tool call, the path LLM adapters such as Anthropic and Gemini use. An adapter that emits output only through send_event is not captured.Memory from a closed room never shows up
Memory from a closed room never shows up
Consolidation runs through
improve in the background on the server, so give it time. Also confirm the agent shut down cleanly, since the shutdown path is what bridges rooms that were still open.Current Limits
- Only text messages are remembered. Tool calls and reasoning events are excluded, so a fact surfaces only if it reaches the reply text. The client has a trace-storing method for this, but the adapter does not drive it yet.
- Session names can collide. Two agents on the same dataset serving the same room ID write to the same session. That is usually intended, but change
session_prefixif you need them apart. - Recall adds latency to every text turn, up to the 20 second default timeout. Lower
recall_timeoutif you would rather drop memory than wait.
Integration Source
Read the adapter, client, and examples in cognee-integrations
Band
Learn about the Band agent platform