Skip to main content

Public unified Mubit SDK with one Client facade

Project description

mubit-sdk

Canonical Python SDK for MuBit.

Install

pip install mubit-sdk

Quickstart

import os

from mubit import Client

client = Client(
    transport=os.getenv("MUBIT_TRANSPORT", "auto"),
    run_id="sdk-python-demo",
    api_key=os.environ["MUBIT_API_KEY"],
)

client.remember(
    session_id="sdk-python-demo",
    agent_id="sdk-quickstart",
    content="If the replay queue stalls, checkpoint before replaying recovery.",
    intent="lesson",
    lesson_type="success",
    lesson_scope="session",
    metadata={"source": "readme"},
)

answer = client.recall(
    session_id="sdk-python-demo",
    query="What should I do before replaying recovery?",
    entry_types=["lesson", "rule"],
)
print(answer.get("final_answer"))

Surface Model

  • Low-level raw APIs remain available on client.auth.*, client.core.*, and client.control.*.
  • High-level helper APIs live on Client:
    • remember
    • recall
    • get_context
    • archive
    • archive_block
    • dereference
    • memory_health
    • diagnose
    • reflect
    • forget
    • checkpoint
    • register_agent
    • list_agents
    • record_outcome
    • surface_strategies
    • handoff
    • feedback
  • Helper APIs use session_id as the ergonomic alias for run_id.

Auto-Capture

The Python package also ships mubit.auto for zero-friction trace capture in MAS learning loops:

from mubit.auto import instrument, observe

instrument()

@observe(name="repair-attempt")
def run_attempt():
    ...

MAS / Learning Loop Example

client.register_agent(
    session_id="sdk-python-demo",
    agent_id="planner",
    role="planner",
    read_scopes=["rule", "lesson", "fact"],
    write_scopes=["lesson", "trace"],
    shared_memory_lanes=["knowledge", "history"],
)

client.checkpoint(
    session_id="sdk-python-demo",
    label="pre-compaction-1",
    context_snapshot="Planner narrowed the failure to token refresh ordering.",
    metadata={"window": 1},
)

strategies = client.surface_strategies(
    session_id="sdk-python-demo",
    lesson_types=["success", "failure"],
    max_strategies=3,
)
print(len(strategies.get("strategies", [])))

Exact References

archived = client.archive(
    session_id="sdk-python-demo",
    artifact_kind="patch_fragment",
    content="--- a/query.py\n+++ b/query.py\n@@ ...",
    labels=["django", "retry"],
    family="patch-repair",
)

exact = client.dereference(
    session_id="sdk-python-demo",
    reference_id=archived["reference_id"],
)
print(exact.get("evidence", {}).get("content"))

Endpoint Resolution

transport defaults to auto (gRPC primary, HTTP fallback).

Endpoint resolution order:

  • explicit endpoint / http_endpoint / grpc_endpoint constructor args
  • env vars MUBIT_ENDPOINT, MUBIT_HTTP_ENDPOINT, MUBIT_GRPC_ENDPOINT
  • shared defaults https://api.mubit.ai and grpc.api.mubit.ai:443

Package Example Lanes

Public adoption scenarios are the primary learning path:

PYTHONPATH=sdk/python/mubit-sdk/src python3 sdk/python/mubit-sdk/examples/public/run_public_examples.py --list
PYTHONPATH=sdk/python/mubit-sdk/src python3 sdk/python/mubit-sdk/examples/public/run_public_examples.py --scenario 01_remember_recall
PYTHONPATH=sdk/python/mubit-sdk/src python3 sdk/python/mubit-sdk/examples/public/run_public_examples.py --scenario 12_auto_capture_observed_loop

Internal raw-smoke scenarios remain available for compatibility and wire-level verification:

PYTHONPATH=sdk/python/mubit-sdk/src python3 sdk/python/mubit-sdk/examples/internal/run_internal_examples.py --list
PYTHONPATH=sdk/python/mubit-sdk/src python3 sdk/python/mubit-sdk/examples/internal/run_internal_examples.py --scenario auth_lifecycle

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mubit_sdk-0.5.0.tar.gz (66.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mubit_sdk-0.5.0-py3-none-any.whl (76.3 kB view details)

Uploaded Python 3

File details

Details for the file mubit_sdk-0.5.0.tar.gz.

File metadata

  • Download URL: mubit_sdk-0.5.0.tar.gz
  • Upload date:
  • Size: 66.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mubit_sdk-0.5.0.tar.gz
Algorithm Hash digest
SHA256 7fd1ffd45289207f0299b9ad4e4ae216cb51a8c4e837cf69d54dc3e10c690241
MD5 7a31f76cb9e42104e9abfd17e5664ec9
BLAKE2b-256 62e142a00bac2eeb80721af749a4c40c4ce07b765be288f20e709514827eca00

See more details on using hashes here.

File details

Details for the file mubit_sdk-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: mubit_sdk-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 76.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for mubit_sdk-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b4abd5343794c672a39fa949f5cc1204ae2890919c669fd485e604a1e3a944a0
MD5 e9ee1b265b5bf45d9e733b00aa2d2f68
BLAKE2b-256 cd5d7c32bd571092d674698bd8b781a41c500641194b3f910185129c7a616c11

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page