Expert-level direct agent construction, provider configuration, budgets, hooks, and runtime delivery internals.
Advanced Rust SDK usage for the cases where the runtime-backed SessionService path is intentionally not enough. This page covers expert-level direct agent construction, provider configuration, budgets, hook helpers, and lower-level delivery internals.
AgentBuilder (in meerkat-core) wires the agent loop primitives: LLM client, tool dispatcher, and session store. It has no dependency on meerkat-tools and no opinions about which tools exist.AgentFactory (in the meerkat facade) is the opinionated composition layer. It knows about tool categories, runtime resources, comms, memory, mobs, and skills, and wires them into the dispatcher before passing them to AgentBuilder. All public surfaces go through the runtime-backed session path built on top of AgentFactory.Use AgentFactory via build_persistent_service() (main path) or build_ephemeral_service() (substrate/testing path) unless you explicitly need to bypass session lifecycle orchestration. Direct AgentBuilder usage means you own composition, persistence, event handling, and any drift from the standard runtime-backed path.
For most use cases, prefer SessionService via the runtime-backed persistent path (see
overview). AgentBuilder is used internally by AgentFactory::build_agent().
Direct usage is only needed when bypassing the session service entirely.
If you are embedding Meerkat into an application, start with SessionService. Reach for AgentBuilder only when you deliberately want an expert-only execution API with no runtime-managed session identity.
use meerkat::AgentBuilder;let agent = AgentBuilder::new() .model("claude-sonnet-4-5") .system_prompt("You are a helpful assistant.") .max_tokens_per_turn(4096) .temperature(0.7) .build(llm_client, tool_dispatcher, session_store);
Public comms injection is a delivery API. event_injector() gives you an EventInjector, and inject() queues a runtime-backed external event for later admission.
use meerkat::{EventInjector, PlainEventSource};let injector = service.event_injector(&session_id).await .expect("comms must be enabled");injector.inject( "review PR #42".into(), PlainEventSource::Rpc,)?;
How it works
inject() queues a plain event into the session inbox.
The runtime-backed surface admits that queued event as future turn work.
Observation is selected independently:
use the session’s primary event_tx for full session activity,
use mob member subscriptions for agent-scoped activity,
use mob event subscriptions for attributed mob-wide activity.
Public callers no longer receive an interaction-scoped stream from injection.
This distinction matters: queueing an event and consuming it are no longer treated as the same seam. The keep-alive/drain lifecycle owns consumption truth.Requirements:
Agent must be in keep-alive mode if you want the keep-alive loop to drain inbox events.
Comms must be enabled.
If you need streaming output, configure an observation surface separately.