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.2.tar.gz (68.0 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.2-py3-none-any.whl (77.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mubit_sdk-0.5.2.tar.gz
  • Upload date:
  • Size: 68.0 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.2.tar.gz
Algorithm Hash digest
SHA256 dfeb7cafa6d11bce6bb9b69f0b7b73b7284194e1bbae04bc4d0a2d7e91e11ccf
MD5 52041469323b1bf52da9cdc6683cd1db
BLAKE2b-256 7c4c6602258aa80b3628414e8e779e946e876f257d2a1c1af2e5b62ac0854416

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mubit_sdk-0.5.2-py3-none-any.whl
  • Upload date:
  • Size: 77.5 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 5717e5223a7d8b6c6d877f8b1287873928f6e7a1bfe77faf819718c791c75fdc
MD5 70f4acae057751d8d60d6492f2d4374d
BLAKE2b-256 352b0c82f05727211d97a714670d7835bd0e64719268589987f123c341b49ab7

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