Skip to main content
The cognee-memory kit is a Docker Sandboxes mixin that gives any sandboxed coding agent persistent, self-improving memory backed by cognee. Everything runs embedded inside the sandbox — no external services, no database to provision.
The kit lives in the cognee repository at examples/integrations/docker-sandbox-kit. Clone it (or copy the cognee-memory/ directory) and point --kit at it.
Verified end-to-end with sbx v0.39.0 under a deny-all network policy. The kit does not declare a minimum sbx version.

What the kit does

cognee-memory/spec.yaml is a stackable mixin kit (schemaVersion: "2", kind: mixin) that:
  • installs the CLI with uv tool install cognee at sandbox creation — this assumes uv is present in the base image, which Docker’s default sandbox images ship;
  • pins all memory state to /home/agent/.cognee (DATA_ROOT_DIRECTORY=/home/agent/.cognee/data, SYSTEM_ROOT_DIRECTORY=/home/agent/.cognee/system), so memory survives sandbox restarts and is easy to inspect or back up;
  • defaults to LLM_MODEL=openai/gpt-6-luna and sets TELEMETRY_DISABLED=1;
  • pins ENABLE_BACKEND_ACCESS_CONTROL=true — cognee’s default, made explicit so the kit’s multi-agent behavior is unambiguous: multi-tenant ACLs and per-user+dataset database isolation;
  • declares a proxy-managed OpenAI credential so the real key never enters the sandbox VM;
  • allowlists only the domains cognee actually needs under deny-all;
  • appends usage instructions to the agent’s memory file (kits-memory/cognee-memory.md): recall at task start → work → remember durable learnings, plus the multi-agent handover pattern.
Because it is a mixin, it stacks onto any agent sandbox — claude, shell, opencode, and so on.

Prerequisites

Install and start sbx, then set the baseline policy and the OpenAI secret. The install line below is macOS/Homebrew; use whatever install path sbx documents for your platform.
set-custom prints a placeholder (sbx-cs-…, retrievable later with sbx secret ls). Sandboxes only ever see the placeholder; the proxy substitutes the real key on requests to api.openai.com.

The cognee-openai credential

The kit declares its credential service as cognee-openai, not openai:
The rename is deliberate: built-in agent kits (shell, claude, …) already declare the common LLM services, and composition fails when two kits define the same service. required: false means sandbox creation is never blocked when no key is bound. There are two ways to supply the key, both proxy-side:
  1. Bind the service — interactively at run time, or via ~/.config/sbx/credentials.yaml. The agent sees LLM_API_KEY=proxy-managed and the inject rule rewrites the Authorization header for api.openai.com.
  2. Headless — sbx secret set-custom --host api.openai.com --env LLM_API_KEY --value <key>, as in the prerequisites above.
The kit’s proxy-managed environment value wins over the custom secret’s placeholder. For headless sbx exec commands, export the printed placeholder explicitly:

Network allowlist

Under deny-all, the kit’s allowlist is the sandbox’s only egress. Each domain was discovered by running under the deny-all policy and reading sbx policy log — the recommended way to derive a kit allowlist:

Single-agent usage

Inside the sandbox the agent has the full memory CLI: The first remember builds a knowledge graph with a few LLM calls, so it takes noticeably longer than a plain key-value write; recall then answers from the graph. To use a provider other than OpenAI, edit environment.variables, the credentials and permissions.network blocks, and the stored secret to match — see LLM providers.

Multi-agent demo: supervisor to worker handover

demo/handover.sh runs a round-trip memory handover between two real sandboxes, cognee-supervisor and cognee-worker, both created from this kit and sharing the demo/ directory as their workspace. The supervisor and worker are separate cognee users, so ACLs gate what each one can read and write.
The three phases run sequentially:
1

brief — supervisor sandbox

Stores a private note (dataset supervisor_private) and a handover briefing (dataset handover) in its own datasets, grants the worker read and write on the briefing, and writes a handover token to demo/handover-out/handover_token.json carrying the briefing’s dataset UUID.
The creator automatically holds share, so no extra grant is needed to hand access over.
2

work — worker sandbox

Redeems the token by UUID, proves the two boundaries, then writes its completion report back into the shared dataset:
Negative checks: recalling the supervisor’s private dataset raises PermissionDeniedError, and recalling the shared dataset by name (datasets=["handover"]) fails to resolve.
3

review — supervisor sandbox

Recalls the worker’s report from the shared dataset.
Share by UUID, never by name. Dataset names are namespaced per user — a name maps to uuid5(name + user.id + tenant_id) — so a name never crosses a user boundary. The dataset UUID is the only cross-user address, for reads and for cross-owner writes alike.
Permission management is Python-SDK/REST-only: cognee-cli has no user or permission commands, so the multi-agent pattern requires the SDK (create_user, get_datasets, authorized_give_permission_on_datasets). On a fresh install, call create_db_and_tables() before touching users or ACLs — the CLI does this implicitly, the raw SDK path does not. The payload, demo/supervisor_worker_handover.py, is self-contained: drop it into any repository with cognee installed and run python supervisor_worker_handover.py to execute all phases in one process, or --phase brief|work|review to split them across environments. Clean up with:

