Overview
Retrieve
Before the next LLM call,
recall() finds relevant evidence and getContext() assembles a token-budgeted context block with rules, lessons, and facts.Reflect
After a run completes,
reflect() extracts reusable lessons from what happened. Recurring lessons get promoted from run-scoped to session-scoped to global.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 helper-first control usage:
remember,recall,getContext,checkpoint,reflect,recordOutcome. - Introduce
core.*only when you need direct-lane or branch/session primitives. - Keep
auth.*out of end-user request handlers.
Execution contract
- Write memory with
remember()or rawcontrol.ingest. - If you use raw ingest, poll
control.get_ingest_jobuntildone=truebefore freshness-critical reads. - Read with
recall()or assemble context withgetContext()/get_context(). - Checkpoint before compaction.
- Reflect and record outcomes when the attempt finishes.
Query and context controls that matter
| Control | Why it matters |
|---|---|
run_id / session_id | Defines the memory scope |
mode on context | Chooses full, summary, or sectioned context assembly |
max_token_budget | Keeps context within the active model budget |
entry_types | Restricts retrieval to facts, lessons, rules, traces, and other types |
diagnose / memory_health | Explains weak retrieval and low-quality memory |
Minimal helper-first example
helper_flow.py
Failure modes and troubleshooting
| Symptom | Root cause | Fix |
|---|---|---|
| Recent write missing from later context | Raw ingest completion was ignored | Gate reads on done=true or use remember() |
| Context is too long or too noisy | No explicit context mode or budget | Use getContext() / get_context() with mode and max_token_budget |
| The system does not improve across attempts | Reflection or outcomes are missing | Pair reflect() with recordOutcome() |
| 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.