Skip to Content
The Ngamia platform API is in preview. Endpoints may change before general availability.
EnginesKUMBUKUMBU: memory

KUMBUKUMBU: memory

KUMBUKUMBU is Ngamia’s memory engine. It keeps durable, per-end-user memory for agents. It is a standalone Rust service (kumbukumbu) with its own MongoDB database. It is private: nothing on https://api.ngamia.com exposes it directly. Other engines call its HTTP API. They never read its collections.

KUMBUKUMBU is a development baseline. It is approved for a sandbox beta with synthetic or reviewed non-sensitive data only. It is not yet approved for production personal data. See Known limits.

How agents use it

You turn memory on per agent with memory: true in the agent definition. The platform does not call KUMBUKUMBU itself. NAK, the agent runtime, does.

  1. Your app starts a run with POST /v1/agents/{slug}/runs. With an API key, pass user so each end user gets their own memory.
  2. The platform calls NAK with a service assertion for (workspace, subject, app platform).
  3. When the agent has memory: true, NAK recalls up to 5 facts for the run’s user and adds them to the prompt. The query is the latest user message. It calls POST /v1/recall with min_score 0.3.
  4. For agents with memory: true, and unless NAK_KUMBU_FORWARD_EVENTS=false, NAK forwards each turn’s user input and final answer to POST /v1/events. The extraction worker can later turn these events into memories.

Details of the NAK side:

  • Every call carries a fresh NAK service assertion (nak-te-assertion-v1, Ed25519 JWT, audience ngamia-kumbukumbu). It names the tenant, the user (sub) and the app. KUMBUKUMBU accepts each jti once.
  • The app in the assertion must equal KUMBU_APP_ID. In the platform stack this is platform.
  • The subject is the run’s end user: kida:<user> for people, ext:<user> or key:<id> for API keys. Each end user has a separate memory.
  • The workspace ID (KIDA tenant UUID) is the KUMBUKUMBU tenant.
  • Forwarded text is cut to 16 KiB. Forwarding runs in the background through a bounded queue. Turns are dropped, not blocked, when memory is slow.
  • Idempotency keys are nak:<run_id>:<seq>, so a retried forward is deduplicated. The session is the conversation thread, or the run when it starts a new one.
  • Memory calls time out after 3 seconds. An unreachable memory service never fails a run: recall returns no facts.
  • Both recall and forwarding happen only for agents defined with memory: true. In platform mode NAK checks the agent of each run before forwarding its turns; runs of other agents send nothing to memory. Operators can also turn forwarding off for the whole deployment with NAK_KUMBU_FORWARD_EVENTS=false.

Data model

RecordWhat it is
EventAn input observation: a user message, assistant answer, or tool result. Immutable and idempotent. Expires after KUMBU_EVENT_RETENTION_SECONDS (MongoDB TTL index).
MemoryA fact, preference, episode, procedure or relation. Has text, type, confidence, importance, sensitivity, provenance, source event IDs, a content hash and temporal fields.
Memory operationHistory of each create, correction and forget.
EntityNames resolved within app, tenant and subject, linked to memories by ID.
Session summaryA short, replaceable digest of a session with links to source events.
ProfileA deterministic view of a subject’s facts.

Scope: every record is scoped by app, tenant and subject. Credentials fix the tenant; callers cannot choose it in the request body.

Memory types: episodic, semantic, procedural, relational. Status: active, archived, deleted, conflict, pending_review. Callers cannot set status through PATCH.

Trust comes from the event role, never from the caller:

RoleTrust
user, systemHigh
toolMedium
assistant, webLow
  • system events need the admin scope. Events more than five minutes in the future are rejected.
  • Direct writes (POST /v1/memories, MCP remember_memory) get tool/medium-trust provenance and cannot create procedural memories.
  • A correction does not overwrite. It creates a replacement and archives the old version in one transaction.
  • Time has two axes: valid time (valid_from included, valid_to excluded) and record time. Recall can ask as_of a past instant.

