Skip to main content
When planner state stays in app memory, debugging and replay are fragile. MuBit lets you persist goal structure and decision history next to the memory the planner is using.

Mental model

  1. Register planner identity.
  2. Create a goal tree.
  3. Record actions and reasoning cycles.
  4. Save checkpoints before major transitions.
  5. Retrieve the goal tree and action history when you need to replay or diagnose the run.

Minimal implementation example

stateful_task_tree.py
from mubit import Client
import os

run_id = "claims:planner:claim-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="planner", role="planner")

parent_goal = client.control.add_goal({
    "run_id": run_id,
    "description": "Resolve claim-42 with a policy-safe decision",
    "priority": "critical",
})
client.control.add_goal({
    "run_id": run_id,
    "description": "Verify rental reimbursement coverage",
    "priority": "high",
    "parent_goal_id": parent_goal.get("id", ""),
})

client.control.submit_action({
    "run_id": run_id,
    "agent_id": "planner",
    "action_type": "retrieve",
    "action_json": '{"query":"collect coverage and fraud signals"}',
})
client.control.run_cycle({
    "run_id": run_id,
    "agent_id": "planner",
    "candidates": [{
        "action_type": "reason",
        "action_json": '{"prompt":"pick the safest next verification step"}',
        "score": 0.88,
        "rationale": "coverage confirmation should happen before settlement drafting",
    }],
})

client.checkpoint(
    session_id=run_id,
    agent_id="planner",
    label="after-goal-tree-build",
    context_snapshot="Planner built the first goal tree and recorded an initial decision cycle.",
)

goal_tree = client.control.get_goal_tree({"run_id": run_id})
actions = client.control.get_action_log({"run_id": run_id, "limit": 20})

print({
    "goal_nodes": len(goal_tree.get("goals", [])),
    "actions": len(actions.get("entries", [])),
})

Failure modes and troubleshooting

SymptomRoot causeFix
Planner decisions are hard to replayActions and cycles were not storedRecord both action logs and cycle history
Goal hierarchy becomes flat and noisyParent-child goals were not usedBuild explicit goal trees and read them through goals/tree
Compaction loses planner intentNo checkpoint before the transitionSave checkpoints at major decision boundaries

Next steps