Skip to main content
The MobKit Python SDK provides a typed builder API for starting and managing MobKit runtimes. Apps own policy (who exists, who’s wired, what tools they have). MobKit owns mechanism (spawn, wire, route, reconcile, persist, serve).

Installation

Quick start

Identity-First API

For household-style apps (HomeCore), the identity-first API provides durable lifecycle management. Agents are addressed by stable identities (identity:luka, triage:main), not member IDs.

DispatchInput convenience constructors

Mob-Level API

For direct mob-member operations (discovery-based), the mob handle API is still available. The app-facing surface has three categories. Each is a distinct concern — no method crosses categories.

Comms — deliver work to agents

Returns a SendMessageResult with accepted, member_id, and session_id fields. The message enters the agent’s inbox and is processed by the host loop.

Observation — watch what’s happening

Observation is independent of delivery. Subscribe before or after sending — the stream is continuous.

Structural mob events — durable observability

MobHandle.query_mob_events() and subscribe_mob_events() project every meerkat MobEventKind (25 variants) into a typed envelope preserving mob_id, run_id, step_id, agent_identity, and the full payload.
MobStructuralEvent.cursor is the meerkat ledger cursor — durable across mobkit gateway restarts when the runtime is built with .persistent_state(path). Checkpoint a cursor and resume by passing it as after_seq on the next call.

Flow runs

Returns MobRun carrying the full meerkat ledger projection (step_ledger, failure_ledger, frames keyed by frame id, loops keyed by loop id, loop_iteration_ledger, flow_state, activation_params, schema_version, etc.).

Control plane — manage the runtime

ensure_member() and find_members() both return typed MemberSnapshot objects (single and list[MemberSnapshot] respectively).

Roster — inspect and manage members

Member state is exposed via constants MEMBER_STATE_ACTIVE and MEMBER_STATE_RETIRING, importable from the top-level package.

Common pattern: new user first contact

Per-user agents are durable members, so stand them up on the identity plane — declare them through your roster provider and reconcile — rather than ensure_member-ing them into the mob roster. Identity-plane members get continuity records and resume across restarts; mob-plane members do not.
Reserve ensure_member for ephemeral workers (helpers a parent spawns and an idle-retire label reaps) — the worker plane. See the identity-first doctrine.

Builder pattern

Builder methods

External identity providers follow the Rust gateway’s authoritative path: set .continuity_store(provider), .lease_provider(provider), and .scratch_dir(path) together. The Python callback dispatcher speaks the Rust wire contract for leases (result tags and ttl) and continuity deletes. LeaseProviderProtocol.renew_leases(...) is atomic from the caller’s perspective: raising means no input grant was changed, while every returned renewed or lost result is already committed for that identity. Providers must not commit a replacement grant and then raise. For continuity stores, checkpoint_version is monotonic per identity and continuity generation. A live session rebind changes session_id without resetting the version; only destructive reset advances generation and starts the version stream over. Every explicit .identity_bootstrap_mode(...) call declares identity-first intent and requires .roster(...), including explicit eager mode. Omitting the setter keeps a gateway without a roster on the classic path; a configured roster with no explicit mode retains eager materialization. Gateway memory config accepts {backend: "local_json"} with an optional health_check_endpoint (memory.local_json(...)); the legacy Elephant {backend, endpoint} shape still works but emits a DeprecationWarning. memory(stores=...) is intentionally rejected because the Rust gateway does not accept store lists in mobkit/init. JWT auth is the gateway-supported auth mode; Google/OIDC helpers are not accepted by gateway init today. Agent memory is configured with .agent_memory() and requires .persistent_state(path) plus an identity roster when using the bundled gateway store. Options include realm, selection, max_entries, recall_timeout_ms, recall_failure_policy, and instruction_header; the SDK serializes them to the gateway wire contract. Automatic injection defaults to a 500 ms timeout and skips the memory block if recall fails.

Runtime lifecycle

Session agent builder

Define how agents are built during session creation:

Error hierarchy

All SDK errors inherit from MobKitError:

Advanced API

These methods are available for power users and module-system internals. Most apps should use send, subscribe_agent/subscribe_mob, and status/reconcile instead.

Mobpack authoring

MobHandle wraps the full Flow Editor authoring surface (mobkit/mobpacks/*) with snake_case typed methods — mobpack_templates, mobpack_catalogs, mobpack_validate, mobpack_source, mobpack_export, mobpack_import, mobpack_list, mobpack_get, mobpack_create, mobpack_save, mobpack_delete, mobpack_undo, mobpack_redo, mobpack_apply_operation, mobpack_deploy_command, and mobpack_deploy. The same wrappers exist on the SDK’s typed JSON-RPC clients.
mobpack_deploy(document, execute=True) writes the archive and runs rkat mob run on the host — gated by the surface’s advertised authoring_capabilities and, on ABAC-enforced runtimes, the caller’s mobpack.deploy grant. See the Flow Editor guide.

Public surface exports

Everything below is importable directly from meerkat_mobkit:
Module authoring helpers (ModuleSpec, define_module, etc.) live in meerkat_mobkit.helpers — not top-level.

See also