honcho-ai
Rust SDK for Honcho — AI agent memory and social cognition infrastructure.
Status: Beta — full API parity with Python/TypeScript SDKs. Production-ready for async Rust.
What is Honcho?
Honcho is an AI agent memory platform that provides persistent, contextual memory and social cognition for LLM agents. It enables your agents to:
- Remember past interactions across sessions and users
- Understand social context — who knows what about whom
- Reason dialectically — query and synthesize knowledge across peers
- Evolve self-representation and peer models over time
This crate is a native Rust client for the Honcho API (v3), with 100% parity with the official Python and TypeScript SDKs.
Installation
Add to your Cargo.toml:
[]
= "0.1"
= { = "1", = ["full"] }
Or via cargo:
Quickstart
use Honcho;
async
Key Concepts
| Concept | Description |
|---|---|
| Workspace | Isolated container for peers, sessions, and all memory data |
| Peer | An identity (user or AI agent) with persistent memory, a dynamic representation, and a peer card of key facts |
| Session | A conversation context grouping messages between peers |
| Message | A unit of communication belonging to a peer within a session |
| Dialectic Chat | LLM-powered reasoning over all available context — the "query the memory" layer |
| Conclusion | A durable fact about a peer, formed through the dialectic process |
| Dream | Background memory consolidation task, triggered by schedule_dream |
Core API
Client (Honcho)
let client = new?;
// Workspace management
client.force_ensure.await?; // ensure workspace exists
client.get_metadata.await?; // fetch metadata
client.set_metadata.await?; // set metadata
client.get_configuration.await?; // typed config
client.delete_workspace.await?; // delete workspace
// Paginated listing
let peers_page = client.peers.await?;
let sessions_page = client.sessions.await?;
let workspaces_page = client.workspaces.await?;
// Search & dream
let results = client.search.await?;
client.schedule_dream.await?;
Peer
let peer = client.peer.await?;
// Dialectic chat
let reply = peer.chat.await?;
let reply = peer.chat_with_options.await?;
let stream = peer.chat_stream.send.await?;
// Representation & context
let rep = peer.representation.await?;
let ctx = peer.context.await?;
let ctx = peer.context_with_target.await?;
// Peer card (key facts)
let card = peer.get_card.await?;
peer.set_card.await?;
// Conclusions
peer.conclusions.list.send.await?;
peer.conclusions.create.await?;
peer.conclusions.delete.await?;
let cross = peer.conclusions_of; // cross-peer conclusions
// Search & sessions
let results = peer.search.await?;
let page = peer.sessions.await?;
// Metadata CRUD
peer.refresh.await?;
peer.get_metadata.await?;
peer.set_metadata.await?;
peer.update.await?; // patch update
Session
let session = client.session.await?;
// Messages (batch up to 100 per call)
let msgs = session.add_messages.await?;
let page = session.messages.await?;
let msg = session.get_message.await?;
let msg = session.update_message.await?;
// File upload — typed sources (Rust-only feature)
use FileSource;
let msgs = session.upload_file.peer.send.await?;
let msgs = session.upload_file.peer.send.await?;
// Peer management
session.add_peer.await?;
session.set_peers.await?;
session.remove_peers.await?;
// Context & search
let ctx = session.context.await?;
let results = session.search.await?;
let summaries = session.summaries.await?;
// Clone & delete
let cloned = session.clone_session.await?;
session.delete.await?;
Error Handling
use HonchoError;
match client.peer.await
The SDK auto-retries transient errors (2 retries, exponential backoff, respects Retry-After). You don't need to implement your own retry loop for timeouts, connection errors, 429, or 5xx responses.
Features
| Feature | Default | Description |
|---|---|---|
rustls-tls |
✓ | TLS via rustls (recommended) |
native-tls |
TLS via platform-native backend | |
blocking |
Synchronous API for non-async contexts | |
tracing |
Emit tracing spans for all API calls |
Blocking API
Enable the blocking feature for synchronous usage:
= { = "0.1", = ["blocking"] }
use Honcho;
let client = new?;
let peer = client.peer?;
let reply = peer.chat?;
Note: The blocking API uses an internal
tokioruntime. It will panic if you call it from within an existing async context — use the async API instead.
Rust-Only Features
These APIs have no equivalent in the Python/TypeScript SDKs:
| Feature | Description |
|---|---|
FileSource enum |
Typed file upload sources: bytes(), path(), stream() |
Honcho::force_ensure() |
Explicit workspace creation (normally lazy via ensure_workspace) |
Peer::conclusions() / Peer::conclusions_of() |
Scoped conclusion handles with lazy evaluation |
DialecticStream::is_complete() |
Check stream completion without consuming |
Pagination
All list endpoints return a Page<T> with 1-based page numbers:
// Default: page 1, 50 items
let page = client.peers.await?;
println!;
for peer in page.items
// Auto-fetch all pages
use StreamExt;
let stream = page.into_stream;
pin!;
while let Some = stream.next.await
// Manual pagination
let mut page = client.sessions_with_filters.await?;
while page.has_next
Environment Variables
| Variable | Field | Default |
|---|---|---|
HONCHO_API_KEY |
API key | None |
HONCHO_URL / HONCHO_API_URL |
Base URL | https://api.honcho.dev |
HONCHO_WORKSPACE_ID |
Workspace ID | "default" |
Explicit builder arguments take precedence over environment variables.
Parity with Official SDKs
| Feature | Python | TypeScript | Rust |
|---|---|---|---|
| Peer CRUD | ✓ | ✓ | ✓ |
| Session CRUD | ✓ | ✓ | ✓ |
| Messages (batch) | ✓ | ✓ | ✓ |
| Dialectic chat (text) | ✓ | ✓ | ✓ |
| Streaming chat (SSE) | ✓ | ✓ | ✓ |
| Representation | ✓ | ✓ | ✓ |
| Peer card | ✓ | ✓ | ✓ |
| Conclusions | ✓ | ✓ | ✓ |
| File upload | ✓ | ✓ | ✓ |
| Context (OpenAI/Anthropic) | ✓ | ✓ | ✓ |
| API key auth | ✓ | ✓ | ✓ |
| Paginated listing | ✓ | ✓ | ✓ |
| Typed file sources | — | — | ✓ |
| Scoped conclusions | — | — | ✓ |
force_ensure |
— | — | ✓ |
Requirements
- Rust 1.88.0 or later (edition 2024)
- Tokio async runtime (multi-thread)
- Honcho server (local or api.honcho.dev)
Links
License
MIT — see LICENSE.md.
Built by Leszek. Not affiliated with Plastic Labs — community-maintained with the intent to contribute upstream.