Skip to main content

Crate adk_agent

Crate adk_agent 

Source
Expand description

§adk-agent

Agent implementations for ADK (LLM, Custom, Workflow agents).

§Overview

This crate provides ready-to-use agent implementations:

§Quick Start

use adk_agent::LlmAgentBuilder;
use std::sync::Arc;

// LLM Agent requires a model (from adk-model)
// let agent = LlmAgentBuilder::new("assistant")
//     .description("Helpful AI assistant")
//     .model(Arc::new(model))
//     .build()?;

§Workflow Agents

Combine agents for complex workflows:

// Sequential: A -> B -> C
let seq = SequentialAgent::new("pipeline", vec![a, b, c]);

// Parallel: A, B, C simultaneously
let par = ParallelAgent::new("team", vec![a, b, c]);

// Loop: repeat until exit
let loop_agent = LoopAgent::new("iterator", vec![worker]).with_max_iterations(10);

§Guardrails (optional)

Enable the guardrails feature for input/output validation:

use adk_agent::{LlmAgentBuilder, guardrails::{GuardrailSet, ContentFilter, PiiRedactor}};

let input_guardrails = GuardrailSet::new()
    .with(ContentFilter::harmful_content())
    .with(PiiRedactor::new());

let agent = LlmAgentBuilder::new("assistant")
    .input_guardrails(input_guardrails)
    .build()?;

Re-exports§

pub use compaction::LlmEventSummarizer;
pub use guardrails::GuardrailSet;
pub use tool_call_markup::normalize_content;
pub use tool_call_markup::normalize_option_content;

Modules§

compaction
LLM-based event summarizer for context compaction.
guardrails
Guardrail integration for LlmAgent
tool_call_markup
XML-based tool call markup parsing.

Structs§

ConditionalAgent
Rule-based conditional routing agent.
CustomAgent
CustomAgentBuilder
LlmAgent
LlmAgentBuilder
LlmConditionalAgent
LLM-based intelligent conditional routing agent.
LlmConditionalAgentBuilder
LoopAgent
Loop agent executes sub-agents repeatedly for N iterations or until escalation
ParallelAgent
Parallel agent executes sub-agents concurrently
SequentialAgent
Sequential agent executes sub-agents once in order

Constants§

DEFAULT_LOOP_MAX_ITERATIONS
Default maximum iterations for LoopAgent when none is specified. Prevents infinite loops from consuming unbounded resources.
DEFAULT_MAX_ITERATIONS
Default maximum number of LLM round-trips (iterations) before the agent stops.
DEFAULT_TOOL_TIMEOUT
Default tool execution timeout (5 minutes).

Traits§

Agent

Type Aliases§

AfterToolCallbackFull
Rich after-tool callback that receives the tool, arguments, and response.
OnToolErrorCallback
Callback invoked when a tool execution fails (after retries are exhausted).