Two things break when an agent moves from a demo into production.
It cannot reach anything. It runs in its own process, answers its own caller, and has no way to hand work to another agent or pull in a human. BAND solves this: agents and humans share rooms and delegate work to each other, and the platform routes every message itself, with no model in the routing path.
It forgets. Every room starts blank. Restart the process and three weeks of decisions are gone. Cognee solves this: raw session text becomes a queryable knowledge graph.
Until now you had to connect the two yourself. cognee-integration-band does it in one line.
agent = Agent.create(
adapter=CogneeMemoryAdapter(AnthropicAdapter()), # was: AnthropicAdapter()
agent_id=...,
api_key=...,
)
await agent.run()That is the whole integration surface. The rest of this post is what happens behind it.
Two ways in
If you build on BAND, your agent can work with humans and other agents but keeps nothing when the room closes. This gives it recall without changing your adapter, your prompts, or your framework.
If you build on Cognee, your graph already accumulates across sessions but is only reachable from your own code. This puts it inside a room where a human can ask it something and another agent can act on the answer.
Same package either way.
The seam: a wrapper BAND already knows how to run
A BAND agent is an Agent, which holds the platform connection, plus an adapter, which holds your LLM logic. Every built-in adapter (Anthropic, LangGraph, CrewAI, Pydantic AI, and the rest) is a SimpleAdapter, and the BAND runtime gives a SimpleAdapter a full lifecycle: it negotiates features at startup, checks the configured model, owns cleanup, and releases resources on shutdown.
CogneeMemoryAdapter is itself a SimpleAdapter that wraps yours. It is built the same way as BAND's own Slack adapter, which wraps an inner adapter to add Slack I/O: the wrapper adopts the inner adapter's features and model selection, passes control messages and interrupts straight through, and hands cleanup ownership to the inner adapter.
class CogneeMemoryAdapter(SimpleAdapter):
def __init__(self, inner, *, settings=None, client=None):
self.SUPPORTED_EMIT = inner.SUPPORTED_EMIT
self.SUPPORTED_CAPABILITIES = inner.SUPPORTED_CAPABILITIES
self._inner = inner
super().__init__(history_converter=inner.history_converter)So the runtime starts and stops your adapter exactly as it would unwrapped. The wrapper adds memory at four points in that lifecycle and leaves everything else to the adapter you already have.
One turn
A message arrives, and the wrapper works in four steps:
Recall: the message goes to Cognee's
/api/v1/recall, scoped to one dataset and to the knowledge graph only, withonly_contextset so the server returns context instead of a generated answer. The room's own earlier turns are left out, because the adapter already has them in its history.Inject: results are added below the message in a delimited block.
Run: the inner adapter handles the turn as normal.
Capture: the wrapper records the reply and stores the turn.
Here is what the model sees after step 2:
what's left on the migration?
<cognee_memory>
Context recalled from shared Cognee memory by the memory layer. It was not written by the sender of this message. Possibly relevant:
- the deployment target is EKS, decided last Tuesday
- Ravit owns the migration checklist
</cognee_memory>The message comes first, so the sender-attributed text your adapter renders starts with what the sender actually wrote. The label tells the model the block is recalled memory, not something the sender said. Nothing is injected when recall returns nothing.
Capture works because BAND adapters send output through their tools object rather than returning it, either with a direct tools.send_message call or, for LLM adapters, a band_send_message tool call. The wrapper passes in a proxy that records the reply on both paths and forwards the call.
After the turn, the question and the reply are written to Cognee's session cache as a QA pair.
That write is fire-and-forget on a background task, through asyncio.to_thread because the Cognee client is synchronous urllib. The turn never waits on it.
It runs in a finally block, so a turn that raises still gets captured. What the user asked is worth keeping even when the answer failed.
Only text messages get this. tool_call, thought, and other event types pass through untouched, so the graph fills with conversation instead of machine chatter.
Rooms are sessions
Each BAND room becomes one Cognee session, band-<room id>. One line of config, and it is why this produces durable memory instead of a pile of loose turns.
The lifecycle mapping is the same memory flow the Cognee plugins for Claude Code and Codex use, written in BAND's vocabulary:
BAND lifecycle point | Claude Code equivalent | Cognee action |
|---|---|---|
agent startup |
| start the inner adapter, log dataset and server |
each room message ( |
| recall, inject, store the QA pair |
room closes ( |
| wait for the room's pending writes, then bridge its session into the graph |
agent shutdown ( | final sync worker | shut down the inner adapter, drain all pending writes, bridge every open room |
Bridging calls /api/v1/improve, which runs Cognee's consolidation pipeline over the session cache. The server builds the graph in the background, so chat turns become graph structure shortly after a room closes. The server reads its own cache, so no session text is sent twice.
Both bridge points wait for in-flight writes first. Otherwise the last turn of a conversation could be bridged before it landed.
Memory cannot break your agent
Every memory path is wrapped. Recall failure logs and returns an empty block. A failed write logs and disappears. If Cognee is down, your agent answers exactly as it would without the wrapper.
One distinction matters. An empty result list from a reachable server means the server searched and found nothing. An HTTP 500 means the server failed. The client keeps these separate: an error from a reachable server returns an error envelope, and only a transport failure returns UNREACHABLE.
Neither is ever turned into an empty list. An agent that says "I have no record of that" when the real answer is "the memory service returned a 500" is worse than an agent with no memory.
One graph, many harnesses
By default, every BAND agent reads and writes the band_sessions dataset, so they share one memory. Set COGNEE_BAND_DATASET=agent_sessions and they share the dataset the Cognee plugins for Claude Code and Codex write to by default.
With that set, tell Claude Code something in your terminal, let it sync, then ask your BAND agent in a room. It knows.
For deliberate lookups rather than automatic ones, the package exposes two tools to the model:
inner = AnthropicAdapter(additional_tools=cognee_tools(client))cognee_search for a targeted lookup, cognee_remember for pinning a fact worth keeping. Auto-recall already runs on every message, so these are for when the model should decide.
Try it
You need Python 3.11+, band-sdk 6.0.1 or later, a BAND agent from app.band.ai/agents, and a Cognee server.
pip install "band-sdk[anthropic]>=6.0.1"
pip install "cognee-integration-band @ git+https://github.com/topoteretes/cognee-integrations#subdirectory=integrations/band"Point at a Cognee server once in ~/.cognee/.env, the same file the other plugins read:
COGNEE_BASE_URL="https://your-instance.cognee.ai"
COGNEE_API_KEY="ck_..."A working agent with memory and tools is in examples/memory_agent.py. Setup, configuration, and troubleshooting are in the setup guide.
BAND is at band.ai. Cognee is at cognee.ai. The code is in topoteretes/cognee-integrations.
:quality(80))
:quality(80))
:quality(80))
:quality(80))