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 team::BlackboardHistoryPolicy;
pub use team::BlackboardPolicy;
pub use team::BlackboardSchedule;
pub use team::BlackboardSpec;
pub use team::BlackboardTransition;
pub use team::CircuitBreakerPolicy;
pub use team::CompiledBlackboardTeam;
pub use team::CompiledTeam;
pub use team::RelationshipApprovalPolicy;
pub use team::RelationshipFailureStrategy;
pub use team::RelationshipKind;
pub use team::RelationshipPolicy;
pub use team::ResolvedTeamMember;
pub use team::StaticTeamAgentRegistry;
pub use team::TEAM_EDGE_ID_KEY;
pub use team::TEAM_EXECUTION_STATE_KEY;
pub use team::TEAM_ROOT_INVOCATION_KEY;
pub use team::TeamAgentDescriptor;
pub use team::TeamAgentHealth;
pub use team::TeamAgentRegistry;
pub use team::TeamArchitectureTemplate;
pub use team::TeamBudget;
pub use team::TeamContextPolicy;
pub use team::TeamEdgeExecution;
pub use team::TeamError;
pub use team::TeamExecutionAnalysis;
pub use team::TeamExecutionSnapshot;
pub use team::TeamExecutionStatus;
pub use team::TeamExecutionUsage;
pub use team::TeamFailurePolicy;
pub use team::TeamHistoryPolicy;
pub use team::TeamLifecycleContext;
pub use team::TeamLifecycleDecision;
pub use team::TeamLifecycleHook;
pub use team::TeamLifecycleOutcome;
pub use team::TeamLifecyclePhase;
pub use team::TeamManagerBranch;
pub use team::TeamMemberSpec;
pub use team::TeamPolicy;
pub use team::TeamRegistryRequirement;
pub use team::TeamRelationship;
pub use team::TeamReplayError;
pub use team::TeamResumePlan;
pub use team::TeamResumePolicy;
pub use team::TeamRuntimeError;
pub use team::TeamSpec;
pub use team::TeamStateMergePolicy;
pub use team::TeamTerminationPolicy;
pub use team::WorkflowArchitectureTemplate;
pub use team::analyze_team_execution;
pub use team::validate_team_replay;
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
team
Portable, validated multi-agent team composition.
tool_call_markup
XML-based tool call markup parsing.

Structs§

ConditionalAgent
Rule-based conditional routing agent.
CustomAgent
An agent with a user-defined async handler function.
CustomAgentBuilder
Builder for constructing a CustomAgent.
LlmAgent
An LLM-powered agent that orchestrates tool calls and sub-agent delegation.
LlmAgentBuilder
Builder for constructing an LlmAgent with all configuration options.
LlmConditionalAgent
LLM-based intelligent conditional routing agent.
LlmConditionalAgentBuilder
Builder for constructing an LlmConditionalAgent.
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
The fundamental trait for all ADK agents.

Functions§

extract_typed
Extract a typed value from agent events.

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