agent-sdk 0.9.1

Rust Agent SDK for building LLM agents
Documentation

agent-sdk

crates.io docs.rs Rust 1.91+ MIT

A Rust SDK for building AI agents powered by large language models. Agents reason, call tools, and take actions through a streaming, event-driven loop.

[dependencies]
agent-sdk = "0.8"
tokio = { version = "1", features = ["rt-multi-thread", "macros"] }
anyhow = "1"

Quickstart — ask()

The 30-second path: build an agent, ask a question, get the answer. ask() builds the tool context and cancellation token for you and returns the assembled assistant text.

use agent_sdk::prelude::*;
use agent_sdk::ThreadId;

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    let agent = builder::<()>()
        .provider(AnthropicProvider::from_env()) // reads ANTHROPIC_API_KEY
        .build();

    let answer = agent.ask(ThreadId::new(), "What is the capital of France?").await?;
    println!("{answer}");
    Ok(())
}

use agent_sdk::prelude::*; brings the dozen names a newcomer needs: the builder, config + I/O types, the Tool surface, the in-memory event store, the cancellation token, and the default AnthropicProvider. When you need application context, a confirmation flow, explicit cancellation, or the raw run state, drop down to run().

Features

The default build is lightweight: a plain cargo add agent-sdk enables only the anthropic provider and the core runtime — no sqlx, tonic, lapin, prost, or opentelemetry. Everything else is opt-in:

Feature Enables
anthropic (default) Anthropic (Claude) provider
openai OpenAI Chat Completions provider
openai-codex OpenAI Codex / Responses provider
gemini Google Gemini provider
vertex Google Vertex AI provider
cloudflare Cloudflare Workers AI provider
web Web search + URL fetch tools (pulls in html2text)
mcp Model Context Protocol client (stdio + streamable-HTTP/SSE)
skills Skill / command loading from markdown
otel OpenTelemetry spans
agent-sdk = { version = "0.8", features = ["openai", "gemini", "web", "mcp"] }

Cookbook

Runnable recipes for the common building blocks live in COOKBOOK.md and as compiling examples under examples/: typed tools (TypedTool), schema-validated structured output, streaming, MCP (including the HTTP transport), durable serving, and human-in-the-loop (HITL) confirmation.

cargo run --example basic_agent
cargo run --example typed_tool
cargo run --example streaming
cargo run --example mcp_http_remote --features mcp

Documentation

License

MIT. See LICENSE.