Sensitive categories

Sensitivity is none, personal or sensitive. Sensitive categories are health, religion, politics, sexual_orientation, ethnicity, finances, children and government_identifier. They are denied by default. A sensitive memory is stored only when both allow its category:

  • the deployment list KUMBU_SENSITIVE_CATEGORIES (what its Vault setup may hold), and
  • the tenant’s published policy (PUT /v1/admin/policy). No policy means no categories.

The extraction worker never stores sensitive candidates. Sensitive memories have no embedding and never appear in recall or profiles.

Redaction

Common-pattern rules run before events and memories are stored, and before extraction. The built-in rules replace phone numbers ([REDACTED_PHONE]), email addresses ([REDACTED_EMAIL]) and government ID numbers ([REDACTED_GOVERNMENT_ID]). Override them with a JSON array of { "name", "pattern", "replacement" } in KUMBU_REDACTION_RULES_FILE. Set the same file on serve, worker and mcp-stdio. Limits: 64 rules, 2 KiB per pattern, 64 KiB per file. Bad rules stop startup.

Redaction is best-effort. It does not find every kind of personal data and does not redact records already stored.

Privacy

What is stored. Events (until retention expires), memories, their history, entities, summaries, profiles, and audit records. Event idempotency keys are stored as app/tenant-scoped HMAC-SHA256 digests. API keys are stored as hashes. Logs hold only request ID, method, status and duration, never bodies or memory text.

Vault Transit encryption. With KUMBU_KMS_PROVIDER=vault-transit, each sensitive memory gets its own data key from Vault (transit/datakey/plaintext on a derived=true key, context bound to app, tenant and category). The text is encrypted locally with AES-256-GCM, bound to app, tenant, subject and memory ID. Only the wrapped key is stored; the text field holds [encrypted].

  • Reads and exports decrypt. Sensitive memories cannot be patched; forget and re-create them.
  • Without a working KMS, sensitive reads and writes return 503. Moved or tampered ciphertext returns 403.
  • Rotation: rotate the Transit key, run kumbukumbu kms-rewrap until nothing is skipped, then raise min_decryption_version.

Export. Both need the forget scope and are audited.

  • GET /v1/subjects/{subject}/export: synchronous, Relaxed Extended JSON, at most 10,000 records and 8 MiB (else 413).
  • POST /v1/subjects/{subject}/exports: asynchronous NDJSON, up to 1,000,000 records and 512 MiB. Runs inside serve. Download ends with a trailer line; without it the file is incomplete. Exports expire after 24 hours.

Deletion. DELETE /v1/subjects/{subject} (forget) fences new writes, waits for reads to drain, removes the subject’s records for that app and tenant, and verifies zero counts. It is resumable: retry the same request if it fails. Reads and recall reject a subject being deleted.

Subject deletion is not production-accepted. In-flight read races, Atlas index propagation and backup/restore replay are unverified.

API surface

Protected routes take Authorization: Bearer <credential>: a KUMBUKUMBU API key, an optional KIDA user token, or a NAK assertion. admin satisfies any scope.

