| Crates.io | adk-agent |
| lib.rs | adk-agent |
| version | 0.2.1 |
| created_at | 2025-11-30 14:15:17.775042+00 |
| updated_at | 2026-01-22 03:39:32.556817+00 |
| description | Agent implementations for Rust Agent Development Kit (ADK-Rust, LLM, Custom, Workflow agents) |
| homepage | |
| repository | https://github.com/zavora-ai/adk-rust |
| max_upload_size | |
| id | 1958270 |
| size | 256,908 |
Agent implementations for ADK-Rust (LLM, Custom, Workflow agents).
adk-agent provides ready-to-use agent implementations for ADK-Rust:
[dependencies]
adk-agent = "0.1"
Or use the meta-crate:
[dependencies]
adk-rust = { version = "0.1", features = ["agents"] }
use adk_agent::LlmAgentBuilder;
use adk_model::GeminiModel;
use std::sync::Arc;
let model = Arc::new(GeminiModel::new(&api_key, "gemini-2.5-flash")?);
let agent = LlmAgentBuilder::new("assistant")
.description("Helpful AI assistant")
.instruction("Be helpful and concise.")
.model(model)
.tool(Arc::new(calculator_tool))
.build()?;
| Method | Description |
|---|---|
new(name) |
Create builder with agent name |
description(desc) |
Set agent description |
model(llm) |
Set the LLM model (required) |
instruction(text) |
Set static instruction |
instruction_provider(fn) |
Set dynamic instruction provider |
global_instruction(text) |
Set global instruction (shared across agents) |
tool(tool) |
Add a tool |
sub_agent(agent) |
Add a sub-agent for transfers |
input_schema(json) |
Set input JSON schema |
output_schema(json) |
Set output JSON schema |
output_key(key) |
Set state key for output |
input_guardrails(set) |
Add input validation guardrails |
output_guardrails(set) |
Add output validation guardrails |
before_callback(fn) |
Add before-agent callback |
after_callback(fn) |
Add after-agent callback |
before_model_callback(fn) |
Add before-model callback |
after_model_callback(fn) |
Add after-model callback |
before_tool_callback(fn) |
Add before-tool callback |
after_tool_callback(fn) |
Add after-tool callback |
build() |
Build the LlmAgent |
use adk_agent::{SequentialAgent, ParallelAgent, LoopAgent};
use std::sync::Arc;
// Sequential: A -> B -> C
let pipeline = SequentialAgent::new("pipeline", vec![
agent_a.clone(),
agent_b.clone(),
agent_c.clone(),
]);
// Parallel: A, B, C simultaneously
let team = ParallelAgent::new("team", vec![
analyst_a.clone(),
analyst_b.clone(),
]);
// Loop: repeat until exit or max iterations
let iterator = LoopAgent::new("iterator", vec![worker.clone()])
.with_max_iterations(10);
use adk_agent::{ConditionalAgent, LlmConditionalAgent};
// Function-based condition
let conditional = ConditionalAgent::new(
"router",
|ctx| async move { ctx.user_content().text().contains("urgent") },
urgent_agent,
).with_else_agent(normal_agent);
// LLM-powered routing
let llm_router = LlmConditionalAgent::new("smart_router", model)
.instruction("Route to the appropriate specialist based on the query.")
.add_route("support", support_agent, "Technical support questions")
.add_route("sales", sales_agent, "Sales and pricing inquiries")
.build()?;
// Agent with sub-agents for transfer
let coordinator = LlmAgentBuilder::new("coordinator")
.instruction("Route to appropriate specialist. Transfer when needed.")
.model(model)
.sub_agent(support_agent)
.sub_agent(sales_agent)
.build()?;
use adk_agent::LlmAgentBuilder;
use adk_guardrail::{GuardrailSet, ContentFilter, PiiRedactor};
let input_guardrails = GuardrailSet::new()
.with(ContentFilter::harmful_content())
.with(PiiRedactor::new());
let agent = LlmAgentBuilder::new("safe_assistant")
.model(model)
.input_guardrails(input_guardrails)
.build()?;
use adk_agent::CustomAgentBuilder;
let custom = CustomAgentBuilder::new("processor")
.description("Custom data processor")
.handler(|ctx| async move {
// Custom logic here
Ok(Content::new("model").with_text("Processed!"))
})
.build()?;
Agent traitApache-2.0
This crate is part of the ADK-Rust framework for building AI agents in Rust.