Advanced Rust SDK usage for the cases where the runtime-backedDocumentation Index
Fetch the complete documentation index at: https://docs.rkat.ai/llms.txt
Use this file to discover all available pages before exploring further.
SessionService path is intentionally not enough. This page covers expert-level direct agent construction, provider configuration, budgets, hook helpers, and lower-level delivery internals.
Runtime-backed vs standalone builds
The Rust contract is explicit:- runtime-backed surfaces should call
MeerkatMachine::prepare_bindings(session_id) - those bindings should be threaded through
SessionBuildOptions.runtime_build_mode = RuntimeBuildMode::SessionOwned(bindings) - standalone/testing/embedded paths should use
RuntimeBuildMode::StandaloneEphemeral
AgentBuilder vs AgentFactory
meerkat::AgentBuilder is the public facade builder. It accepts explicit client/tool/store overrides for embedded use, then still routes through AgentFactory::build_agent() so provider defaults, session metadata, hook wiring, and runtime build-mode defaults stay aligned with the factory path.
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.
The lower-level meerkat_core::AgentBuilder is not re-exported by the facade. Its standalone build path is reserved for core tests; public embedding code should use the facade builder or AgentFactory.
Use AgentFactory via build_persistent_service() (main path), build_ephemeral_service() (substrate/testing path), or the public meerkat::AgentBuilder facade unless you explicitly need to bypass session lifecycle orchestration. Direct core builder usage means you own composition, persistence, event handling, and any drift from the standard runtime-backed path.
If you are building a runtime-backed surface around SessionService, avoid the
old hand-rolled register_session() + registry extraction pattern. Prefer the
binding seam above so the runtime/session owner stays canonical.
AgentBuilder
For most use cases, prefer
SessionService via the runtime-backed persistent path (see
overview). The public AgentBuilder delegates to the factory
pipeline. Use the core builder only inside core-owned tests that bypass the
session service and facade composition entirely.All builder methods
All builder methods
| Method | Description | Default |
|---|---|---|
model(name) | Set the model identifier | "claude-opus-4-6" |
system_prompt(prompt) | Set the system prompt | None |
max_tokens_per_turn(n) | Max tokens per LLM call | 8192 |
temperature(t) | Sampling temperature (0.0-1.0) | None (model default) |
budget(limits) | Set resource limits | Unlimited |
retry_policy(policy) | Configure retry behavior | 3 retries with backoff |
resume_session(session) | Resume from existing session | New session |
provider_params(json) | Provider-specific parameters | None |
with_hook_engine(engine) | Attach a hook engine | None |
with_hook_run_overrides(overrides) | Run-scoped hook overrides | Empty |
Providers
Built-in clients for major LLM providers:- Anthropic
- OpenAI
- Gemini
Provider parameters
Pass provider-specific options viaAgentBuildConfig:
- Anthropic
- OpenAI
- Gemini
Implementing a custom LLM client
Implementing a custom LLM client
Budget configuration
Retry configuration
When to bypass SessionService
Direct agent construction still makes sense when you need one of these expert-only scenarios:- You are embedding a single transient agent loop with fully custom persistence and tool composition.
- You are testing a lower-level trait contract in isolation from session orchestration.
- You are implementing infrastructure that itself sits underneath a
SessionService.
SessionService so runtime admission, history, interruption, and external-event handling stay canonical.
Hook helpers
Comms delivery and observation
Public comms injection is a delivery API.event_injector() gives you an EventInjector, and inject() queues a runtime-backed external event for later admission.
How it works
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_txfor full session activity, - use mob member subscriptions for agent-scoped activity,
- use mob event subscriptions for attributed mob-wide activity.
- use the session’s primary
- Public callers no longer receive an interaction-scoped stream from injection.
- 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.
SSE streaming example
SSE streaming example
Complete example
Python and TypeScript SDKs
Both communicate with a localrkat-rpc subprocess over JSON-RPC 2.0 (with optional explicit realm/instance scoping) — no native bindings required.
- Python: Python SDK overview
- TypeScript: TypeScript SDK overview
See also
- Rust SDK overview - getting started, sessions, events
- Tools and stores - tool system, stores, MCP
- API reference - type index
- Architecture - system design and internals