RouteScopePurpose
GET /healthzpublicLiveness
GET /readyzpublicMongoDB, Atlas Search/Vector Search and KMS readiness
GET /openapi.jsonpublicOpenAPI document
POST /v1/eventswriteIngest 1-100 events for one subject
POST /v1/memorieswriteCreate an explicit memory
GET /v1/memories/{id}readRead one memory
PATCH /v1/memories/{id}writeCorrect content (supersedes)
DELETE /v1/memories/{id}forgetForget one memory
GET /v1/memories/{id}/historyreadOperation history
POST /v1/recallreadRecall, with optional bounded context
GET /v1/subjects/{subject}/profilereadDeterministic profile
GET /v1/subjects/{subject}/exportforgetSynchronous export
POST /v1/subjects/{subject}/exports, GET .../exports/{id}, GET .../exports/{id}/downloadforgetAsynchronous export
DELETE /v1/subjects/{subject}forgetDelete a subject
POST /v1/sessions/{id}/summarize, GET /v1/sessions/{id}/summarywrite / readSession summaries
POST/DELETE /v1/admin/api-keysadminCreate or revoke API keys
GET/PUT /v1/admin/policy, GET /v1/admin/policy/revisionstenant adminSensitive-category policy
GET /v1/admin/jobs, POST /v1/admin/jobs/{id}/replaytenant adminList jobs, replay dead letters
GET /metricsmetrics tokenPrometheus metrics
POST /mcpper toolMCP Streamable HTTP (opt-in)

Recall accepts query, limit (default 20), min_score (default 0.5), type and agent filters, context, and the filters since, until, as_of and entity_ids. tags is rejected: memories have no tags.

MCP tools, over kumbukumbu mcp-stdio or /mcp with X-Kumbu-Subject:

ToolScope
recall_memoriesread
get_profileread
remember_memorywrite
summarize_sessionwrite
forget_memoryforget (needs confirmed: true)

Scopes: NAK assertions get KUMBU_NAK_ASSERTION_SCOPES (default read,write). KIDA tokens get KUMBU_KIDA_SCOPES and reach only their own user. Neither can ever get admin.

Configuration

VariableMeaning
KUMBU_MONGO_URI, KUMBU_DBMongoDB replica set or Atlas, and database name
KUMBU_APP_IDThe one app this process serves; platform in the platform stack
KUMBU_EVENT_RETENTION_SECONDSRequired, positive. Raw event lifetime
KUMBU_IDEMPOTENCY_HMAC_KEYRequired by serve. 64 hex characters, same on all replicas. Changing it needs a migration
KUMBU_BINDListen address, default 127.0.0.1:8080 (plain HTTP)
KUMBU_TENANT_REQUESTS_PER_MINUTEShared per-tenant limit, default 600 (then 429)
KUMBU_REQUEST_TIMEOUT_SECONDS, KUMBU_MAX_CONCURRENT_REQUESTSDefault 30 (then 503) and 256
KUMBU_SEARCH_INDEX_WAIT_SECONDSWait for Atlas indexes at startup, 1-3600, default 300
KUMBU_NAK_ASSERTION_ISSUER, KUMBU_NAK_ASSERTION_KEYSEnable NAK assertions; issuer ngamia-nak, 1-8 Ed25519 public keys by key ID (JSON)
KUMBU_NAK_ASSERTION_AUDIENCE, KUMBU_NAK_ASSERTION_SCOPESDefault ngamia-kumbukumbu and read,write
KUMBU_KIDA_ISSUER, KUMBU_KIDA_JWKS_URL, KUMBU_KIDA_AUDIENCE, KUMBU_KIDA_SCOPESOptional KIDA user tokens; set all four
KUMBU_KMS_PROVIDER, KUMBU_SENSITIVE_CATEGORIESvault-transit or none (default), and allowed categories
KUMBU_VAULT_ADDR, KUMBU_VAULT_TOKEN_FILE, KUMBU_VAULT_TRANSIT_MOUNT, KUMBU_VAULT_TRANSIT_KEY, KUMBU_VAULT_NAMESPACEVault; mount and key default to transit and kumbukumbu
KUMBU_LLM_PROVIDER, KUMBU_LLM_ENDPOINT, KUMBU_LLM_MODEL, KUMBU_LLM_API_KEYExtraction model; none (default) or openai_compatible
KUMBU_SESSION_SUMMARIES, KUMBU_SUMMARY_EVENT_THRESHOLDenabled to summarise; worker auto-summarises every 50 new events by default
KUMBU_EMBED_PROVIDER, KUMBU_EMBED_ENDPOINT, KUMBU_EMBED_MODEL, KUMBU_EMBED_DIMnone (default) or loopback-only ollama; dimension 512 or 768
KUMBU_REDACTION_RULES_FILECustom redaction rules
KUMBU_MCP_HTTP, KUMBU_MCP_ALLOWED_HOSTS, KUMBU_MCP_ALLOWED_ORIGINSEnable /mcp; host and origin allowlists
KUMBU_METRICS_TOKEN32-256 characters; enables /metrics
KUMBU_WORKER_DRAIN_SECONDSWorker shutdown grace, default 60
KUMBU_LOG_LEVELerror, warn or info

