Rust SDK
rho-sdk is Rho's embeddable, headless Rust agent runtime. It provides provider-neutral messages, sessions, completion and streaming runs, custom provider and tool extension points, cancellation, host input, compaction, workspace policy, approvals, diagnostics, and versioned snapshots.
rho-sdk 1.0.0 is published on crates.io. The pages in this section document the stable 1.0 public API and compatibility policy. See known limitations for behavior that did not fully meet the drafted release-candidate gates before publication.
Start here
- Read installation and support for dependency, runtime, platform, feature, and Rust-version status.
- Read concepts to understand runtime, session, run, and host ownership.
- Choose or implement a provider.
- Register only the tools and capabilities the host intends to grant.
- Consume events and cancellation and persist session snapshots as needed.
- Review the security model and threat model before enabling sensitive operations.
Current capability map
| Capability | Current SDK contract |
|---|---|
| Final answer | Session::complete returns a typed RunOutcome |
| Streaming | Session::start returns a bounded, ordered RunEvent stream |
| Providers | Public ModelProvider trait and deterministic ScriptedProvider |
| Tools | Public Tool trait, registry, progress metadata, host input, and scoped authorization |
| Sessions | One mutable run at a time, explicit history inspection, reset, provider replacement, and reasoning changes |
| Cancellation | Shared cooperative token, run cancellation handle, runtime shutdown, and safe run-drop fallback |
| Compaction | Host-supplied Compactor, optional automatic policy, explicit manual compaction |
| Persistence | Versioned JSON SessionSnapshot and an atomic in-memory adapter, with no SQLite requirement |
| Security | No sensitive capability by default; workspace, policy, approval handler, provider, and tools are host supplied |
| Diagnostics | Secret-free-by-contract configuration snapshot, subject to adapter redaction obligations |
Examples
The repository contains compiling examples for:
- simple completion
- streaming
- custom providers
- custom tools
- cancellation
- image history
- snapshots
- questionnaires and approvals
Run one from a repository checkout:
bash
cargo run -p rho-sdk --example simple_completionDocumentation map
- Installation and support
- Concepts and ownership
- Providers
- Tools, workspaces, and approvals
- Sessions, compaction, and persistence
- Events, retries, cancellation, drop, and shutdown
- Compatibility and public contracts
- Security model
- Threat model
- Redaction audit procedure
- Upgrade guide for 1.0
- Release-candidate process