Tool system
Defining tools
Define tools using JSON Schema:Implementing AgentToolDispatcher
TheAgentToolDispatcher trait connects your tools to the agent:
ToolIdentityRegistry (dynamic registration)
ToolIdentityRegistry (dynamic registration)
For dynamic tool registration:
Multimodal tool results
Tool results can carry either plain text or multimodal content blocks:ToolResult::new(...) creates a text-only result. ToolResult::with_blocks(...) passes content blocks directly into ToolResult.content, enabling tools to return images and other rich content to vision-capable models.
The built-in view_image tool uses the same content-block mechanism to read image files from disk and return them as ContentBlock::Image blocks. It is automatically hidden from models that lack vision or image tool result support.
Session stores
SessionStore owns the session persistence domain. A complete facade realm-backed
runtime also needs runtime lifecycle and delivery state, schedules, WorkGraph
state, detached jobs, blobs, and artifacts. RealmStorageProvider is that
facade persistence boundary: one provider returns every required store in a
RealmStoreSet, and the facade composes that set into the realm’s
PersistenceBundle.
Mob state is intentionally not a RealmStoreSet slot. The separate
meerkat-mob crate owns its mob store to avoid a facade dependency cycle;
MobKit or another higher-level host composes it alongside the facade provider.
Each required slot declares a DurabilityClass and its actual
DurabilityResolution. Startup fails closed when a durable slot resolves to
non-persistent storage unless the realm manifest explicitly declares that
domain ephemeral. The required domains are sessions, runtime, schedule,
workgraph, jobs, blobs, and artifacts.
- JsonlStore
- MemoryStore
File-based persistence using JSONL format:
Implementing a custom store
Implementing a custom store
Implement the
SessionStore trait and pass it to AgentFactory::session_store() when you are replacing only session persistence. Then compose the persistent service with MeerkatMachine so the custom store participates in the canonical runtime-backed lifecycle instead of only a one-off direct agent.Prefer
SessionStore + session_store() over implementing AgentSessionStore directly.
SessionStore is the richer trait (with list, delete, exists) and AgentFactory
automatically wraps it via StoreAdapter. Implementing AgentSessionStore directly
bypasses the factory and loses runtime-backed session orchestration.For runtime-backed persistent services, realm persistence still flows through the
PersistenceBundle opened for that realm. Treat custom SessionStore
implementations as a storage seam for custom builders or direct agent/store
integration, not as a drop-in replacement for the entire runtime persistence
bundle.Implementing a realm storage provider
Implementing a realm storage provider
Implement
RealmStorageProvider when an external backend must own the whole
realm. open() receives the canonical RealmOpenContext and returns a
RealmStoreSet with all seven required stores and exactly one durability
declaration for each domain. DiskStorageProvider is the built-in reference
implementation for SQLite, JSONL, and explicitly ephemeral memory realms.The snippet below is intentionally schematic and non-runnable: each backend
must construct its own seven stores and durability declarations before it can
return.Provider implementations should run the published meerkat-store-conformance
chapters for each supplied session, blob, and artifact trait capability. The
suite covers session round trips, guarded revisions, incremental/rewrite
semantics, concurrency, blob/artifact survival, and dangling references.
Runtime, scheduler, WorkGraph, and job stores retain their own crate-level
conformance suites, while facade composition enforces the provider’s complete
durability declaration set.MCP integration
Route tool calls across multiple MCP servers:See also
- Rust SDK overview - getting started, sessions, events
- Rust SDK advanced - expert-only direct agent construction, providers, hooks
- Tools concept - how the tool system works