On the NAK side: NAK_KUMBU_ENDPOINT (HTTPS, or plain HTTP on loopback; needs NAK_ASSERTION_KEY_FILE and NAK_ASSERTION_KEY_ID), NAK_KUMBU_AUDIENCE and NAK_KUMBU_FORWARD_EVENTS. The CLI reads process environment only; it does not load .env.

Operations

  • MongoDB. A replica set is required: corrections, job leases and deletion use transactions. Atlas Search and Atlas Vector Search are required. A plain local replica set runs tests but cannot make serve ready.
  • Indexes. Run kumbukumbu ensure-indexes, then kumbukumbu serve. serve waits for the search indexes (memories_text_v3, memories_vec_v3) before listening. Drop the _v2 indexes once no older replica runs.
  • Worker. kumbukumbu worker is a separate process and off by default. It leases jobs per subject, renews leases every 20 seconds, checks cited source events, redacts, and retries into dead letters. Enable it only after reviewing the model provider and its data terms.
  • Health. /healthz is liveness. /readyz checks MongoDB, search indexes and, when configured, Vault.
  • Metrics. Prometheus at /metrics with the metrics token: status classes, latency, 401/403/429/503 counts, dependency reachability, jobs by state, oldest pending job age, exports. No tenant or subject labels. Alert on kumbu_dependency_up == 0 and on a growing kumbu_jobs{state="dead_lettered"}.
  • Network. The service does not terminate TLS. In the platform stack it runs on private networks only, under the memory Compose profile.
  • First admin key. kumbukumbu bootstrap-admin-key writes a one-time, short-lived key to a mode-0600 file. Not needed for NAK traffic.

Known limits and status

  • Sandbox beta only. No production personal data.
  • Deletion and backup/restore are not accepted. No restore drill across a Vault key rotation yet.
  • Relationship extraction, conflict review, consolidation, scheduled decay and purge, and re-embedding are not implemented.
  • No storage or compute quotas, route-specific limits or tracing spans. No load or staging evidence on real Atlas.
  • NAK-to-KUMBUKUMBU assertions are tested locally, not yet in staging.
  • No remote embedding provider. Changing embedding dimensions needs a migration.
  • A KIDA token stays valid until it expires, even after a membership change.

Repository docs

PathContent
KUMBUKUMBU/README.mdOverview, build, run
KUMBUKUMBU/docs/USING_KUMBUKUMBU.mdWhat works today, sandbox walkthrough
KUMBUKUMBU/docs/RUNBOOKS.mdOperations: Vault, export, deletion, NAK assertions, metrics
KUMBUKUMBU/docs/IMPLEMENTATION_STATUS.mdShipped behavior and blockers
KUMBUKUMBU/docs/BETA_DEPLOYMENT_GATE.mdBeta restrictions
KUMBUKUMBU/docs/DECISIONS.mdRecorded decisions
KUMBUKUMBU/docs/SRS.mdTarget requirements (not all shipped)
KUMBUKUMBU/docs/PRODUCTION_READINESS_PLAN.mdOrdered backlog
KUMBUKUMBU/docs-site/Engine docs site
NAK/crates/runtime/src/integrations.rsNAK’s memory client and turn forwarding
deploy/compose.yamlPlatform stack (kumbukumbu service)