How the memory snapshot moves

Embedded LanceDB cannot operate on the shared virtiofs workspace mount. The demo works around this by running cognee state on each VM’s local disk during a phase and handing it between sandboxes as a snapshot with sbx cp — the host keeps the canonical copy in demo/cognee-state/ between phases:
The chown step is required because sbx cp preserves the host uid. Phases run sequentially — the snapshot moves, it is never shared live.
For always-on cross-sandbox memory (concurrent agents, no shared workspace), run a central cognee API server and point sandboxes at it over the network allowlist instead of sharing embedded storage.

Backends that support user permissioning

Permissions are read / write / delete / share per dataset. The kit’s defaults — Ladybug for the graph, LanceDB for vectors — support per-user+dataset database isolation, as do Neo4j (including the neo4j_community container-per-dataset handler), Postgres (demo), Turso, and PGVector. Neptune, Neptune Analytics, ladybug-remote, and community vector adapters that do not register a dataset-database handler are not supported — see the permissions system for how users, datasets, and ACLs fit together.

Inspecting memory and security

The relational database (demo/cognee-state/system/databases/cognee_db, SQLite) holds users, datasets, and the ACL rows. After the demo, the worker holds exactly two grants — read and write — on the shared dataset, and nothing on the private one.

Run the handover on Daytona

examples/integrations/daytona ports the supervisor → worker handover to Daytona cloud sandboxes. It runs the same supervisor_worker_handover.py payload, read from this kit’s demo/ directory. handover.py does the orchestration. It builds a cognee-memory snapshot once, then runs each phase (brief, work, review) in its own short-lived sandbox. cognee stays embedded on sandbox-local disk, with no cognee server. --handover picks how memory gets from one sandbox to the next:
  • cogx (default): only the shared dataset moves. cogx_handover.py exports it as a COGX archive with cognee.export(dataset_id, format="cogx", include_permissions=True), which records the owner and ACL grants. The next sandbox restores it with cognee.remember(COGXArchiveSource(dir)), which makes no LLM call (embeddings are recomputed). The supervisor’s private dataset never leaves the first sandbox. Restored accounts get new ids, so the import re-issues the handover token with the restored dataset’s id.
  • copy: the whole cognee state is tarred, pulled to the host and pushed into a fresh sandbox, as sbx cp does above.
  • fork: Daytona clones the running sandbox copy-on-write. This works only for Linux VM sandboxes created from a VM-class snapshot; the cognee-memory snapshot the script builds gives container sandboxes, so fork fails on it. auto tries a fork and falls back to copy when Daytona answers 422.
copy and fork carry every dataset, including the private one, and only the ACLs that travel with them protect it. In every mode the worker’s reads are still gated by cognee’s ACLs, and the shared dataset is addressed by UUID. The security posture follows the kit’s:
  • The LLM key is an organization Secret, cognee-openai, scoped to api.openai.com. The sandbox only ever sees a placeholder.
  • A sandbox-level domain allow list (api.openai.com, extension.ladybugdb.com) applies on Tier 3/4 organizations only. Tier 1/2 organizations reject it, and sandboxes there run behind Daytona’s organization-wide policy.
  • After brief, the script checks the credential and network walls from inside the sandbox and fails the run if one does not hold. On Tier 1/2, Daytona’s own egress proxy still reaches hosts the policy blocks on direct connections. The script reports that gap as a warning; --strict-walls turns it into a failure.
walkthrough.py shows a run as annotated terminal output: what each block of lines proves, and how long it took. It replays a recorded transcript (no account needed), or annotates a live run with --live. --record saves a transcript, and --markdown renders one as a document. The rl/ example uses the same snapshot, Secret and COGX pieces in an RL rollout loop. It runs one fresh sandbox per attempt, plus a memory sandbox running the cognee API server for the whole run. Before each group of attempts, the loop calls POST /api/v1/recall. After each graded attempt, it stores a scored QAEntry through POST /api/v1/remember/entry. After each step, it calls POST /api/v1/improve with that step’s session id. Held-out variants are evaluated with memory off and then on, and the memory is exported as a COGX archive at the end as a checkpoint. The example READMEs cover the operator details: snapshot reactivation, label-based cleanup of interrupted runs, Tier 1/2 quotas, and the RL run’s results.

Kit source

spec.yaml, the handover demo, and the README

Daytona port

The handover, the walkthrough, and the RL memory loop on Daytona

Docker Sandboxes kits

Docker’s documentation for authoring kits