adk_agent/lib.rs
1//! # adk-agent
2#![allow(clippy::result_large_err)]
3#![deny(missing_docs)]
4//!
5//! Agent implementations for ADK (LLM, Custom, Workflow agents).
6//!
7//! ## Overview
8//!
9//! This crate provides ready-to-use agent implementations:
10//!
11//! - [`LlmAgent`] - Core agent powered by LLM reasoning
12//! - [`CustomAgent`] - Define custom logic without LLM
13//! - [`SequentialAgent`] - Execute agents in sequence
14//! - [`ParallelAgent`] - Execute agents concurrently, with optional [`SharedState`](adk_core::SharedState) coordination
15//! - [`LoopAgent`] - Iterate until exit condition
16//! - [`ConditionalAgent`] - Branch based on conditions
17//!
18//! ## What's New in 0.6.0
19//!
20//! - **`ParallelAgent::with_shared_state()`**: Opt-in builder method that creates a fresh
21//! [`SharedState`](adk_core::SharedState) per `run()` invocation, enabling sub-agents to
22//! exchange data via `set_shared`/`get_shared`/`wait_for_key` through the context chain.
23//! - **`AgentToolContext` delegation**: Tools executed by `LlmAgent` now have access to
24//! `shared_state()` via the context chain, enabling tool-level coordination in parallel workflows.
25//! - **Tool confirmation**: `LlmAgentBuilder::require_tool_confirmation()` and
26//! `require_tool_confirmation_for_all()` for human-in-the-loop tool authorization.
27//!
28//! ## Quick Start
29//!
30//! ```rust,no_run
31//! use adk_agent::LlmAgentBuilder;
32//! use std::sync::Arc;
33//!
34//! // LLM Agent requires a model (from adk-model)
35//! // let agent = LlmAgentBuilder::new("assistant")
36//! // .description("Helpful AI assistant")
37//! // .model(Arc::new(model))
38//! // .build()?;
39//! ```
40//!
41//! ## Workflow Agents
42//!
43//! Combine agents for complex workflows:
44//!
45//! ```rust,ignore
46//! // Sequential: A -> B -> C
47//! let seq = SequentialAgent::new("pipeline", vec![a, b, c]);
48//!
49//! // Parallel: A, B, C simultaneously
50//! let par = ParallelAgent::new("team", vec![a, b, c]);
51//!
52//! // Loop: repeat until exit
53//! let loop_agent = LoopAgent::new("iterator", vec![worker]).with_max_iterations(10);
54//! ```
55//!
56//! ## Guardrails (optional)
57//!
58//! Enable the `guardrails` feature for input/output validation:
59//!
60//! ```rust,ignore
61//! use adk_agent::{LlmAgentBuilder, guardrails::{GuardrailSet, ContentFilter, PiiRedactor}};
62//!
63//! let input_guardrails = GuardrailSet::new()
64//! .with(ContentFilter::harmful_content())
65//! .with(PiiRedactor::new());
66//!
67//! let agent = LlmAgentBuilder::new("assistant")
68//! .input_guardrails(input_guardrails)
69//! .build()?;
70//! ```
71
72pub mod compaction;
73mod custom_agent;
74pub mod guardrails;
75mod llm_agent;
76mod skill_shim;
77pub mod tool_call_markup;
78mod workflow;
79
80pub use adk_core::AfterToolCallbackFull;
81pub use adk_core::Agent;
82pub use adk_core::OnToolErrorCallback;
83pub use compaction::LlmEventSummarizer;
84pub use custom_agent::{CustomAgent, CustomAgentBuilder};
85pub use guardrails::GuardrailSet;
86pub use llm_agent::{DEFAULT_MAX_ITERATIONS, DEFAULT_TOOL_TIMEOUT, LlmAgent, LlmAgentBuilder};
87pub use tool_call_markup::{normalize_content, normalize_option_content};
88pub use workflow::{
89 ConditionalAgent, DEFAULT_LOOP_MAX_ITERATIONS, LlmConditionalAgent, LlmConditionalAgentBuilder,
90 LoopAgent, ParallelAgent, SequentialAgent,
91};