Skip to main content
This page shows one complete support-agent shape per SDK using the current recommended MuBit flow:
  1. register the agents involved
  2. store facts, traces, and preferences
  3. assemble context before responding
  4. checkpoint before compaction or risky transitions
  5. coordinate specialist review with handoff and feedback
  6. reflect and record outcomes so future cases improve

Environment

.env
MUBIT_API_KEY="mbt_<instance>_<key_id>_<secret>"
MUBIT_ENDPOINT="https://api.mubit.ai"

Full implementation

import os
from mubit import Client

RUN_ID = "support:acme:ticket-42"

client = Client(
    endpoint=os.getenv("MUBIT_ENDPOINT", "https://api.mubit.ai"),
    api_key=os.environ["MUBIT_API_KEY"],
    run_id=RUN_ID,
    transport="http",
)

client.register_agent(session_id=RUN_ID, agent_id="support", role="support")
client.register_agent(session_id=RUN_ID, agent_id="billing", role="billing")

client.remember(
    session_id=RUN_ID,
    agent_id="support",
    content="Customer Taylor wants concise Friday updates and is asking about invoice INV-7781.",
    intent="fact",
    metadata={"customer": "taylor", "ticket": 42},
)
client.remember(
    session_id=RUN_ID,
    agent_id="billing",
    content="Invoice INV-7781 has a stale tax table mismatch on line item 4.",
    intent="trace",
    metadata={"invoice": "INV-7781", "source": "billing-review"},
)

context = client.get_context(
    session_id=RUN_ID,
    query="Draft the next customer-safe update with the billing root cause and next step.",
    mode="full",
    max_token_budget=800,
)

checkpoint = client.checkpoint(
    session_id=RUN_ID,
    agent_id="support",
    label="pre-response-compaction",
    context_snapshot=context.get("context_block", ""),
)

handoff = client.handoff(
    session_id=RUN_ID,
    task_id="ticket-42-billing-review",
    from_agent_id="support",
    to_agent_id="billing",
    content="Confirm the billing root cause for invoice INV-7781 before we reply.",
    requested_action="review",
)
feedback = client.feedback(
    session_id=RUN_ID,
    handoff_id=handoff["handoff_id"],
    from_agent_id="billing",
    verdict="approve",
    comments="Root cause confirmed: stale tax table mismatch on line item 4.",
)

reflection = client.reflect(session_id=RUN_ID)
lessons = client.control.lessons({"run_id": RUN_ID, "limit": 20})
lesson_id = (lessons.get("lessons") or [{}])[0].get("id")
if lesson_id:
    client.record_outcome(
        session_id=RUN_ID,
        agent_id="support",
        reference_id=lesson_id,
        outcome="success",
        signal=0.75,
        rationale="The support response used the stored customer preference and the validated billing root cause.",
    )

strategies = client.surface_strategies(
    session_id=RUN_ID,
    lesson_types=["success", "failure"],
    max_strategies=5,
)

print({
    "checkpoint_id": checkpoint.get("checkpoint_id"),
    "handoff_id": handoff.get("handoff_id"),
    "feedback_id": feedback.get("feedback_id"),
    "lessons_stored": reflection.get("lessons_stored"),
    "strategy_count": len(strategies.get("strategies", [])),
})

Operational notes

  • Start helper-first and drop to raw client.control.* only where helper coverage is intentionally lower, such as explicit lesson listing.
  • mubit.auto is the public zero-friction path if you want Python LLM traces to feed this same memory loop automatically.

Next steps