Skip to main content

adk_agent/
lib.rs

1//! # adk-agent
2#![allow(clippy::result_large_err)]
3//!
4//! Agent implementations for ADK (LLM, Custom, Workflow agents).
5//!
6//! ## Overview
7//!
8//! This crate provides ready-to-use agent implementations:
9//!
10//! - [`LlmAgent`] - Core agent powered by LLM reasoning
11//! - [`CustomAgent`] - Define custom logic without LLM
12//! - [`SequentialAgent`] - Execute agents in sequence
13//! - [`ParallelAgent`] - Execute agents concurrently
14//! - [`LoopAgent`] - Iterate until exit condition
15//! - [`ConditionalAgent`] - Branch based on conditions
16//!
17//! ## Quick Start
18//!
19//! ```rust,no_run
20//! use adk_agent::LlmAgentBuilder;
21//! use std::sync::Arc;
22//!
23//! // LLM Agent requires a model (from adk-model)
24//! // let agent = LlmAgentBuilder::new("assistant")
25//! //     .description("Helpful AI assistant")
26//! //     .model(Arc::new(model))
27//! //     .build()?;
28//! ```
29//!
30//! ## Workflow Agents
31//!
32//! Combine agents for complex workflows:
33//!
34//! ```rust,ignore
35//! // Sequential: A -> B -> C
36//! let seq = SequentialAgent::new("pipeline", vec![a, b, c]);
37//!
38//! // Parallel: A, B, C simultaneously
39//! let par = ParallelAgent::new("team", vec![a, b, c]);
40//!
41//! // Loop: repeat until exit
42//! let loop_agent = LoopAgent::new("iterator", vec![worker]).with_max_iterations(10);
43//! ```
44//!
45//! ## Guardrails (optional)
46//!
47//! Enable the `guardrails` feature for input/output validation:
48//!
49//! ```rust,ignore
50//! use adk_agent::{LlmAgentBuilder, guardrails::{GuardrailSet, ContentFilter, PiiRedactor}};
51//!
52//! let input_guardrails = GuardrailSet::new()
53//!     .with(ContentFilter::harmful_content())
54//!     .with(PiiRedactor::new());
55//!
56//! let agent = LlmAgentBuilder::new("assistant")
57//!     .input_guardrails(input_guardrails)
58//!     .build()?;
59//! ```
60
61pub mod compaction;
62mod custom_agent;
63pub mod guardrails;
64mod llm_agent;
65pub mod tool_call_markup;
66mod workflow;
67
68pub use adk_core::AfterToolCallbackFull;
69pub use adk_core::Agent;
70pub use adk_core::OnToolErrorCallback;
71pub use compaction::LlmEventSummarizer;
72pub use custom_agent::{CustomAgent, CustomAgentBuilder};
73pub use guardrails::GuardrailSet;
74pub use llm_agent::{DEFAULT_MAX_ITERATIONS, DEFAULT_TOOL_TIMEOUT, LlmAgent, LlmAgentBuilder};
75pub use tool_call_markup::{normalize_content, normalize_option_content};
76pub use workflow::{
77    ConditionalAgent, DEFAULT_LOOP_MAX_ITERATIONS, LlmConditionalAgent, LlmConditionalAgentBuilder,
78    LoopAgent, ParallelAgent, SequentialAgent,
79};