adk-agent
Agent implementations for ADK-Rust (LLM, Custom, Workflow agents).
Overview
adk-agent provides ready-to-use agent implementations for ADK-Rust:
- LlmAgent - Core agent powered by LLM reasoning with tools and callbacks
- CustomAgent - Define custom logic without LLM
- SequentialAgent - Execute agents in sequence
- ParallelAgent - Execute agents concurrently
- LoopAgent - Iterate until exit condition or max iterations
- ConditionalAgent - Branch based on conditions
- LlmConditionalAgent - LLM-powered routing to sub-agents
Installation
[]
= "0.1"
Or use the meta-crate:
[]
= { = "0.1", = ["agents"] }
Quick Start
LLM Agent
use LlmAgentBuilder;
use GeminiModel;
use Arc;
let model = new;
let agent = new
.description
.instruction
.model
.tool
.build?;
LlmAgentBuilder Methods
| 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 |
Workflow Agents
use ;
use Arc;
// Sequential: A -> B -> C
let pipeline = new;
// Parallel: A, B, C simultaneously
let team = new;
// Loop: repeat until exit or max iterations
let iterator = new
.with_max_iterations;
Conditional Agents
use ;
// Function-based condition
let conditional = new.with_else_agent;
// LLM-powered routing
let llm_router = new
.instruction
.add_route
.add_route
.build?;
Multi-Agent Systems
// Agent with sub-agents for transfer
let coordinator = new
.instruction
.model
.sub_agent
.sub_agent
.build?;
Guardrails
use LlmAgentBuilder;
use ;
let input_guardrails = new
.with
.with;
let agent = new
.model
.input_guardrails
.build?;
Custom Agent
use CustomAgentBuilder;
let custom = new
.description
.handler
.build?;
Features
- Automatic tool execution loop
- Agent transfer between sub-agents
- Streaming event output
- Callback hooks at every stage
- Input/output guardrails
- Schema validation
Related Crates
- adk-rust - Meta-crate with all components
- adk-core - Core
Agenttrait - adk-model - LLM integrations
- adk-tool - Tool system
- adk-guardrail - Guardrails
License
Apache-2.0
Part of ADK-Rust
This crate is part of the ADK-Rust framework for building AI agents in Rust.