# Memory SDK — Mubit
The execution memory primitive.
Write a lesson when a run finishes. Retrieve the relevant ones before the next call. The primitive underneath self-learning agents, self-improving environments, and adaptive tool routers.
## What you build with it
### Agents that get sharper with every run.
Every run writes back what worked, what didn't, and the context that shaped it. The next run retrieves the relevant lessons before calling the model. No retraining, no prompt rewrites.
### Interfaces that adapt to how they're used.
An IDE, a CRM, a support console — when actions inside it write lessons back to memory, the environment learns what users actually want. The next session opens with the right defaults, the right shortcuts, the right surfaced fields.
### Every decision shows what shaped it.
Every call records the lessons it retrieved, the input, and the output in one record. Open any past run and see exactly which lessons drove the result.
## A primitive, not a product
- Off your agent's critical path. Writes queue to a worker and return immediately. Reads run off the critical path — memory never blocks the loop your agent is running in.
- Sits beside your LLM client. Not in front of OpenAI, Anthropic, Bedrock, or Vertex — beside them. No wrapping, no routing required.
- Drops into any agent loop. LangGraph, custom orchestrators, a single Python script — the SDK doesn't care what's around it.
- Self-host or Mubit Cloud. Same SDK, same wire format. Run the memory plane in your VPC if traffic can't leave.
## FAQ
**Why call this a primitive?**
Because it does one thing — give your agent execution memory — and nothing else. You compose it into whatever you're building, instead of buying a finished product around it.
**What does Mubit build on top of it?**
Intelligence turns captured lessons into observability. Actions proposes prompt and skill updates from them. Gateway uses the same memory store on the inference path. Same primitive underneath.
**What does the SDK actually store?**
Short, retrievable summaries of what happened in a run — the input that triggered the agent, the decision it made, the outcome, and any tags you attach. Mubit handles embedding and ranking; you just write the lesson.
**Do I need a vector database?**
No. Memory ships with managed embeddings + ANN retrieval. Point the SDK at your agent ID and you're done — no separate index to provision, scale, or backup.
**How is retrieval ranked?**
A blend of semantic similarity to the current context, recency, and tag match. You can override the ranker per-call if you need custom weighting — e.g. boost failures, demote stale lessons.
**Will it slow my agent down?**
Writes are non-blocking — they queue to a background worker. Reads stay off your agent's critical path too, so memory never blocks the loop it's running in.
**Where is memory stored — my infra or yours?**
Either. Use Mubit Cloud for the fastest setup, or self-host the memory plane in your own region. Same SDK, same APIs, same wire format — switch any time.
**How do I scope memory per-user or per-tenant?**
Lessons carry arbitrary metadata. Pass user_id, tenant_id, env, or anything else to write(), then filter on the same keys in retrieve() — Mubit constrains the result set automatically.