Skip to main content
This is the default long-running support-agent pattern in current MuBit:
  1. store customer facts, traces, and preferences
  2. assemble context before each response
  3. checkpoint before compaction or risky transitions
  4. reflect after the attempt
  5. record the outcome so the next similar case gets better guidance
  6. archive exact artifacts when later steps need exact reuse instead of only semantic recall

Minimal implementation example

support_agent_memory_loop.py
from mubit import Client
import os

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-agent",
    role="support",
    read_scopes=["fact", "lesson", "rule", "handoff", "feedback"],
    write_scopes=["fact", "trace", "lesson", "handoff", "feedback"],
)

client.remember(
    session_id=run_id,
    agent_id="support-agent",
    content="Customer Taylor prefers concise Friday updates and wants billing fixes summarized in one paragraph.",
    intent="fact",
    metadata={"customer": "taylor", "source": "ticket"},
)

context = client.get_context(
    session_id=run_id,
    query="Draft the next customer-safe update for Taylor.",
    mode="full",
    max_token_budget=700,
)

checkpoint = client.checkpoint(
    session_id=run_id,
    agent_id="support-agent",
    label="pre-response-compaction",
    context_snapshot=context.get("context_block", ""),
    metadata={"stage": "drafting"},
)

archived = client.archive(
    session_id=run_id,
    agent_id="support-agent",
    content="Original billing diff and exact remediation note for ticket-42",
    artifact_kind="billing_postmortem",
    labels=["billing", "exact"],
)

exact = client.dereference(
    session_id=run_id,
    reference_id=archived["reference_id"],
)

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-agent",
        reference_id=lesson_id,
        outcome="success",
        signal=0.8,
        rationale="The customer update matched the stored preference and resolved the billing question cleanly.",
    )

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

print({
    "checkpoint_id": checkpoint.get("checkpoint_id"),
        "lessons_stored": reflection.get("lessons_stored"),
        "strategies": len(strategies.get("strategies", [])),
        "exact_reference_found": exact.get("found"),
    })

What matters operationally

  • get_context is the pre-compaction memory surface.
  • checkpoint preserves the critical context snapshot before the LLM window is compacted.
  • archive plus dereference is the exact-reference path for artifacts that must come back verbatim later.
  • reflect extracts reusable lessons and rules from the run.
  • record_outcome changes later ranking so good lessons appear earlier next time.

Next steps