Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content
Runtime calibration

Use runtime calibration from the SDKs

This page is for developers who use the Mubit SDKs, mubit-sdk for Python and @mubit-ai/sdk for TypeScript, to store lessons and report outcomes. It shows the helpers that work against the hosted service, and lists the 1.0.6 helpers that don't, so you don't meet a 403 in production.

The SDKs call the same routes as the API reference lists, on https://api.mubit.ai, with your Mubit key. They read the key from MUBIT_API_KEY. The SDK's session_id is sent as the route's run_id.

pip install mubit-sdk
npm install @mubit-ai/sdk

Helpers that work

TaskPythonTypeScriptRoute
Store an item or a lessonclient.rememberclient.memory.rememberPOST /v2/control/ingest, then GET /v2/control/ingest/jobs/{job_id} while it waits
Store a lessonclient.learnedclient.learnedThe same: remember with intent set to lesson
Report an outcomeclient.record_outcomeclient.memory.recordOutcomePOST /v2/control/outcome
Save a checkpointclient.checkpointclient.memory.checkpointPOST /v2/control/checkpoint
List a run's lessonsclient.lessons.list(lane="legacy", ...)client.lessons.list({ lane: "legacy", ... })POST /v2/control/lessons
Read entries backclient.memory.lookup, client.memory.searchclient.memory.lookup, client.memory.searchPOST /v2/core/lookup, POST /v2/core/search
Check the keyclient.healthclient.auth.healthGET /v2/core/health
Delete a runforget with a session_idforget with a runIdPOST /v2/control/delete_run

Two limits to know:

  • An outcome needs a reference_id. The SDK helpers refuse an empty one, so they report on one entry, not on a whole run. Take the id from the record_id of the finished ingest job that remember returns, or call the route directly to report on the whole run.
  • Pass lane="legacy" to list lessons. Without it, lessons.list asks a route the hosted service doesn't serve.

Store a lesson and report an outcome

Python
import os
from mubit import Mubit
 
client = Mubit(api_key=os.environ["MUBIT_API_KEY"])
run = "support-triage-lessons"
 
job = client.remember(
    content=(
        "A message about being charged twice belongs in the billing category, "
        "not the account category. A reviewer confirmed this on the October invoice case."
    ),
    session_id=run,
    intent="lesson",
    lesson_type="success",
    metadata={"kind": "category-rule", "contract": "v1"},
    idempotency_key="lesson-double-charge-v1",
)
 
# `remember` waits for the ingest job and returns it. Each trace lists the records it wrote.
writes = [w for trace in job.get("traces", []) for w in trace.get("writes", [])]
if writes:
    client.record_outcome(
        session_id=run,
        reference_id=writes[0]["record_id"],
        outcome="success",
        signal=1.0,
        rationale="A reviewer confirmed the billing category.",
        idempotency_key="outcome-ticket-1042",
    )
 
page = client.lessons.list(lane="legacy", run_id=run, limit=10)
print(len(page["lessons"]), "lessons")

Save a checkpoint with client.checkpoint(session_id=..., context_snapshot=..., label=...) in Python, or client.memory.checkpoint({ session_id, context_snapshot, label }) in TypeScript.

Helpers that are not offered on the hosted service

Mubit serves the routes in the API reference and no others. Each SDK 1.0.6 helper below calls a route the hosted service doesn't offer yet, and gets 403 not_in_1_0 or an error that the route doesn't exist. The cause is not your key.

Helper (Python and TypeScript names)What to use instead
recallSearch or look up, then filter the entries in your app, as Recall lessons shows.
Get context (getContext in TypeScript, and the same helper in Python), and memory.context with lane set to legacySearch, and filter in your app. memory.context with its default lane reads approved lessons.
reflect, and lessons.reflectNone. Write lessons yourself from runs you have checked.
diagnoseNone.
dereferenceRead the entry back with look up.
memory.health, and the other health report helper of each SDKhealth checks that your key reaches the service.
forget with a lesson_id, and lessons.deleteDelete a run deletes a whole run. A single lesson can't be deleted yet.
The strategy helpers, including lessons.strategies, and the prompt and skill optimizersNone.
The agent registry, hand-off and feedback helpersNone.
lessons.list without lane="legacy", and the helpers that open a run and send events: init and runs.createList with lane="legacy". The routes the other helpers use aren't served.

TypeScript names are the camelCase forms of the Python names.

Next