Skip to main content

Integrate the memory in the agents

The contract is described by contracts/v1/memory-provider.schema.json. An engine instance announces a declarative set of capabilities: schema_version, provider (builtin, mem0 or cognee), engine_instance, capabilities, and their split into memory and knowledge. Reading the capabilities needs no credential of the engine; it adds isolation, the separation guaranteed for the tenant of the caller, and session_memory, true for builtin only.

GroupCapabilities
Memoryremember, recall, search, update, forget, list, get, purge, get_health, get_capabilities
Knowledgeingest_knowledge, build_graph, search_graph, get_relations, delete_dataset

builtin and mem0 announce every memory capability; cognee announces forget, list, purge, get_health, get_capabilities and every knowledge capability. An operation outside the announced set answers memory_capability_unsupported (422); an unreachable engine answers memory_engine_unavailable (502). The context of each operation ($defs.context of the schema) is built server side.

Engine instances​

Every route is under /v1/memory.

Method and pathRequired roleEffect
GET /enginesauthenticatedbuiltin, the mem0 and cognee instances rendered by the Manager, the declared instances
GET /engines/{engine_id}/capabilitiesauthenticatedcapabilities, isolation, session_memory
GET /engines/{engine_id}/healthtenant_admin, developer, security_officer or auditorengine health
POST /enginesplatform_admindeclares an instance: id, provider (mem0 or cognee), base_url, tenant_id (dedicated instance), credential_ref (openbao:// or env://), access_control, tls_verify, timeout_seconds, manager_cluster, manager_service
DELETE /engines/{engine_id}platform_adminremoves a declared instance
PUT /engines/{engine_id}/credentialtenant_adminkey of the tenant on a shared instance (credential_ref as openbao://)
DELETE /engines/{engine_id}/credentialtenant_adminremoves this key

Each call to an engine goes through the guarded egress client (declared host and port only, redirects refused), with TLS verification (the Manager CA of EAI_MEMORY_ENGINES_CA_FILE on top of the default authorities), a timeout and the traceparent header. Plain HTTP is refused in staging and production unless EAI_MEMORY_ENGINES_ALLOW_HTTP.

Agent memory policy​

Method and pathOpenFGA relationEffect
GET /agents/{agent_id}/policyviewercurrent policy
PUT /agents/{agent_id}/policyeditornew version of the policy
GET /agents/{agent_id}/policy/versionsviewerprevious versions
POST /agents/{agent_id}/policy/restoreeditorrestores the version version

The body of PUT carries engine (builtin by default, mem0, cognee or hybrid), mem0_instance, cognee_instance and policy:

Field of policyDefaultRole
modessession, long_term, agent on; shared, knowledge_graph offmemory modes allowed
write_scopes, read_scopessession, user, agentscopes where the agent writes and reads, among session, user, agent, shared_agents, project, team, organization, global
default_scopeuserscope of a write without a scope
allowed_kindsallepisodic, semantic, procedural, preference, fact
max_classificationconfidentialhighest classification accepted
allow_personal_datatruepersonal data refused when false
retention_days, legal_holdnone, falselifetime and legal hold
inferfalsefact extraction by the LLM of the engine
shared_with, teams, global_accessempty, falsesharing with other agents and teams
required_isolationlogicalminimal guarantee required from the instance (see Security)
recall_top_k8number of items of a recall

A change of engine and a share are audited (memory.engine.change, memory.share). Memorization follows this policy: nothing writes every conversation to the engines.

Memories​

These routes need the relation can_invoke on the agent (or to be the agent).

Method and pathMain fieldsEffect
POST /agents/{agent_id}/memoriescontent, scope, kind (fact by default), classification, session_id, team, retention_days, legal_hold, sourceremembers (201)
GET /agents/{agent_id}/memoriesscope, limit, cursor, include_content (false by default)paginated list
POST /agents/{agent_id}/recallquery, scopes, top_k, session_idrecall framed as untrusted data
POST /agents/{agent_id}/memories/searchsame fieldssearch
GET /agents/{agent_id}/memories/{item_id}-reads one item
PATCH /agents/{agent_id}/memories/{item_id}contentupdates
DELETE /agents/{agent_id}/memories/{item_id}-forgets one item
POST /agents/{agent_id}/memories/purgescope, confirm, team, session_idpurges a scope (confirmation required)
POST /agents/{agent_id}/memories/exportscopesexports the authorized memories

Knowledge and graph​

Method and pathMain fieldsEffect
POST /agents/{agent_id}/knowledgetexts (1 to 50), scope (agent by default), team, dataset_id, classification, retention_days, legal_hold, build_graphingestion (201)
GET /agents/{agent_id}/knowledge/datasetsscope, limit, cursordatasets
POST /agents/{agent_id}/knowledge/graphdataset_idsbuilds the graph (cognify)
POST /agents/{agent_id}/knowledge/searchquery, dataset_ids, top_k (10), search_type (CHUNKS, CHUNKS_LEXICAL, SUMMARIES, RAG_COMPLETION, GRAPH_COMPLETION)search in the knowledge
GET /agents/{agent_id}/knowledge/datasets/{dataset_id}/relations-entities and relations
DELETE /agents/{agent_id}/knowledge/datasets/{dataset_id}-deletes the dataset

Hybrid mode​

With engine set to hybrid, Mem0 keeps the facts and memories, Cognee the knowledge and relations. A write goes to one engine only: a memory to Mem0, a knowledge ingestion to Cognee. A recall queries both, merges the results, deduplicates them by content and keeps every source. Session memory always stays in builtin, never in Mem0 nor in Cognee.