Skip to main content

Tool system

Defining tools

Define tools using JSON Schema:

Implementing AgentToolDispatcher

The AgentToolDispatcher trait connects your tools to the agent:
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.
File-based persistence using JSONL format. Enable the facade’s jsonl-store feature:
Implement SessionStore when replacing session-content storage. AgentFactory::session_store() installs it for direct-agent or custom-builder integration. It is not an override for persistent-service composition: the persistent builders take their session store from PersistenceBundle and install its adapter as the default per-agent override, taking precedence over the factory’s custom store.
Prefer SessionStore for backend implementations: it includes list, delete, and exists, and AgentFactory::session_store() wraps it via StoreAdapter. That setter alone does not compose the runtime-backed lifecycle.For a realm-backed persistent host, put the custom store in RealmStoreSet.session_store returned by your RealmStorageProvider, then use open_realm_persistence_with_provider() to obtain the PersistenceBundle. Supply or delegate all other required stores, keep each durability declaration accurate, and preserve the runtime/session-store persistence-profile pairing: HeadCanonicalV1 requires an IncrementalSessionStore. See Implementing a realm storage provider below.Low-level PersistenceBundle::new() and related constructors also accept custom stores; callers using them own the corresponding composition. A custom SessionStore is not a drop-in replacement for the entire persistence bundle.
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