Build serious agents
in Rust.
adk-rs is a code-first Agent Development Kit for Rust: model-agnostic, deployment-agnostic agent construction with the low overhead, predictable latency and safety guarantees of the Rust toolchain.
use adk_rs::{agents::LlmAgent, providers::gemini::Gemini, runner::Runner};
use adk_rs::services::mem::InMemorySessionService;
use futures::StreamExt;
use std::sync::Arc;
#[tokio::main]
async fn main() -> adk_rs::Result<()> {
let agent = LlmAgent::builder("greeter")
.model(Arc::new(Gemini::from_env("gemini-2.5-flash")?))
.instruction("You greet the user warmly.")
.build()?;
let runner = Runner::builder()
.app_name("hello")
.agent(Arc::new(agent))
.session_service(Arc::new(InMemorySessionService::new()))
.build()?;
let mut events = runner.run("user", None, "Hello!").await?;
while let Some(event) = events.next().await {
if let Some(content) = event?.response.content {
println!("{}", content.text_concat());
}
}
Ok(())
}Everything an agent runtime needs, behind cargo features.
Composable agents
LlmAgent, SequentialAgent, ParallelAgent and LoopAgent nest through one BaseAgent trait, driven by a unified tokio event stream.
02 /Three first-class providers
Gemini (REST + SSE), Anthropic Claude, and an OpenAI-compatible client that also reaches Azure, Ollama and Groq — all behind one Model trait.
03 /The #[tool] macro
Annotate any async fn and the macro derives the JSON schema, FunctionDeclaration and Tool impl. Manual impls stay available.
04 /Pluggable services
Session, memory, artifact and credential traits with in-memory, filesystem, SQLite and PostgreSQL backends out of the box.
05 /MCP & OpenAPI toolsets
Mount tools from any Model Context Protocol server (stdio or streamable HTTP) or generate one tool per operation from an OpenAPI 3.x spec.
06 /A2A protocol
Spec-compliant Agent-to-Agent JSON-RPC client and server bridge — interoperate with any A2A agent in either direction.
07 /Human-in-the-loop
Tool confirmation, interactive auth consent, long-running tools, cancellation and resumable invocations are built into the runtime.
08 /Sandboxed code execution
Run model-emitted code in a local subprocess or a locked-down Docker container: no network, read-only rootfs, dropped capabilities.
09 /Serve, evaluate, observe
An axum dev server compatible with the adk-web UI, a JSON eval-set framework, and tracing with optional OTLP export.
Runnable demos, straight from the repo.
Minimal single-agent loop: one turn against Gemini, events streamed to stdout.
examples/weather_agent.rsA #[tool]-defined function tool, with tool calls and responses printed live.
examples/three_providers.rsThe same prompt against Gemini, Claude and OpenAI through one Model trait.
examples/code_agent.rsA scripted MockModel emits shell snippets; LocalCodeExecutor runs them.