RunResult
RunResult is returned by session.turn(), session.invoke_skill(), and deferred.start_turn(). Session creation returns runtime-backed Session or DeferredSession wrappers, and the latest RunResult remains available through session.last_result or events.result after consuming an EventStream.
Session UUID.
Assistant response text.
Number of LLM turns completed.
Number of tool calls made.
Token usage breakdown.
Optional human-readable session reference.
Parsed structured output, if an
output_schema was provided.Schema validation warnings emitted by the provider.
Runtime diagnostics from the skill subsystem, when present.
Session
client.create_session() returns a runtime-backed Session wrapper.
Stable session UUID used by the runtime.
Optional human-readable session reference.
Assistant text from the most recent turn.
Token usage from the most recent turn.
Number of LLM turns in the most recent run.
Number of tool calls in the most recent run.
Structured output from the most recent run, if present.
Cached result from the most recent runtime-backed turn.
Session methods are thin conveniences over canonical runtime calls:
await session.turn(...)session.stream(...)await session.history(...)await session.archive()await session.interrupt()await session.invoke_skill(...)await session.subscribe_events()
DeferredSession
client.create_deferred_session() returns a DeferredSession when you want to allocate session identity now and run the first turn later.
Stable session UUID reserved by the runtime.
Optional human-readable session reference.
await deferred.start_turn(...) to execute the first turn through the same runtime-backed path as any other session.
Usage
Usage is a frozen dataclass describing token consumption for a single LLM turn. It appears on RunResult.usage and on the TurnCompleted and RunCompleted events.
Input tokens consumed.
Output tokens generated.
Tokens used to write to the prompt cache (provider-specific).
Tokens read from the prompt cache (provider-specific).
SessionInfo
Returned byclient.list_sessions().
Session UUID.
Optional human-readable reference.
ISO 8601 creation timestamp.
ISO 8601 last-updated timestamp.
Number of messages in the session.
Cumulative tokens consumed.
Whether a turn is currently in progress.
Capability
Returned as elements ofclient.capabilities.
Capability identifier (e.g.
"shell", "comms", "skills").Human-readable description.
Availability status string. Normalised from Rust-tagged enums to a plain string by the SDK.
Convenience property —
True when status == "Available".Checking capabilities
Capability inspection is done directly on the client — there is no separate checker class.Skill types
SkillKey
UUID of the skill source.
Name of the skill within the source.
SkillRef
session.invoke_skill(), turn(skill_refs=...)) you can pass either a SkillKey or a legacy string of the form "<source_uuid>/<skill_name>". Legacy strings emit a DeprecationWarning.
Multimodal prompts
All prompt parameters (create_session, turn, stream, create_session_streaming) accept str | list[dict]:
str— plain text prompt (backwards compatible).list[dict]— a list of content blocks for multimodal input. Each block is a dict with a"type"key:{"type": "text", "text": "..."}— text content.{"type": "image", "media_type": "image/png", "data": "<base64>"}— base64-encoded image content.
Diagnostic types
SchemaWarning
Provider that emitted the warning.
JSON path to the offending schema location.
Warning message.
SkillRuntimeDiagnostics
RunResult.skill_diagnostics when the skill subsystem emits diagnostics.
Health snapshot for skill source resolution.
Skills that have been quarantined due to repeated failures.
SourceHealthSnapshot fields: state, invalid_ratio, invalid_count, total_count, failure_streak, handshake_failed.
SkillQuarantineDiagnostic fields: source_uuid, skill_id, location, error_code, error_class, message, first_seen_unix_secs, last_seen_unix_secs.
EventStream
EventStream is an async context manager returned by session.stream() and client.create_session_streaming(). Iterating it yields typed Event subclass instances.
session.stream() and client.create_session_streaming() are synchronous — they return an EventStream directly. The JSON-RPC request is sent when entering the async with block.Properties
Session UUID. For
create_session_streaming, this is set after the response arrives (once __aenter__ has flushed the request).The final result. Available only after the stream has been fully consumed. Raises
MeerkatError("STREAM_NOT_CONSUMED") if accessed beforehand.Usage patterns
Typed events
All events are frozen dataclasses. Import them from the top-levelmeerkat package.
Session lifecycle
RunStarted
RunStarted
RunCompleted
RunCompleted
LLM turn events
TurnStarted
TurnStarted
A new LLM turn has begun.
1-based turn index within the current run.
TextDelta
TextDelta
An incremental text chunk streamed from the LLM. Handle these to display output in real time.
The text chunk.
TextComplete
TextComplete
Full assistant text for the current turn, emitted after streaming finishes.
The complete text.
ToolCallRequested
ToolCallRequested
ToolResultReceived
ToolResultReceived
TurnCompleted
TurnCompleted
Tool execution events
ToolExecutionCompleted
ToolExecutionCompleted
ToolExecutionTimedOut
ToolExecutionTimedOut
Compaction events
CompactionStarted
CompactionStarted
CompactionCompleted
CompactionCompleted
CompactionFailed
CompactionFailed
Failure description.
Budget and retry events
BudgetWarning
BudgetWarning
Retrying
Retrying
Hook events
HookStarted / HookCompleted / HookFailed
HookStarted / HookCompleted / HookFailed
HookDenied
HookDenied
HookRewriteApplied / HookPatchPublished
HookRewriteApplied / HookPatchPublished
Skill events
SkillsResolved
SkillsResolved
SkillResolutionFailed
SkillResolutionFailed
Comms events
InteractionComplete / InteractionFailed
InteractionComplete / InteractionFailed
Forward compatibility
UnknownEvent
UnknownEvent
Error handling
All errors inherit fromMeerkatError.
| Class | Description |
|---|---|
MeerkatError | Base error with code, message, details, capability_hint |
CapabilityUnavailableError | Required capability not available |
SessionNotFoundError | Session not found |
SkillNotFoundError | Skill reference cannot be resolved |
Client-side error codes
| Code | Description |
|---|---|
BINARY_NOT_FOUND | rkat-rpc binary not found on PATH and auto-download failed |
BINARY_DOWNLOAD_FAILED | Automatic binary download failed |
NOT_CONNECTED | Operation attempted before connect() |
CONNECTION_CLOSED | rkat-rpc process closed unexpectedly |
VERSION_MISMATCH | Server contract version incompatible with SDK |
CAPABILITY_UNAVAILABLE | Capability check failed via require_capability() |
STREAM_NOT_CONSUMED | EventStream.result accessed before the stream was iterated |
INVALID_ARGS | Mutually exclusive options provided (e.g. realm_id + isolated) |
Server-side error codes
| Code | JSON-RPC code | Description |
|---|---|---|
SESSION_NOT_FOUND | -32001 | Session does not exist |
SESSION_BUSY | -32002 | Turn already in progress |
PROVIDER_ERROR | -32010 | LLM provider error |
BUDGET_EXHAUSTED | -32011 | Budget exceeded |
HOOK_DENIED | -32012 | Hook blocked operation |
AGENT_ERROR | -32013 | Internal agent error |
INVALID_PARAMS | -32602 | Invalid method parameters |
Example
Version compatibility
The SDK negotiates version compatibility duringconnect():
- 0.x: Requires exact minor version match (SDK
0.2.0works with server0.2.x) - 1.0+: Requires same major version
Running tests
See also
- Python SDK overview — getting started, MeerkatClient, and Session API
- TypeScript SDK — TypeScript SDK
- RPC reference — JSON-RPC protocol specification
