How Mubit works
How your agents go from stateless to self-improving with Mubit's memory loop.
Mubit is a memory engine for AI agents. It stores what your agents learn, retrieves the right context before each LLM call, and extracts reusable lessons so agents improve over time. Everything runs behind a single control-plane boundary — your agent talks to Mubit, Mubit talks to storage.
Overview
The core loop has four steps:
- Write
Your agent calls
remember()to store facts, traces, or observations as they happen. - Retrieve
Before the next LLM call,
recall()finds relevant evidence andcontext()assembles a token-budgeted context block with rules, lessons, and facts; the wrappers inject it into the system message for you. - Reflect
After a run completes,
reflect()extracts reusable lessons from what happened. Recurring lessons get promoted from run-scoped to session-scoped to global. A freshly reflected lesson may start as a pending candidate and is only promoted to active once its evidence score crosses the acceptance threshold (default 0.6; low-scoring ones are rejected at or below 0.25 and down-weighted), so newly learned lessons are not always surfaced instantly. This validation gate is on by default and can be disabled withMUBIT_CONTROL_LESSON_VALIDATION_ENABLED. - Reinforce
outcome()feeds success/failure signals back into the lesson store, strengthening what worked and weakening what didn't.
Over multiple runs, agents accumulate lessons that make them better at the task — without retraining the LLM.
Component model
Mubit exposes three API surfaces. Most application logic belongs on the control plane.
| Surface | Responsibility | Typical use |
|---|---|---|
control | Memory lifecycle, context assembly, diagnostics, learning loop, coordination, and planning state | Default application path |
core | Direct search, sessions, scratch memory, and specialized low-level primitives | Advanced or specialized features |
auth | User and API key lifecycle | Admin and provisioning workflows |
- Start with the global helpers and the
client.memory,client.snapshots,client.lessonsandclient.outcomesnamespaces. - Introduce
client.raw.invoke("core.<op>", ...)only when you need direct-lane or branch/session primitives. - Keep
client.admin.*out of end-user request handlers.
Execution contract
- Write memory with
client.memory.remember()or rawcontrol.ingest. - If you use raw ingest, poll
client.jobs.get(job_id, run_id=...)untildoneis true before freshness-critical reads. - Read with
client.memory.recall()or assemble context withclient.memory.context(). - Checkpoint before compaction.
- Reflect and record outcomes when the attempt finishes.
Query and context controls that matter
| Control | Why it matters |
|---|---|
run_id | Defines the memory scope |
mode on context | Chooses full, summary, or sectioned context assembly (lane="legacy") |
max_token_budget / budget | Keeps context within the active model budget |
kinds | Restricts retrieval to facts, lessons, rules, traces, and other types |
diagnose / health | Explains weak retrieval and low-quality memory |
Minimal helper-first example
client.memory.remember(
"Customer Taylor prefers concise Friday updates.",
kind="fact",
run_id="support:acme:ticket-42",
agent_id="support-agent",
)
answer = client.memory.recall(
"What preference do we already know for Taylor?",
run_id="support:acme:ticket-42",
)
context = client.memory.context(
"Draft the next response.",
lane="legacy",
mode="summary",
max_token_budget=300,
run_id="support:acme:ticket-42",
)Failure modes and troubleshooting
| Symptom | Root cause | Fix |
|---|---|---|
| Recent write missing from later context | Raw ingest completion was ignored | Gate reads on done or use client.memory.remember() |
| Context is too long or too noisy | No explicit context mode or budget | Use client.memory.context() with budget, or lane="legacy" with mode and max_token_budget |
| The system does not improve across attempts | Reflection or outcomes are missing | Pair client.lessons.reflect() with client.outcomes.record() |
| Security boundary drift | auth or direct core calls leaked into the request path | Keep application logic on the control plane |
Deep dives
Next steps
- Extend the same project with Add data.
- Extend retrieval behavior with Retrieve data.