SDK Helpers
Explicit helper methods for memory, context assembly, and the learning loop — when you outgrow the mubit.learn drop-in.
The mubit.learn drop-in is the right choice for most readers. Use the helpers below when you need explicit control over what gets stored, when, and under which session/agent identity.
Automatic trace capture via mubit.learn is Python-only. In JS, learn.init gives you lesson injection plus loop closure via feedback(); in Rust, use an explicit learn::LearnSession (enrich_messages / record / end). The helpers on this page exist in all three SDKs.
Helper map
| Method | Purpose | When to reach for it |
|---|---|---|
remember() | Default write path for a single logical memory item | Storing facts, lessons, or observations |
recall() | Answer-oriented retrieval (returns a synthesized final_answer plus evidence and citations) | Asking the memory a question |
get_context() | Assemble a token-budgeted context block to inject into your next LLM call | Before any prompt where memory matters |
archive() | Store an exact artifact with a stable reference_id | Anything you'll need recovered byte-for-byte later |
dereference() | Fetch the exact content for a reference_id | Recover an archived artifact |
reflect() | Extract reusable lessons from session evidence | End of a run/session, or on demand |
lessons() | List lessons with optional filtering | Audit, debugging, surfacing strategies |
checkpoint() | Snapshot memory state with a label | Before compaction or risky transitions |
record_outcome() | Tag a reference_id (and any contributing entry_ids) with success / failure and a rationale | RL-style reinforcement signal |
Minimal usage
The recall() (and query()) response includes a citations array — 0-based indices into evidence marking which items grounded final_answer (empty when the answer cites no specific evidence).
Cross-session recall
recall() queries are scoped to the session by default. To read memory from a different session for the same user:
- Store the memory as a lesson with
lesson_scope="global". - On recall, pass the same
user_idandentry_types=["lesson"].
intent="fact" memories are session-local even if user_id matches. This trips up almost everyone the first time — call it out in your design doc.
Context modes
get_context(mode=...) returns different shapes:
| Mode | Returns | Use when |
|---|---|---|
"full" | Single concatenated context_block string | You want to drop the result straight into a system message |
"summary" | section_summaries[] with top_item_preview per section | You want to render structured context (e.g., a card UI) |
"sections" | Only the explicitly requested sections (pass sections=[...]) | You want to interleave sections with your own prose |
max_token_budget is enforced after assembly. If the budget is too small, the lowest-score evidence is dropped first.
Exact references
archive() and dereference() are the exact-recovery pair. Use them for anything semantic recall is the wrong tool for — original diffs, raw tool outputs, generated SQL you'll re-execute later.
archive() requires the archive_block write scope; dereference() requires the matching read scope. Register your agent with both if it needs to round-trip artifacts.
Reflection and outcomes
reflect() extracts new lessons from the session's traces. record_outcome() is the reinforcement signal — recurring success lessons get promoted from run-scoped to session-scoped to global.
Pass entry_ids to attribute the outcome to every recalled entry that contributed, not just the primary reference_id (which is never double-counted). List each contributing entry — for example the evidence items that citations flagged as grounding the answer you acted on.
When to drop down to client.advanced.* raw methods
Reach for client.advanced.* (Python/JS; in Rust, raw ops are payload-style methods directly on Client, e.g. client.ingest(...)) only when you need:
- Async ingest with explicit job polling (
advanced.ingest+advanced.get_ingest_job). - Raw wire payloads for tooling/observability that needs the full response shape.
- Direct access to
core.*lanes (search, scratch, branching) that the helpers wrap.
Most application code never needs this layer. See the Control HTTP reference for the full surface.