meerkat-mob remain authoritative for agent execution, identity, membership,
lifecycle, and wiring; Meta packages gateway startup, provider adapters,
operational modules, persistence projections, and operator surfaces.
Installation
The wheel is client-only and does not contain
rpc_gateway. Download
meta-rpc-gateway-<version>-<target>.tar.gz for Unix or macOS, or
meta-rpc-gateway-<version>-<target>.zip for Windows, and extract its
rpc_gateway binary (rpc_gateway.exe on Windows). Alternatively, follow the
source-build instructions. Pass that binary’s path to
.gateway(...). Linux x86_64 and aarch64 and macOS arm64 archives are
published with the release and listed in index.json and checksums.sha256;
macOS x86_64 and Windows archives may arrive later, listed in
index-trailing.json and checksums-trailing.sha256.Quick start
For a complete application that tracks its own turns and keeps its agents across restarts, see the supervised Python example. In a fresh project directory, createconfig/mob.toml:
external_addressable = true lets a caller outside the mob, such as the
script below, send to members of the profile. It is false by default, and
handle.send is then refused with
mob member is not externally addressable: agent-1. comms = true is
needed by every profile a member is built from, also for a single agent
with no peers (see
Mob profile tools).
Set OPENAI_API_KEY in your environment for the model above, or choose a
supported model and its matching provider credentials. Run the following
script from that project directory, replacing /path/to/rpc_gateway with
the binary you installed. Profiles are templates, not pre-created members,
so the example explicitly creates an ephemeral worker before sending.
ensure_member line and replace the
handle.send(...) line and the watch loop: read the member’s tokens_used
before the send, then wait until it is greater:
tokens_used grows once per run, when the run ends, and only for a run that
called the model and whose provider reported usage: a run that fails before
that, or a provider that reports no usage, ends this wait in the
TimeoutError. It counts every run of the member, whoever started it, so the
wait shows that a run ended, not that yours did; in this sample nothing else
sends to agent-1. status.status and status.is_final describe the
member, not the run.
Confirmed by runs on the published 0.9.14 packages: the count changes once,
when a run ends, also for a run with tool calls, and a run the provider
refused left it unchanged. Read from the source: a provider that reports no
usage adds nothing, and a run started by another sender (a peer or a schedule)
counts as well.
Durable detached tools
Declare long-running host work explicitly instead of holdingcallback/call_tool open:
ctx.requester is the requester of the run that submitted the job (see
Who a tool call serves), recorded with the job, or
None when that run had none.
Who a tool call serves
A tool handler that declares arequester parameter receives the original
requester of the run the call serves (ToolCallRequester): its principal
(kind, id, and trust_domain_id when it is qualified) and carried,
true when the run’s work reached the agent through another actor, such as a
peer hop. A person the Meta console authenticated appears with
trust_domain_id oidc-issuer: followed by the token’s issuer; a
run without a requester passes None. The runtime sets it, never the
arguments, so a tool that acts in one person’s name can refuse everyone else:
requester parameter is called with the arguments alone.
Identity-First API
For apps with durable agent identities, the identity-first API provides durable lifecycle management. Agents are addressed by stable identities (identity:alice, triage:main), not member IDs.
send_and_wait, dispatch_and_wait and dispatch_text_and_wait are
per-admission: the runtime mints a turn ticket for the delivery and keeps the
admitted turn’s own completion handle under it, and the wait reads
meta/turn_result for that ticket, which reports that turn’s own output
from its committed run result. A failed turn raises TurnFailedError, and a
ticket the gateway does not know (for example after a gateway restart) raises
TurnUnknownError. Text cut at the 256 KiB bound emits
TurnOutputTruncatedWarning; a turn that completed without output of its own
(the runtime folded it into a run in progress, or deduplicated it) returns
None with TurnOutputUnavailableWarning. wait_for_turn returns the typed
TurnResult (output_status, output, output_truncated) instead.
send_and_wait_outcome, dispatch_and_wait_outcome and
dispatch_text_and_wait_outcome take the same arguments and return the typed
AwaitedTurn: text, attributed (whether the text provably belongs to this
delivery’s turn), admission, ticket, output_status and untracked_code.
The plain methods return its text.
The delivery happens exactly once and the call never resends. Every failure
after admission carries the send/dispatch result as admission, so the
caller keeps the receipt instead of redispatching the work:
- No turn ticket (any delivered
turn_unavailable.code, below, or a gateway that predates turn tickets): the call waits on the identity-wide completion cursor and emitsTurnTrackingUnavailableWarningnaming the code. That result is NOT attributed: another delivery’s completion can satisfy the wait, and the text is the session’s latest output. The outcome’sattributedisFalseanduntracked_codecarries the code.require_attribution=TrueraisesTurnTrackingUnavailableError(withcodeandreason) in every untracked case instead. - The exact-ticket wait fails for a transport or RPC reason (for example
observation_lane_saturated): only that ticket’s observation is retried, with bounded backoff, untiltimeout; thenPostAdmissionObservationErrorcarriesadmission,ticketand the last failure as__cause__. Read the turn later withwait_for_turn(ticket). - Every other error after admission keeps its type and carries
admission(andticket,Nonewhen untracked):TurnFailedError,TurnUnknownError,WaitEndedError, the identity-wide wait’s missing-baseline, superseded-incarnation and live-aliasRuntimeErrors, the persistent transport’s plainRuntimeErroron a response timeout or closed stdout, a caller’sasyncio.CancelledError(the same instance, re-raised), and an SDK warning a caller escalated withfilterwarnings("error"). A wait still pending attimeoutraisesTurnWaitTimeoutError, aTimeoutErrorthat also carriesadmissionandticket. The one exception is a custom exception type that rejects attribute assignment, which cannot carry the fields and still propagates unchanged.
turn_unavailable.code says why a turn could not be tracked. Every
code but not_delivered means the delivery still happened, exactly once:
autonomous_host: the member runs inautonomous_hostmode (the default), read from the runtime’s live roster entry, so a profile or override changed without a respawn does not count until the member respawns. The runtime reports no per-turn completion for autonomous inbox delivery, so on these members a per-admission wait is unavailable.runtime_refused: the runtime refused per-turn completion for the member’s live mode for another reason.externally_bound,host_human_input,bridge_cannot_report_output.- A gateway that predates turn tickets returns no
turn_unavailableat all.
not_delivered means nothing was delivered (no session bridge or no bound
runtime), so the call raises TurnNotDeliveredError instead of waiting
(nothing ran, so a retry is safe). session_rotated means a re-dispatch
landed on a different session after a repair or respawn and ran as its own
turn. Run a member with
runtime_mode = "turn_driven" for per-admission results.
Do not mix ticket waits and cursor waits on one identity: a ticket can settle
before the identity health monitor counts the same turn on the cursor, so a
later wait_for_output(after=baseline) can be satisfied by an earlier
send_and_wait turn.
wait_for_completion(baseline) and wait_for_output(after=cursor) remain
identity-wide primitives: any completion on the identity after the baseline
satisfies them, and the returned output_preview is the session’s latest
output, not necessarily a specific send’s answer. Use wait_for_turn(ticket)
or wait_for_output(turn=ticket) to wait for one specific turn.
The recommended completion barrier is track_turn=True plus
wait_for_turn(ticket) (or send_and_wait): it reads only the ticket ledger.
Every wait is server-side and event-driven: wait_for_turn is one
meta/wait_for_turn request, and the identity-wide waits
(wait_for_completion, wait_for_output(after=...), rt.wait_until_ready)
are one meta/wait_for_completion request each. The gateway answers when
the ticket settles or a completion is recorded, so nothing polls, and the
member’s output is read once, at completion. timeout is only the deadline;
poll_interval applies only against a gateway that predates the server-side
waits. completion_cursor() is a one-shot cursor read that never touches the
member session. inspect() does read the member session, so do not poll it.
A wait that ends before a completion (a failed or cancelled run, a broken,
retiring or deleted identity, or gateway shutdown) raises the typed
WaitEndedError, whose outcome names why; only the deadline raises
TimeoutError.
DurableAgentSpec fields
The roster provider returns oneDurableAgentSpec per identity. The SDK
serializes the shared wire shape that Rust deserializes: identity, profile,
addressability, labels, and additional_instructions are always included,
even at their defaults. Optional fields whose value is None are omitted,
including unset runtime_mode_override and initial_message.
Roster provider context
The gateway callsroster(context) with a typed RosterContext
(meerkat_meta.identity_first_models.RosterContext), a one-to-one mirror of
the Rust struct:
DispatchInput convenience constructors
In the releasedmeerkat-meta 0.9.19 SDK, use DispatchInput.connector for an
unkeyed connector event. For a keyed event, use the full DispatchInput
constructor: the 0.9.19 helper does not accept idempotency_key.
idempotency_key and correlation_id go together: a repeat of the same
pair to the same identity starts no second turn in its session, and a
dispatch that carries one of the two without the other is refused with
nothing delivered (invalid delivery identity (... (half-pair))).
In the development SDK (not 0.9.19), DispatchInput.connector also takes
idempotency_key, so a keyed connector input can be built with the helper.
It sends the supplied values as given.
Different deliveries may use distinct idempotency keys with the same
correlation ID. The full constructor and dispatch_text also accept the
pair; the gateway refuses a half pair from any of the three. On a dispatch without
expected_scope, with the connector or system origin a correlation id
that is not a canonical UUID is turned into one deterministically, and the
gateway carries that UUID, not the source string; with another origin give
a canonical UUID. With expected_scope the pair is used as supplied and
nothing is turned into a UUID: give a canonical UUID whatever the origin.
Scope-bound dispatch
A host that must never admit a delivery to a session other than the one it recorded captures the identity’s scope fromstatus(), persists it, and
dispatches against it. A moved scope raises StaleScopeError with nothing
submitted; a lost reply is recovered from the scope’s original session.
expected_scope needs both idempotency_key and correlation_id, does not
combine with track_turn, and applies no delivery preparation. A scope with
an unknown version raises ContractMismatchError from
DeliveryScope.from_dict; in status() it leaves delivery_scope None and
the rest of the status usable. recover_delivery returns ScopedRecovery
with state ABSENT, IN_FLIGHT (durable_witness), COMPLETED
(output_status, output), FAILED, TERMINAL_WITHOUT_RUN, BROKEN or
UNRESOLVED (cause); a state this SDK does not know reads as UNRESOLVED,
never ABSENT. See Scope-bound dispatch.
Scoped tool grants
A profile’stools.grant_gated mounts tools closed on every build of its
members; a grant to an identity opens one for a fixed window, across the
member’s respawns and the gateway’s restarts. The grant wakes nothing and
applies at the member’s next model request.
tool and family, and exactly one of duration_ms
and expires_at_ms. A grant answers applies, whether it applies to the
member’s running build, and a list answers the member’s gate (none for a
retired identity); both are advisory. Every refusal raises
ToolGrantRequestRefusedError; its kinds are
TOOL_GRANT_REQUEST_REFUSAL_KINDS. See
Scoped tool grants.
Long-term agents
runtime.identities reads and changes the mob’s long-term agents, one call
per meta/identity/* host method. Every agent is read and changed the same
way, whoever asked for it and by whatever route it came to exist. The
guide walks through adopting an agent your
configuration declares.
An
archive or a remove of an agent that still owns mobs it created is
refused owns_mobs: have the agent destroy them first (see
meta/identity/archive).
A change needs your request_id: the same id and request return the same
state and commit at most once. expected_spec_digest is the agent’s
spec_digest as you read it. There is one spec digest on every surface: the
same value in list, get, an outcome and stale_spec’s current_digest.
An outcome is IdentityDone (operation_id, agents),
IdentityPendingDecision (operation_id, decision_id, deadline_ms) or
IdentityPendingPreparation; each has .outcome, its token. A held decision
is a normal answer. The SDK does not poll: read operation when you want the
state. Each AgentOutcome carries the agent’s spec_digest afterwards, a
create’s seat (seated or owed) and an update’s instructions
(InstructionOutcome: applies_at_next_run, applies_after_compaction,
applies_at_next_session with a reason, or unchanged).
applies_after_compaction is a change that waits: the agent’s model takes a
system instruction only ahead of the conversation, and a short conversation
may never reach the compaction that brings it into effect. rt.reset(name)
does, and gives the agent’s conversation up. rt.instruction_status is the
authority for whether a change is in effect; see
Changing an agent’s instructions.
The first answer of an archive, an unarchive and a remove also carries
the agent’s schedules (SchedulesFollowed: effect, count,
schedules of ScheduleRef(schedule_id, name), incomplete): how the
agent’s schedules stand after the change. After an archive the list is the
schedules paused for the agent; after an unarchive, its schedules that are
active after the call (one somebody resumed by name meanwhile included);
after a removal, the ended ones. The gateway gives your host the list; a
caller that is not given it (an agent that asks for the change, a Console
caller without runtime.admin) is told the effect and the count only,
and such an answer reads as an empty schedules with its count kept. A
replay of the request and an operation read state none, so compare a
retry by operation_id and each agent’s state and spec_digest, not
whole. IdentityChangePlan.schedules carries the list a planned change
would answer.
AgentSpec and AgentSet take addressability (addressable,
internal_only) and runtime_mode_override (autonomous_host,
turn_driven), the members and values of a roster row; AgentSummary and
AgentRecord read both back, each None when it is the default.
A create of an agent of a profile whose preparation the policy names
required returns IdentityPendingPreparation: prepare what the agent
needs, then settle_preparation(name, request_id=...) seats it. An agent
that awaits none refuses preparation_not_pending.
IdentityStatus.roster_listing_superseded (runtime.status(name)) is
True when the host’s roster lists a name whose agent is served from its
record, an adopted agent your roster still lists for one: the roster’s
entry is not applied. get, list, the directory and the plan of a change
of such an agent read the same member (AgentSummary, AgentRecord,
DirectoryPeer, IdentityChangePlan). IdentityStatus.archived is True
while the agent
is archived, and IdentityStatus.preparation_pending while it waits for
its host’s preparation; the gateway writes each only when it is so. An
agent’s spec digest, provenance and open_operations are read with get
and list: open_operations names its create while it waits for its
host, and each change of it that is held or approved and not yet carried
out, and is empty when nothing is open.
Every refusal of every call raises IdentityRefusedError (-32058); its
kinds are the closed vocabulary IDENTITY_REFUSAL_KINDS. A kind newer than
the SDK is the same error with known_kind false. Only operation answers a
refusal as a value. An archive or a remove of an agent that still owns
mobs it created is refused owns_mobs, and nothing is changed: details
holds count (how many mobs) and mobs (their ids, given to this host;
a caller that is not given them reads may_be_incomplete in their place),
and the remedy is to have the agent destroy its mobs first, or to keep the
agent. A candidate
launch refuses a change with the gateway-wide
AnnouncementRefusedError (kind candidate_launch). Advisory values
(readiness, a change’s state, provenance, directory verdicts) are kept as
the gateway sent them.
The gateway changes agents only under the host’s policy:
MetaBuilder.identity_creation(policy) sends it as
runtime_options.identity_creation. Without one every change is refused
change_denied. The outcomes of this release are allow, require_approval
and deny; a policy that names notify or review is refused at init. See
the policy reference and, for the methods
themselves, Agent changes.
A 0.9.15 client against a 0.9.14 gateway was exercised in one keyless run
only (the Meta Python SDK’s own tests that start a real gateway without a
provider key, against a gateway built at the 0.9.14 commit); no other client
and no 0.9.14 runtime was exercised. Of the tests in that run that start a
real gateway, the five that existed at 0.9.14 and need no provider key
passed; the failures were in tests new in 0.9.15 (the identity methods and
cross-mob delivery between gateways) or in tests that need a provider key.
The methods for agents created at run time (meta/identity) need a 0.9.15
gateway: upgrade the gateway before the SDKs that call them.
Realm MCP administration
The stdio gateway lets its host administer the installation realm’s own MCP servers and the secret values of their stdio servers’secret_env slots,
kept in the launch’s provider credential store:
set_secret request, and never appears in an
answer, an exception or a log record. A launch whose credential store did not
open answers the secret methods RealmMcpUnavailableError; a write whose
result is unknown raises RealmMcpOutcomeUnknownError. See
Realm MCP administration.
Operator instructions
Standing instructions for the members of the gateway’s mob: the host writes one body per slot (anamespace it owns and a key) at a revision, for
every member, the members of one profile, or one identity. Each member it
selects applies the instruction at its next run start, never inside a run.
Host methods only: no agent tool sets, revokes or reads them.
RpcError with
data["instruction_set_code"] (for example stale_revision). A member
target is for that member alone. From 0.9.15 Meerkat has include_forks, a
record for a member and its forks: set_instruction refuses a target that
carries it, and such a record is written by a Rust host that embeds Meta,
through the mob handle’s set_operator_instruction (instruction_status
shows it). The status
read never wakes a member and names each member by its identity; its
advisory values (a pending or blocked reason, residency) may be new to
this SDK, so keep them as they are. These replace
activate_member_instruction (meta/member_activate_instruction,
deprecated since 0.9.11). See
Operator instructions.
Compacting a member’s conversation
From 0.9.15.compact_member compacts a member’s conversation now: the
member runs one maintenance turn in which the older turns are summarized and
the most recent ones are kept. It costs one model turn and two in-place
rebuilds of the member, one before that turn and one after it, on the same
conversation.
A meta/compact_member call that is admitted rebuilds the identity, whether
it then compacts, compacts nothing or fails. On a 0.9.15 gateway a completed
call keeps an identity’s listing and management of the mobs it created with
its own tools (one run; a call that times out, or completes without
compacting, rebuilds by the same step: read from the source, not run), unless
the same-session step does not serve its member (see Known limitations in
Meta’s changelog, the entry on the loss of an identity’s mobs after a
respawn); against a gateway on 0.9.9 through 0.9.14 the call costs it that,
and upgrading does not give it back (see the meta/compact_member section of
the RPC reference). Where the cost applies, have the identity destroy a mob
it created before the call if it must not be left running unmanaged.
Call it against a 0.9.15 gateway: on 0.9.9 through 0.9.14 a call that fails
leaves the agent with the call’s low compaction threshold.
It is a host method only (meta/compact_member): the Console’s RPC route
does not forward it.
instructions outcome is applies_after_compaction, because
the member’s model takes a system instruction only ahead of the
conversation.
floor_tokens is the member’s compaction threshold for that one turn
(gateway default 1024 tokens). A conversation shorter than the floor is left
as it is, so always check the result’s compaction_applied: False means
the conversation holds no fewer messages than before the call. timeout
(seconds, gateway default 60) is how long the gateway watches the
maintenance turn; past it the call raises even if the compaction completes
later. The gateway holds the call for longer than timeout, so the call
waits for the reply for timeout plus 30 seconds, whatever the transport’s
own request timeout is.
The result is the gateway’s, as it is: identity, session_id,
floor_tokens, messages_before, messages_after, compaction_applied,
head_revision and last_rewrite_reason. A failure raises RpcError whose
data["kind"] names it, for example compact_member_busy,
compact_member_timeout or compact_member_completion_failed, with
data["stage"] and data["operation_id"]. See
meta/compact_member.
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
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
Structural mob events — durable observability
MobHandle.query_mob_events() and subscribe_mob_events() project
every current Meerkat MobEventKind 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 meta 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
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
MemberSnapshot exposes agent_identity, role, state, wired_to, and
labels. Known state strings are exported from the top-level package as
MEMBER_STATE_ACTIVE, MEMBER_STATE_RETIRING, MEMBER_STATE_BROKEN,
MEMBER_STATE_COMPLETED, and MEMBER_STATE_UNKNOWN. The underlying Rust
status enum is non-exhaustive, so consumers should tolerate future state
strings.
More than one mob on a gateway
A gateway hosts the mob its launch names and can host more.runtime.mob_handle()
is the handle of the launch’s own mob. runtime.mob(mob_id) is the same
MobHandle for a mob named by its id, and runtime.mobs creates, lists and
reads the mobs of the host, and stops, resumes, redefines and destroys them.
runtime.mobs has seven calls, and each asks the
gateway every time: the SDK keeps no list of mobs and no state of one.
A
HostedMob has mob_id, default (true for the mob the launch names) and
state, and when the gateway sent them provenance, failure,
quarantine and revision. state says where the mob stands. creating,
running, completed and destroyed are the lifecycle of a loaded mob.
stopped is the mob’s own stop and holds whether the host has the mob
loaded or not: the host’s records keep it, across a restart too. dormant
says that the host knows the mob, has not loaded it and does not know it as
stopped. quarantined says that its store could not be opened or restored,
and held that a mob one of the host’s agents created waits for its owner.
The list
(HOSTED_MOB_STATES) is open: a state newer than this SDK is kept as its
text and known_state is false, so read state as advice. provenance
(the kind of the mob’s creation record: host, member or another kind)
is None for a quarantined or held mob, and for a mob that is not loaded
and whose store the host has not read yet: for a short time after a start
such a mob reads dormant, a stopped one too, until the host has read its
store, which it does by itself.
mobs.list loads nothing: it answers from the host’s records. mobs.get
loads the mob it names when the host created it and it is not loaded, as its
store has it: a stopped mob loads stopped, no agent of it runs and nothing is
started. A mob one of the host’s agents created is answered from the records
and is not loaded by a get. A load that fails raises what a lifecycle of
that mob would raise, unless the host’s records show what became of the mob:
a store that cannot be opened is kept quarantined, and the entry says so.
revision is the revision of the mob’s definition: a whole number that every
committed redefinition advances. A mob that was never redefined reports the
revision its create recorded. mobs.get carries it for a loaded mob, which a
mob the host created is after a get, and so does the entry in a create,
lifecycle or redefine answer; an entry of mobs.list never carries it,
and a quarantined or held mob has None.
mobs.get(mob_id).revision before a redefine and pass it as
expected_revision: the get loads a mob the host created, so its entry
carries the revision. A quarantined or held mob has none.
Is a mob idle. mobs.standing(mob_id) returns Meerkat’s own standing of
the mob as a MobStanding: mob_id, standing, reason, causes (a
tuple), counts (MobStandingCounts, or None for a mob that has no
actor to ask) and composed (MobStandingComposed, or None).
is_idle is true for the word idle and for no other: nothing is in flight
in the mob and every piece of evidence of that was read. busy is a mob with
work in flight or owed (counts.runs counts member turns and flow runs).
unknown is a mob with nothing counted in flight whose evidence was not all
read: causes names each missing piece and is never empty for it. A mob
whose member created or owns another mob with members says unknown with
owned_mob_members_unread by itself: its own read does not read the members
of a mob its members own. A mob that a member created stays below this mob
after that member was retired, for as long as it exists. The host serves
those mobs too and reads them
together: when it could read them all, it answers idle when all are quiet
or busy when one of them is working, and the answer carries composed
with what the mob’s own observation said (own_standing, which is unknown
or idle, and own_causes); counts stay the asked mob’s own. When it
could not read them all, the answer is unknown with
owned_mob_members_unread and no composed.
Read the causes of an answer from causes alone: composed.own_causes are
not causes of the answer. A mob that is not
loaded reads dormant, or stopped when the host’s records keep its stop,
without counts, and nothing is loaded for the call. standing, reason and
causes are open lists (MOB_STANDINGS, MOB_STANDING_REASONS,
MOB_UNKNOWN_CAUSES): a word newer than this SDK is kept as its text,
known_standing is false for such a standing, and it never reads as idle.
The call asks a loaded mob’s actor once (a mob whose members own mobs is
read together with the loaded mobs they own, each asked once or twice), and
the gateway bounds the wait for one answer
at five seconds. The stdio gateway answers its host Meerkat’s verdict. A
Console answers that verdict to an administrator of the access
configuration; every other caller reads, for a loaded mob, unknown with
the one cause members_not_visible and no counts, whatever the mob holds
and whatever its members are doing or own. The call needs the gateway’s mob_standing feature capability
(supports_mob_standing) beside hosted_mobs; an earlier gateway has
neither the capability nor the method, and the call raises
CapabilityUnavailableError without sending anything.
The calls need the gateway’s hosted_mobs feature capability
(supports_hosted_mobs). Their own refusals raise MobHostingRefusedError
(code -32059) with kind, mob_id, retryable and detail. The kinds
(MOB_HOSTING_REFUSAL_KINDS) are a closed list: mob_exists (a create under
an id a mob of the host has, loaded or not), invalid_mob_id,
default_mob (a destroy, a redefinition, a stop or a resume of the mob the
launch names), mob_not_stopped
(a redefinition of a mob that is not stopped: stop the mob, redefine it,
resume it) and mob_busy (a redefinition of a stopped mob that still holds
something: the one kind with retryable true; its detail ends with
held: and one closed word for each thing held, work, roster or
owner, or the word unanswered). A kind newer than this
SDK is still this error, with known_kind false.
lifecycle, redefine and destroy name their mob themselves: there is no
default, so none of them can reach the launch’s own mob by omission. A stop
and a resume are the mob’s own. The launch’s own mob is not stopped or
resumed through lifecycle (default_mob): its host stops it by its own
means. A
storage refusal with code -32014 raises StorageResolutionError, even
when it carries no structured data; the error keeps its message and code.
These answers remain plain RpcError with their data: a mob the host does
not have (foreign_mob_target), a mob whose store did not load
(mob_quarantined; such a mob cannot be destroyed through destroy). A
call that lacks what the wire requires (an id or a definition that is not
text, another action, a revision that is not
a whole number or is negative) is refused before anything is sent, with a
TypeError or a ValueError. An answer the SDK cannot read raises
ContractMismatchError instead, so the two are told apart: the request was
sent and the gateway acted on it. That is an answer without its entry, its
id or a member of its receipt, a stop answered without its stop report, and
a report that is not an object.
A handle for a named mob. Obtaining runtime.mob(mob_id) sends nothing
and loads nothing, and it does not say whether the host has such a mob. Every
call of the handle then carries mob_id: in each JSON-RPC request, in the
multipart upload of send with attachments and upload_blob, and as
?mob_id= on the streams of subscribe_agent and subscribe_mob. A call on
a mob the host does not have raises a plain RpcError (-32602, data kind
foreign_mob_target). handle.mob_id is the id, and None on the handle of
the launch’s own mob, whose requests name no mob, as before.
A method with a mob_id of its own keeps it: the announcement methods that
take mob_id (announce, announcement_get, announcement_audit_list and
the announcement_source_* methods), query_events(mob_id=...) and an
EventQuery.mob_id send the value you pass, and the handle’s id when you
pass none.
The agent memory calls of a handle send realm beside the mob when you give
one, as you gave it, and leave it out otherwise: the gateway then takes the
memory realm of the mob the request names.
A gateway of an earlier release ignores mob_id and answers for its own mob.
So a named handle first reads the gateway’s mob_addressing feature
capability (supports_mob_addressing), once per started gateway, and without
it every call raises CapabilityUnavailableError and nothing else is sent.
The handle of the launch’s own mob reads it before one call only, a
query_events that names a mob, and refuses that query without it: such a
gateway would answer the query without an error and for its own mob.
runtime.jobs, runtime.monitors, the realm MCP calls and
runtime.list_identities() are the host’s whichever mob is named; they stay
on the runtime.
Providers under a host with more than one mob. The three callbacks that
build a member name the member’s mob: customize_build’s
AgentBuildContext.mob_id, after_create’s context (mob_id), and the
context a topology provider’s compute_edges is given (mob_id). A host
that names none serves its own mob only, and the value is None (absent in
the topology context). In the two context classes mob_id is given by
keyword only. A mob_id that is not text is refused: the callback answers
an error (ContractMismatchError) and the customizer or the provider is
not asked. The callback tools a customizer registers with
draft.register_tool are kept per mob and identity, so a build of
analyst in one mob leaves the tools of analyst in another in place. An
SDK older than this one keeps them per identity name alone: under a host
with two mobs, a build of a member in one mob releases the callback tools of
the member with the same name in the other. A mob created under the id of a
destroyed mob starts with none of that mob’s callback tools: the gateway
names each mob’s incarnation with the build (mob_incarnation beside
mob_id), and the first member build of the later mob releases every tool
kept under that mob id.
Cross-mob peering (two gateways)
From 0.9.15. Through 0.9.14wire_cross_mob wired nothing, and the Python builder had no member_comms_tcp.
wire_cross_mob(local_member_id, remote_member_id, remote_handle) wires a
member of this mob and a member of another mob to each other, so the two
agents can send each other ordinary peer messages with their comms send
tool. Every MetaRuntime starts its own gateway process, so two mob handles
are normally two processes: give the members of both gateways a socket
endpoint with .member_comms_tcp() on each builder.
peer_info on both sides and calls wire_local on each
side. peer_info answers member_id, mob_id, comms_name, peer_id,
address (the in-process address), pubkey_b64 (the member’s own transport
key) and, only for a member with a socket endpoint, dialable_address. When
both answers carry dialable_address, each side is wired to the other by
that address and the member’s key. Otherwise each side is wired by the
in-process address with no key, which works when one process hosts both mobs
(the gateway takes the member’s key from its own registration and installs
the route with the trust); a member that process does not have is refused in
plain words and nothing is wired. A refused second side undoes the first,
unless that side was wired before the call.
A released member and the wake contact. For a member with a socket
endpoint, peer_info also answers its mob’s wake contact, as four text
values that are present together or not at all: wake_contact_name,
wake_contact_peer_id, wake_contact_address and wake_contact_pubkey_b64
(the mob’s own identity at a socket address, served while the gateway runs).
The helper passes each side the other side’s contact when the answer gives
it whole (wire_local(..., remote_wake_contact=...), the four values as
peer_info gave them); a gateway that answers none gets none passed on, and
the wire is the wire it was. With the contact, a peer message to a member
that is not built (released to rest by its gateway, so nothing listens at its
address) no longer fails as unreachable: the send asks the contact once, the
receiving mob builds the member for a sender that member is wired to, and the
message is handed to it once. The contact gets no trust: a message it signs
gains no admission. It rides the same trust as the endpoint: whoever may call
wire_local for a member names both.
The sending gateway records the link with its contact in its own metadata
store, so the contact is there again after that gateway restarts, with no
second wire. unwire_local removes the record. After a restart of the
receiving gateway its contact is at a new address, unless its mob definition
fixes the mob’s own listener ([backend.external.supervisor_bridge] bind_address, with [backend.external] address_base): with a fixed address
a wake across gateways survives the restart; otherwise call wire_cross_mob
again, which for a pair already wired with the same endpoints changes nothing
but the contact. The cross-mob control channel (cross_mob/wire through a
contact directory) does not carry the contact.
Calling the helper again for a pair that is already wired with the same
endpoints changes nothing. A wire is never replaced: when a side is already
wired to that peer with another endpoint (another address, or another key
after a respawn), its wire_local is refused in plain words and nothing
changes. Call unwire_local on both sides, each with the other member’s
current peer_info, then wire again. A member of a stopped mob still accepts
a message through a wire and is handed it when its mob resumes.
What a wire survives. Between two gateways, a wire survives a gateway
restart on persistent state only when each wired member’s dialable_address
is the same after the restart. With member_comms_tcp()’s default address
(port 0, a port the system picks at each start) it is not: the restarted
member binds another port, is restored broken, and its wires are dead. Give
a mob with persistent state a fixed address (member_comms_tcp("host:port")).
To wire a member again after its address changed:
respawn_memberthe broken member. It comes back active with its new address, and on a fresh conversation: a respawn starts the member on a new session.unwire_localon the other gateway, with the respawned member’s currentpeer_info.unwire_localon the restarted gateway, with the other member’s currentpeer_info.wire_cross_mobagain.
peer_info. peer_pubkey()
is the gateway’s own key, for contact directories; it never describes a
member.
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 thanensure_member-ing them into the mob roster. Identity-plane members
resume their session across restarts (Core keeps it); mob-plane members do
not.
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
A member forked with
fork_off, a delegation fork or a council does not run
the instructions its source activated (meta/member_activate_instruction,
skill bodies activated that way included) unless the gateway’s fork instruction
policy says so. Under the default, such a fork is refused with
fork_instruction_refused before anything is committed. To let forks carry
their source’s activations, opt in at boot:
reactivate_inherited trusts
before you enable it.
Boot-time membership is declared, never derived: a member exists only once a
.roster(provider) names it (identity plane) or ensure_member creates it
(worker plane); [profiles.*] in mob.toml are role templates and spawn
nothing on their own. The former .discovery(callback) and
.pre_spawn(callback) builder methods were removed: they stored the callback
and never transmitted it, so no boot spawn ever came from them.
Identities and their sessions live in Core’s stores under
.persistent_state(path): Core’s mob machine holds each identity’s session
and generation, and a host supplies no continuity storage and holds no
leases. The external identity providers of Meta 0.9.3 are removed; see
Upgrading to Meta 0.9.4 to move a deployment
that used them.
A durable member whose role changed refuses to resume with
MobError::MemberRoleMigrationRequired until the host declares the migration.
.role_migrations([...]) is that declaration: it emits a top-level
role_migrations init param, not a runtime_options field, and the authority
lasts exactly one boot because nothing persists it. Meerkat re-verifies the
declared from_role against durable state and refuses with
MobError::MemberRoleMigrationRejected on mismatch, and ignores the declaration
entirely once the roles already agree, so a declaration left in place after the
migration landed is inert. It arms only where an identity plane exists; on
rpc_gateway that means alongside .roster(...). See
roster and member lifecycle.
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 reports the eager_materialize mode. Under every
mode each roster identity is a member of the mob from ready, and is
materialized when work reaches it; .member_restore(...) decides what is
materialized at start.
Gateway memory config accepts {backend: "local_json"} with an optional
health_check_endpoint (memory.local_json(...)), the only backend. The
predecessor’s backend helper was removed in 0.9 with no alias, and the gateway
refuses its backend value at init.
memory(stores=...) is intentionally rejected because the Rust gateway does not
accept store lists in meta/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.
recall_agent_memory selects records and does not list them (see
Reading agent memory). To see
everything an identity holds, read its manifest with the full tier:
config.runtime_store and
config.event_log modules produce the explicit declarations:
handle.query_events(...) reads the declared event log. A gateway with no
event log configured reads as an empty list through the SDK: an empty result
does not show that no event happened.
The resolved picture is the typed storage census: StatusResult.storage /
CapabilitiesResult.storage parse the gateway’s storage object into
StorageSummary (blob durability, the H2 incremental probe, and the
per-slot StorageSlotSummary census with domain, durability_class,
resolution, backend, degraded, detail). A fail-closed startup
refusal — file-name twins, a store that failed to open — surfaces as the
typed StorageResolutionError (code -32014,
STORAGE_RESOLUTION_CODE), not a TransportError; its message names the
remediation (meta/storage/doctor, or the explicit ephemeral
declaration). Blob-store durability has no wire declaration today — it is
declared by Rust embedders via ephemeral_blobs(true) /
binary_blob_store(...) and reported read-only in the census.
A composition provenance refusal surfaces as the typed
CompositionProvenanceError (code -32019, COMPOSITION_PROVENANCE_CODE).
The gateway raises it when the persistent mob storage’s recorded composition
cannot be proven to match this launch, for example a mob.toml edited since
the persistent mob storage was created. Its kind names the refusal
("divergent", "created_by_rehearsal", the manifest kinds, and
"candidate_divergent" from gateways launched as a candidate) and fields
lists the diverged definition fields as dotted paths, so a host can show what
changed without parsing the message. Revert the edit, or move the stored
definition with declare_spec_update(expected_revision=...).
If a gateway that the Python SDK starts or adopts accepts init and the
SDK then reads a failed settlement:
- In 0.9.15 and 0.9.16,
builder.build()raisesGatewayStartupCleanupError, a transport error. Itsstartup_erroris the underlying refusal. - From 0.9.17,
builder.build()raises the refusal itself.
tools.mob_tasks in a config written for
an earlier release) is never one of the fields: removing it to act on the
warning, or adding it, does not cause this refusal.
Console access
The bundled console is fail-closed. Without.auth(...) the gateway’s
decision state trusts no signing key, and because require_app_auth defaults
to true every console request is refused with 401; the gateway logs a
startup warning naming this. Opening the console is an explicit builder call:
.console_auth_required(False) only behind a loopback bind or a reverse
proxy that authenticates; for anything shared, configure .auth(...) instead.
Earlier SDKs had no setter and hosts overrode
MetaRuntime._build_init_params to inject console_require_app_auth or
console_config_path; both now have builder methods and the override is no
longer needed.
The gateway binds 127.0.0.1 on an ephemeral port by default. To publish it
from another container, .http_listen("0.0.0.0:8080") together with either
.auth(...) or the explicit .allow_remote() acknowledgement, and
.http_public_base_url(...) to advertise the proxy’s address (read back as
runtime.rust_http_public_base_url; runtime.rust_http_base_url stays the
same-host form the SDK itself dials). A non-loopback bind without either is
refused at init. See Deployment.
Runtime lifecycle
RpcError with MemberRestoreFailed and
missing_secret.
If the gateway child dies, a status call can raise TransportReaderFailedError
or its subclass GatewayChildEndedError, depending on when the SDK observes
the exit. Still call shutdown() to release local resources. On 0.9.16 it
raised RuntimeError after bounded cleanup in this case. The example lets
that error pass only if last_gateway_termination.state is "exited".
Startup: no built-in total deadline
connect() (and build()) runs meta/init as accepted-then-settled. The
gateway accepts the init at once, reports each startup phase, and then
settles it ready or failed. The SDK has no built-in total deadline for
that wait. Startup legitimately includes provider callbacks (each bounded at
130 s by the gateway) and the native identity restore, which is
deliberately unbounded and can run for minutes on a large roster. Any fixed
SDK timer would sooner or later abort a healthy restore. A 60 s timeout still
bounds the wait for the accepted answer, and for an older gateway’s single
init response. A host whose gateway answers init late can raise it with
Meta.builder().gateway_init_timeout(seconds) (a positive finite number of
seconds). That bounds a slow host startup; it does not fix one. It applies only
to the meta/init request: ordinary RPCs and provider callback deadlines
keep their own timeouts.
The wait ends only when one of these happens:
- the init settles
ready(connected); - the init settles
failed. You get the typed error, for exampleStorageResolutionError, witherr.data["durable_effects"]:"none"when nothing durable was touched, otherwise"possible"; - the gateway exits, or the transport reader fails. You get
InitOutcomeUnknownError; - your own deadline runs out. Set it with
Meta.builder().init_deadline(seconds), and running out also raisesInitOutcomeUnknownError; - your task is cancelled.
InitOutcomeUnknownError carries init_id, last_phase (the last
meta/init_progress phase seen, such as "roster" or "restore") and
reason. That makes a stuck or interrupted init diagnosable. The gateway may
already have changed native state, so the SDK never retries it automatically
and asks the gateway to shut down. See step 6 of the supervised example
for how to distinguish an unknown startup outcome from a refused start.
Provider callbacks that run during startup (roster, topology, session
builder, customizer) must not call ordinary runtime RPCs on the same
runtime. Ordinary dispatch starts only after init settles, and the
gateway refuses an earlier request at once with InitInProgressError
(-32018, exported as INIT_IN_PROGRESS_CODE).
Schedule callbacks that arrive during startup
A host runnable is application code that a durable schedule fires. The builder declares its name with.host_runnables([...]), and
on_schedule_fire(name, handler) registers the handler that takes each fire
(see Scheduling). Give the handler of a
schedule that can be due when the gateway starts to the builder
(.on_schedule_fire(name, handler) under Builder methods,
from 0.9.17): it is in place before build() connects. A handler registered
on the runtime that build() returned can come too late for such a fire.
Who can schedule a host runnable?
Any member with the schedule tools that is not private to a person can schedule any runnable your application registers and choose its parameters. The handler receives those parameters asoccurrence["payload"] when supplied;
the callback does not identify the member that created the schedule. Register
only actions that any such member may invoke. Validate the payload in the
handler; do not trust it to identify the caller.
Adopting a gateway child the host started
By defaultconnect() spawns rpc_gateway --persistent and owns that
process. A host that supervises the gateway itself (it spawns the process and
owns its lifetime, credentials and cleanup) can hand the SDK that exact child
instead. The SDK then speaks the same stdio protocol over the child’s pipes:
init with its accepted-then-settled readiness, host callbacks, RPC with its
timeouts and the shutdown handshake. It never spawns, signals, reconnects to
or replays a gateway.
Ownership and lifecycle:
AdoptedGatewayChild(...)andAdoptedGatewayTransport(child)only validate: they read, write and close nothing.connect()(or the transport’sstart()) hands the child over, and from then on the transport writesinputand readsoutput. Onlystart()hands it over: a request before it is refused, so the first line the child reads ismeta/init. A refusal before the hand-off leaves both pipes with the host, untouched.- A raw stream is buffered by the transport itself, at the hand-off: a raw
write can take fewer bytes than it was offered and a raw
readline()reads one byte per call, so the transport writes every byte of each line before it flushes, reads lines in blocks, and retries interrupted and partial reads and writes. The wrapper sits over the host’s own stream object, and closing it closes that stream once; the transport opens no second file object over the same descriptor and closes nothing else of the host. Do notos.close()a descriptor you handed over inside such an object: the transport closes it through that object, and by then its number could belong to another file. - From the hand-off, one exit watcher thread is the only caller of
wait_process, in waits of at most 60 seconds, until the child exits or a stop returns; it never calls it from two threads at once. Once the child exited, a request still waiting on a stdout that a process the child started holds open fails about a second later withGatewayChildEndedError, as with a spawned gateway, and so does an init still settling. Ifwait_processraises something other than a timeout, the watcher logs it and ends: the next stop observes the child itself, and until then an exit fails no waiter early. shutdown()stops the transport on a runtime-owned worker thread. The stop makes the stock protocol shutdown (the onemeta/shutdownrequest when the gateway negotiated it, then the end ofinput) on a helper thread that it waits for only until the gateway’s shutdown horizon ends, so a writer stuck on a full pipe cannot hold it. If that phase times out, the helper and the stuck writer stay blocked until the child’s stdin closes, normally through the retirement. Then, whatever that phase did, it callsrequest_retirement(), once per child however often it runs, and waits for the direct child’s exit as the watcher observes it, for the shutdown horizon plus 10 seconds from when the first stop began (10 seconds more on each later stop, which callswait_processitself). It never runs or awaits the host’s own cleanup, and the SDK’s reader never calls the host. The reader closesoutputwhen it ends.- A child whose exit is still pending at the end of that bound raises
GatewayChildPendingError. The runtime keeps the transport, and the nextshutdown()observes the same child again without requesting its retirement twice. - A start that fails after the hand-off (init refused or failed, an init
outcome that is unknown, a cancelled caller) is stopped the same way. Its
failure is recorded before that stop is scheduled, so cancelling the caller
drops neither the retirement request nor the child’s observation; as with
a spawned gateway, the exception of a cancelled caller carries
gateway_cleanupwhile the stop has not succeeded. - The transport’s own
stop()is synchronous: run it withawait asyncio.to_thread(transport.stop). On an event-loop thread it raisesTransportErrorat once and does nothing. Always stop it (throughshutdown()): a transport dropped without a stop ends the child’s input and callsrequest_retirement()from its finalizer, which may run on any thread, the SDK’s reader included, or in the collection at interpreter exit. - One transport serves one connect. To connect again after
shutdown(), passgateway_transport()a factory taking no arguments that returns a transport over a child the host started for that connect..gateway(...)may be set as well; the SDK still never spawns it. - The SDK’s own SSE, multipart and console calls use the
http_base_urlthe gateway reports. A spawned gateway shares this process’s network namespace; for an adopted child, keeping that address reachable from this process is the host’s job.
GatewayTransportConflictError (a ValueError) refuses, before anything is
handed over, a transport that was already started or stopped, and a
transport given both to MetaRuntime(config, transport) and to
gateway_transport(). The TypeScript SDK’s factory takes precedence over a
constructor transport instead; Python refuses the pair. A transport given to
MetaRuntime(config, transport) alone is used in place of a spawn whenever
the configuration names a gateway, and an AdoptedGatewayTransport given
there is used even when it does not.
Gateway logging (stderr)
The persistent gateway reports tracing lines, panic hooks, and storage migration progress on its stderr. By default the SDK inherits the host process’s stderr, so those lines are visible where your application logs. Two environment variables adjust this:
Discarding is the legacy pre-0.8.9 default and is not recommended: it hides
panic output and makes a slow-but-working storage migration indistinguishable
from a hang.
Session agent builder and per-profile tools
build_agent runs once per member build on the worker plane (fresh spawn or
resume). The gateway pre-fills SessionBuildOptions before it calls you:
meerkat sets the fork lineage on the build that seats a durable fork
(
fork_off children, fork_member children, local council participants) and
on every later rebuild of that member, so a builder can build the child as its
source. The child’s own labels and session_id still name the child; they
never carry the source’s agent_identity. The lineage is receive-only: it is
not sent back, and the gateway ignores it in a build response.
Read profile_name, do not assign it. There is no way to select a profile
from build_agent: the gateway applies only additional_instructions (mint
builds only; on a resume they are ignored with a warning, because a resume
inherits the persisted prompt state), labels, resume_session_id, and the
registered tools from what you return, and ignores a host-set
profile_name. Per-profile tools are therefore
one builder that branches on the pre-filled value:
.session_service(builder) is the public setter; build() connects and
registers the builder on the callback dispatcher for you. MetaBuilder._config
and MetaRuntime._dispatcher are internal and change without notice. The
builder must be set before build(): meta/init tells the gateway whether a
session builder exists, so there is no post-connect registration.
Identity-first equivalent: customize_build
On the identity plane the same hook is AgentCustomizer.customize_build,
registered with the public .agent_customizer(customizer). It runs when an
identity is seated (created), and when its member is built (see below). An
identity the mob already holds is reused without customization until its
next build. Do not use reconciliation to refresh an already-active identity’s
tool handlers. The hook receives the durable spec (so spec.profile is the profile
name), and registers tools on the draft:
draft also carries model, system_prompt, additional_instructions,
labels, app_context, and provider_params. A tool registered here rides
the same callback/call_tool dispatch as build_agent tools.
context.mob_id is the mob of the member being customized (context.mobId
in TypeScript). A gateway can host several mobs, and two of them can have a
member of one name: the mob and context.identity together name the member,
and the SDK keeps the handlers each build registers per mob and member name,
so a build of one mob’s member never releases the handlers of another mob’s
member of the same name. The gateway sends the mob as mob_id beside
scope_id in the params of callback/agent_customizer/customize_build, not
inside the context object. With an earlier gateway the callback
names no mob: context.mob_id is None (context.mobId is absent) and the
handlers are kept per member name, as before. An earlier SDK
ignores mob_id: while a gateway hosts two mobs that each have a member of
one name, one mob’s build of that name releases the other mob’s customizer
tools for it until that mob builds it again, and a call to them fails with
no handler registered for tool.
Each identity member has one stable tool dispatcher for its whole life, and
every customize_build publishes its tools into it. The tool list and the
handler scope that serves it always change together. The tools therefore
follow the member through every rebuild: a gateway restart, a member that is
adopted instead of respawned, a respawn. customize_build runs:
- once when an identity is seated and the mob held no member for it (a new
identity, an identity a first-boot manifest row brings in, a hosted
identity its host creates), when a reset or a delete starts its fresh
life, and when a declared role migration moves it to its new role, with
the runtime’s real context (every registered identity as
active_peers, the roster’s managed edges). That call publishes the tools and records the customized spawn spec. It builds nothing, except a declared role migration’s move of the member onto its session, which builds the member from it: a seat that revives the session of a member that was retired after it was built (an identity listed again after its member was retired, for example) is a Dormant seat and builds nothing. From 0.9.15 a respawn seats the identity’s successor in one step, andcustomize_buildruns once for that seat, a Dormant seat on the session the member keeps, with no archive in between; before 0.9.15, and still for a member the same-session step does not serve (see Known limitations in Meta’s changelog, the entry on the loss of an identity’s mobs after a respawn), a respawn retires the member and revives its archived session with such a seat.resolved_tools, which reports the tools a build actually resolved, answersno_build_recordeduntil the member’s first build. Yourafter_create(identity, session_id, context), when you define one, is then called with the session the identity is bound to, unless that incarnation has ended by then. It is attempted at least once: a gateway stopped before the call makes it at its next start, over a durable metadata store. Each call has 30 seconds to answer and is made at most three times; one that failed is reported aslifecycle_effect_failedand not made again; - once per build of a member, right before it: when work reaches a member
that is not materialized (a send, a dispatch, a peer message, a kickoff),
and at start for the members that must be live then. No
after_createfollows a build.
after_create is
called once, with the session the respawn keeps. Before 0.9.15, and still
for a member the same-session step does not serve (see Known limitations in Meta’s changelog, the entry on the loss of an identity’s mobs after a respawn), the member is retired first and seated again on the session
the mob kept archived. A materialization, a warm
or a delivery of an identity the mob seats again on its archived session
builds the member once, at its wake, and the roster pass builds nothing. A
lazily seated identity (one seated with nothing built yet) gets two
customize_build calls before its first run: its seat’s, then its first
build’s. A respawn does the same: its seat calls customize_build, and its
build calls it again.
A member is never built without its tools, so its first run sees them. A
restart over idle members the mob already holds calls customize_build for
none of them. A member the gateway builds before your customizer is composed (a
gateway that stopped uncleanly restores the members that hold work while it
builds the mob) is built, then starts no run until the roster pass has
published its tools. A member whose identity the roster no longer lists
starts no run either, until the roster retires it (a host-adopted identity’s
member, which the roster never retires, is not held). A customize_build
that fails refuses the member’s build: the member stays as it was, and the
delivery that needed it asks for the build once more. When that fails too,
the delivery answers a typed retryable error (the artifact refusal itself,
typed, when the host’s installed artifacts refused the tools), and a later
delivery, or the mob’s own retry of work the member owes, tries again.
While a member’s tools are not published, its identity status reports
customizer_tools_pending with the reason. A tool from an earlier build
that the latest build no longer declares is refused, never routed to stale
handlers.
meta/identity/resolved_tools lists a member’s tools without building it:
a live member’s live tools, or, for a member that is not materialized, the
tools its last build had (tools_source says which, and reads
no_build_recorded for a member not built since the upgrade or since its
fresh life began). runtime.mob_handle().identity_warm(identity) builds a
member without a turn and records its tools; its record_revision counts
the record’s writes and is not the identity’s generation.
Customizer tools belong to roster identities only. Helpers, forks,
flow-provisioned members, and members spawned under their own ids never get
them; use profile tools or the session builder’s per-spawn tools for those.
A raw spawn that reuses a roster identity’s member id does get that
identity’s current tools.
Provider parameters (provider_params)
AgentBuildDraft.provider_params mirrors meerkat’s ProviderParamsOverride:
the shared sampling knobs at the top level and the provider-specific knobs
nested under provider_tag, which is tagged by provider. Anthropic prompt
caching is one such knob. With no profile or request override, the pinned Meerkat
dependency defaults to automatic on Anthropic API, Vertex, and Foundry, and to
disabled on Bedrock and Copilot. Bedrock and Copilot do not support request-wide
automatic caching and reject an explicit automatic policy. On a supported
backend, this example explicitly selects automatic caching with a one-hour TTL:
provider_tag.cache_control to "disabled" and omit
cache_ttl.
The flat form {"cache_control": "automatic"} is refused: both
ProviderParamsOverride and the provider tags deny unknown fields, so the
gateway rejects the returned draft instead of dropping the knob. Knobs the
draft leaves unset are filled from the profile’s own provider_params, and a
provider_tag from a different provider family than the profile’s own tag is a
typed merge error, not a silent union. A declared provider_params also reaches resumed
sessions (the bridge masks it into resume_overrides); it requires an inline
definition profile to carry it, so an identity bound to a realm-reference
profile fails the build with a message naming the realm profile as the place
to declare it.
Mob announcements
With mob announcements enabled (.mob_announcements() on a persistent,
identity-first launch), MobHandle wraps every meta/mob_announcements/*
method. Results are frozen dataclasses; every state, phase, status, outcome,
action and kind is a plain string, so a newer gateway’s value passes
through. The declarations you write (a source’s identity, observation,
audience, routes, …) are dicts in wire form. Optional parameters are sent
only when set.
A
member is {"mob_id": ..., "identity": ...} or an AnnouncementMember.
The method reference describes every
field. A collector step reads the source, then advances it from the
position it read; a step that lost a race raises with the current position:
MobAnnouncementsUnavailableError (-32044),
AnnouncementConflictError (-32045; SourceStaleRevisionError and
SourceVersionConflictError carry the source’s current_version, cursor
and revision), AnnouncementFrontierError (-32046),
AnnouncementRefusedError (-32047) and AnnouncementNotFoundError
(-32048), each with the refusal’s kind (a kind this SDK does not know
keeps its code’s class). A source method on a gateway without sources raises
RpcError -32601 with “Meta does not support sources” in its message.
CapabilitiesResult.mob_announcements (MobAnnouncementsCapability) reads
meta/capabilities.mob_announcements, None when they are disabled.
A batch’s handling and an observation’s handling
(AnnouncementBatchHandling: state, cause, redelivered, held,
dismissed, read_at_ms) say what became of the turn
(Delivery handling). Each is None until
the batch is admitted. A batch that holds nothing for an operator refuses
announcement_delivery_redeliver and announcement_delivery_dismiss with
AnnouncementRefusedError not_held. An AnnouncementAuditEntry for a
plain announcement has source_id and generation None.
Escalations (Mob announcement health)
reach .on_error(callback) as mob_announcement_escalated and
mob_announcement_escalation_resolved, each with its event cursor in
context. After a reconnect, read the events you missed:
StatusResult.mob_announcements (MobAnnouncementsStatus: sources,
members, handling, open_escalations, last_event_cursor) reads
meta/status.mob_announcements. It is None when mob announcements are
disabled or their database could not be read. A source’s
AnnouncementSourceHealth adds escalations, quiet_monitoring,
empty_coverage_monitoring and runner_scheduled_here. Each
AnnouncementEscalation keeps its cause and its subject (a dict, with
its kind as subject_kind) as sent.
A role template (Role templates) subscribes
every member of a mob with a role:
children, and
announcement_subscription_get reads it as template.
announcement_declarations_apply(declarations) applies declared sources
and subscriptions in wire form, with revision defaulting to
declarations["revision"] (Mob announcement declarations).
Called without declarations, it asks a gateway with a declarations
sidecar to read the file again. Each
AnnouncementDeclarationRecord keeps its kind, status and
collection as strings, with refusal_kind and delivery_kind read
from their objects. The refusals declaration_rollback,
declaration_digest_conflict, role_template_limit and
subscription_id_taken are AnnouncementRefusedErrors with their data.
The builder passes declarations or declarations_path in
mob_announcements({...}) unchanged.
Error hierarchy
All SDK errors inherit fromMetaError:
Advanced API
These methods are available for power users and module-system internals. Most apps should usesend, subscribe_agent/subscribe_mob, and status/reconcile instead. Known issue, noted 2026-11-13: on meerkat-meta releases through 0.9.14, the Python SDK’s subscribe_agent and subscribe_mob deliver a run’s events late or not at all, and a loop that waits for run_completed can wait without end. See the known issue on the Meta 0.9.14 release page for the affected releases and what to do.
gating_decide() preserves the owner’s recorded approver_id, outcome,
decided_at_ms, reason, and next_pending_id. Older responses that omit these
fields leave them as None; an absent or unrecognized outcome must not be treated
as permission. Escalation returns pending_approval with a successor
next_pending_id. The SDK makes no automatic follow-up request.
gating_decide() reads the result of a gated action. From 0.9.15
meta/gating/decide answers a question set’s pending_id with another
result, which carries kind: "question_set" and no action_id: decide a
question set with gating_answer() or gating_dismiss(), which read it.
From 0.9.15. gating_questions() lists the open question sets
(they are not part of gating_pending()). Each GatingQuestionSet carries the
pending_id a decision takes, the asking agent as origin, an optional
title, its questions (GatingQuestion: id, prompt, choices,
allow_free_text, recommended), created_at_ms, deadline_at_ms and the
subject_digest a decision sends back as presented_digest. Both decisions
go through meta/gating/decide, so the host names approver_id:
answers takes GatingQuestionAnswer values or their wire form
({"question_id": ..., "answer": {...}}). At least one answer is needed
(ValueError otherwise, before anything is sent); a question left out reaches
the agent as unanswered, and free text is allowed only where the question
sets allow_free_text. gating_dismiss() returns the same
GatingQuestionSetResult with outcome dismissed. The gateway refuses an
invalid answer set as invalid params (-32602). A set that itself refuses
the decide (it is no longer open, or presented_digest is not its digest) is
refused -32602 with the typed refusal in the error’s data:
data.kind = "decision_refused" and data.decision_refusal.kind (not_open,
subject_changed, expired or not_eligible); see
Answering a question set.
Approval records a decision and does not execute the action. These methods expose
Meta gating; native retained-action consent and model-review
configuration are separate contracts.
Durable decisions
MobHandle calls the durable decision methods
of the stdio gateway: decisions_list(kind=, phase=, approver_id=, requester=, after=, limit=), decisions_get(decision_id, include_request=False),
decisions_rendering(decision_id, max_part_bytes=None),
decisions_present(decision_id, presentation), decisions_withdraw(decision_id)
and decisions_decide(decision_id, approve=, presented_digest=, reason=None, attestation=None). Each answers the gateway’s result as a dict.
chat ingress is declared at launch with .decision_ingresses(...),
and the approver map lists U123 on it for the decision’s approver id. An
attested decide is accepted only for a decision that was presented to its
approver: by the presentation the attestation carries, as here; by one
recorded before with decisions_present(decision_id, presentation), which
takes the same mapping; or by the gateway’s own showing to the stdio
operator (its presented notice), where the approver map lists the operator
for that approver id. With none of these, the decide is refused
presentation_incomplete. The fields of a presentation are listed under
meta/decisions/decide.
MetaRuntime.on_decision_notice(handler) receives each meta/decisions/notice.
With the released Meta 0.9.19 gateway and SDK, register the handler before
calling decisions_list. As it serves the list, the gateway writes one held
notice for each open decision of the page this connection has not noticed yet
(a decision that waits for a person and that the stdio operator may decide
gets a presented notice instead, also where it was noticed held before:
see Notices on the stdio gateway);
registering the handler alone does not report new questions. Register the
handler before the first list on a connection: a held notice that arrives
while no handler is set is not sent again on that connection, and neither is
a presented notice once its presentation is recorded; a list on a new
connection notices the decision again.
In the development version, the gateway writes a notice when a decision opens, once when the connection
starts for a decision already open, and before a list answers; the SDK runs
each handler on its own, so a handler may still be running after
decisions_list returns. A held notice that arrives before a handler is
registered is kept (one per decision, the newest 1024 decisions) and handed
to the handler when it registers; an older one comes again at the host’s own
list. Register the handler from the runtime’s running event loop: registered
where no loop runs, it receives the kept notices only before the next notice
that arrives. Without an attestation the stdio
operator decides, eligible only for a decision presented to it on this
connection. A decide called while the SDK serves a host tool callback raises
DecideInsideToolCallbackError (kind = "decide_inside_tool_callback") and
sends nothing: an agent’s tool call never decides.
A notice of kind ask_user.questions names a question set that is open in
the store: read it with gating_questions() and answer it with
gating_answer(). That works on a launch with a roster (.roster(...)): a
gateway serves its agents’ questions only there. On a launch without a
roster the handler is still called for a set the store already holds, and
decisions_list() returns it, but gating_questions() returns no set and
gating_answer() raises RpcError (-32602: the pending_id was not
found). Such a notice is genuine and is not a readable question: do not
treat it as one.
Mobpack authoring
MobHandle wraps the full Flow Editor authoring surface (meta/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 frommeerkat_meta:
ModuleSpec, define_module, etc.) live in meerkat_meta.helpers — not top-level.
See also
- JSON-RPC API — full method reference
- SSE API — event streaming protocol
- Modules — module configuration and lifecycle
- Rust SDK — primary Rust interface
- TypeScript SDK — TypeScript equivalent
