ADK.Agent.LlmAgent (ADK v0.0.1-alpha.1)

Copy Markdown View Source

An LLM-powered agent that calls a language model to generate responses, handles tool calls, and loops until a final text response is produced.

This is the primary agent type in ADK Elixir.

Summary

Functions

Build the LLM request from the current context and agent config.

Clone an agent with optional overrides.

Compile the instruction string, merging global + agent instruction and substituting {key} state variables.

Compute the full tool list including auto-generated transfer tools.

Find an agent by name in the tree, or raise with a helpful error.

Get all agent names in the agent tree for error reporting.

Create a new LLM agent.

Compute the list of agents this agent can transfer to.

Types

t()

@type t() :: %ADK.Agent.LlmAgent{
  _peer_agents: term(),
  after_tool_callback: (map(), map(), map(), any() -> any()) | nil,
  before_tool_callback:
    (map(), map(), map() -> {:cont, map()} | {:halt, any()}) | nil,
  context_compressor: keyword() | nil,
  description: String.t(),
  disallow_transfer_to_parent: boolean(),
  disallow_transfer_to_peers: boolean(),
  generate_config: map(),
  global_instruction: String.t() | nil,
  instruction: String.t() | (map() -> String.t()),
  max_iterations: pos_integer(),
  model: String.t(),
  name: String.t(),
  on_tool_error_callback:
    (map(), map(), map(), term() ->
       {:retry, any()} | {:fallback, any()} | {:error, any()})
    | nil,
  output_key: atom() | String.t() | nil,
  output_schema: map() | nil,
  parent_agent: t() | nil,
  planner: struct() | nil,
  sub_agents: [map()],
  tools: [map()]
}

Functions

build_request(ctx, agent)

@spec build_request(ADK.Context.t(), t()) :: map()

Build the LLM request from the current context and agent config.

clone(agent, overrides \\ %{})

@spec clone(t(), map()) :: t()

Clone an agent with optional overrides.

compile_instruction(ctx, agent)

@spec compile_instruction(ADK.Context.t(), t()) :: String.t()

Compile the instruction string, merging global + agent instruction and substituting {key} state variables.

effective_tools(agent)

@spec effective_tools(t()) :: [map()]

Compute the full tool list including auto-generated transfer tools.

get_agent_to_run(root_agent, agent_name)

@spec get_agent_to_run(t(), String.t()) :: {:ok, t()}

Find an agent by name in the tree, or raise with a helpful error.

get_available_agent_names(root_agent)

@spec get_available_agent_names(t()) :: [String.t()]

Get all agent names in the agent tree for error reporting.

new(opts)

@spec new(keyword()) :: t()

Create a new LLM agent.

Applies any skills from the :skills option, builds the struct, and wires parent/peer references for sub-agent transfer.

transfer_targets(agent)

@spec transfer_targets(t()) :: [t()]

Compute the list of agents this agent can transfer to.

Includes sub-agents, parent (if not disallowed), and peer siblings (if not disallowed).