ADK.Agent.Tree (adk_ex v1.1.0)

Copy Markdown View Source

Utilities for working with agent trees (hierarchies of agents and sub-agents).

Summary

Functions

Builds a map from child agent name to parent agent.

Finds an agent by name using depth-first search.

Validates that all agent names in the tree are unique.

Functions

build_parent_map(root)

@spec build_parent_map(struct()) :: %{required(String.t()) => struct()}

Builds a map from child agent name to parent agent.

find_agent(agent, target_name)

@spec find_agent(
  struct(),
  String.t()
) :: {:ok, struct()} | :error

Finds an agent by name using depth-first search.

Returns {:ok, agent} if found, :error otherwise.

validate_unique_names(root)

@spec validate_unique_names(struct()) :: {:ok, MapSet.t()} | {:error, String.t()}

Validates that all agent names in the tree are unique.

Returns {:ok, names} where names is the set of all names, or {:error, reason} if duplicates are found.