SessionService, which keeps Rust aligned with the same session lifecycle semantics used by every other Meerkat surface while still avoiding subprocess or JSON-RPC overhead.
Method overview
| Area | Method / Type | Purpose |
|---|---|---|
| Setup | Config::load() | Load configuration from disk |
AgentFactory::new(store_root) | Create a factory for building agents | |
open_realm_persistence_in(...) | Open a realm-backed persistence bundle | |
build_persistent_service(factory, config, cap, persistence) | Build the runtime-backed persistent session substrate | |
build_ephemeral_service(factory, config, cap) | Build an in-memory Queue-only substrate | |
| Sessions | service.create_session(req) | Create a session and run the first turn |
service.start_turn(id, req) | Continue an existing session | |
service.read(id) | Read session state | |
service.list(query) | List active sessions | |
service.archive(id) | Remove a session | |
| Agent | agent.run(prompt) | Run agent with a prompt |
agent.run_with_events(prompt, tx) | Run with event streaming | |
agent.cancel() | Cancel the current run |
Installation
Feature flag reference
Feature flag reference
| Feature | Description | Default |
|---|---|---|
anthropic | Anthropic Claude API client | Yes |
openai | OpenAI API client | Yes |
gemini | Google Gemini API client | Yes |
all-providers | Shorthand for all three providers | No |
sqlite-store | SQLite-backed persistent realms | No |
jsonl-store | File-based session persistence | No |
memory-store | In-memory session storage (testing) | No |
session-store | Persistent session lifecycle support | No |
session-compaction | Auto-compact long conversations | No |
memory-store-session | Semantic memory indexing | No |
comms | Ed25519 inter-agent messaging | No |
mcp | MCP protocol client and tool routing | No |
schedule | Durable scheduler surfaces | No |
workgraph | WorkGraph goal and attention surfaces | No |
live | Live-channel orchestration and realtime adapter helpers | No |
skills | Composable knowledge packs | No |
Quick start
Production surfaces (CLI, REST, RPC, MCP) use the runtime-backed path whereSessionService is substrate and MeerkatMachine owns keep-alive, Queue/Steer routing, and comms drain. See the JSON-RPC API or REST API for those entry points.
For the main production embedding path, use the runtime-backed persistent flow:
build_ephemeral_service remains available as a direct Queue-only substrate.
Sessions
SessionService is the canonical lifecycle API. All surfaces (CLI, REST, MCP, RPC) route through it.
Multi-turn conversations
Deferred first-turn system prompt override
system_prompt on StartTurnRequest is only supported for a deferred session’s
first turn. Once the session has existing history/messages, turn-time
system_prompt overrides are rejected.
Error handling
Direct agent APIs
Running agents directly
Basic run
Run with event streaming
Agent methods
| Method | Description |
|---|---|
run(prompt) | Run agent with a ContentInput prompt (text or multimodal) |
run_with_events(prompt, tx) | Run with event streaming; prompt is ContentInput |
session() | Get current session (read-only) |
budget() | Get current budget tracker |
state() | Get current loop state |
cancel() | Cancel the current run |
Error handling
Events
All event types
All event types
Core types
Message and ContentBlock
ContentInput
ContentInput is the prompt type accepted by CreateSessionRequest and StartTurnRequest. It supports both text-only and multimodal prompts:
ToolCall and ToolResult
RunResult
See also
- Tools and stores - tool system, session stores, MCP integration
- Advanced - expert-only direct agent construction, providers, budgets, and hooks
- API reference - quick-lookup type index
