agent-sdk-rs is a lightweight Rust agent framework inspired by browser-use's SDK design.
It is intentionally minimal:
- small surface area
- explicit control flow
- simple tool integration
- easy embedding into Rust binaries
This project is expected to stay lightweight by default. New features should preserve that core philosophy.
A Rust SDK for tool-using agents with:
- an
Agentloop query+query_stream- provider adapter boundary
- tool execution + dependency injection
- explicit completion semantics via
done
Implemented:
- Anthropic provider adapter (
anthropic-ai-sdk) Agent+ builder APIqueryandquery_stream- event stream model (
MessageStart,StepStart,ToolCall,ToolResult,FinalResponse, etc.) - tool registration with JSON schema
- dependency map + dependency overrides
- translated Claude-code-style tool set:
bash,read,write,editglob_search,greptodo_read,todo_writedone
- optional
claude_codebinary target
Out of scope right now:
- non-Anthropic providers
- Laminar integration
Near-term:
- Add xAI Grok provider adapter (next)
- Keep adapter trait stable across providers
- Improve docs/examples while keeping core small
Non-goal:
- turning this into a heavy orchestration framework
[dependencies]
agent-sdk-rs = "0.1.0"use agent_sdk_rs::{Agent, AnthropicModel};
let model = AnthropicModel::from_env("claude-sonnet-4-5")?;
let mut agent = Agent::builder().model(model).build()?;
let answer = agent.query("Hello").await?;
println!("{answer}");
# Ok::<(), Box<dyn std::error::Error>>(())use agent_sdk_rs::{Agent, AgentEvent, AnthropicModel};
use futures_util::StreamExt;
let model = AnthropicModel::from_env("claude-sonnet-4-5")?;
let mut agent = Agent::builder().model(model).build()?;
let stream = agent.query_stream("Solve this step by step");
futures_util::pin_mut!(stream);
while let Some(event) = stream.next().await {
match event? {
AgentEvent::ToolCall { tool, .. } => println!("tool: {tool}"),
AgentEvent::FinalResponse { content } => println!("final: {content}"),
_ => {}
}
}
# Ok::<(), Box<dyn std::error::Error>>(())use agent_sdk_rs::tools::claude_code::{SandboxContext, all_tools};
use agent_sdk_rs::{Agent, AnthropicModel};
let model = AnthropicModel::from_env("claude-sonnet-4-5")?;
let sandbox = SandboxContext::create::<std::path::PathBuf>(None)?;
let mut agent = Agent::builder()
.model(model)
.tools(all_tools())
.dependency(sandbox)
.require_done_tool(true)
.build()?;
# Ok::<(), Box<dyn std::error::Error>>(())Run the fun Claude-code-like binary:
cargo run --features claude-code --bin claude_code -- "list Rust files and summarize"Environment:
ANTHROPIC_API_KEYrequiredANTHROPIC_MODELoptional (default set in binary)CLAUDE_CODE_SANDBOXoptional
cargo run --example local_loop
cargo run --example di_overrideMIT. See LICENSE.