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:

§What’s New in 0.6.0

  • ParallelAgent::with_shared_state(): Opt-in builder method that creates a fresh SharedState per run() invocation, enabling sub-agents to exchange data via set_shared/get_shared/wait_for_key through the context chain.
  • AgentToolContext delegation: Tools executed by LlmAgent now have access to shared_state() via the context chain, enabling tool-level coordination in parallel workflows.
  • Tool confirmation: LlmAgentBuilder::require_tool_confirmation() and require_tool_confirmation_for_all() for human-in-the-loop tool authorization.

§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).