Skip to main content
Polling is acceptable for simple loops, but event-driven coordination is better when planners and workers need to react to new memory, handoffs, feedback, checkpoints, or outcome updates. The event stream is still a low-level control-plane surface. Keep the public integration model helper-first for memory writes and reads, and use the event stream to wake orchestration logic.

Decision model

Event laneSurfaceUse when
Run-scoped control eventsGET /v2/control/events/subscribeOne workflow should react to ingest, reflection, handoff, feedback, checkpoint, or outcome events
Memory read/write loopremember, recall, getContext, checkpointMost application behavior

Minimal implementation example

event_driven_agents.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",
)

stream = client.control.subscribe({"run_id": run_id})

client.remember(
    session_id=run_id,
    agent_id="planner",
    content="A new adjuster note arrived for claim-42.",
    intent="trace",
)
client.checkpoint(
    session_id=run_id,
    agent_id="planner",
    label="before-adjuster-review",
    context_snapshot="Planner stored the adjuster note and is waiting for review.",
)

for event in stream:
    if event:
        print(event)
        break

Failure modes and troubleshooting

SymptomRoot causeFix
Workers still poll constantlyEvent stream is not wired to the orchestration loopMove wakeup logic to the control stream
Event stream is noisyToo many memory writes without filtering in the workerFilter by event type in the consumer
Recovery is hard after compactionEvents fire but context is not rebuiltRe-read with getContext() after the wakeup

Next steps