Class ConfigAgentUtils

java.lang.Object
com.google.adk.agents.ConfigAgentUtils

public final class ConfigAgentUtils extends Object
Utility class for loading agent configurations from YAML files.

TODO: Config agent features are not yet ready for public use.

  • Method Details

    • resolveAndSetCommonAgentFields

      public static void resolveAndSetCommonAgentFields(BaseAgent.Builder<?> builder, BaseAgentConfig config, String configAbsPath) throws ConfigAgentUtils.ConfigurationException
      Configures the common properties of an agent builder from the configuration.
      Parameters:
      builder - The agent builder.
      config - The agent configuration.
      configAbsPath - The absolute path to the config file (for resolving relative paths).
      Throws:
      ConfigAgentUtils.ConfigurationException - if the configuration is invalid.
    • resolveAndSetCallback

      public static <T> void resolveAndSetCallback(@Nullable List<BaseAgentConfig.CallbackRef> refs, Class<T> callbackBaseClass, String callbackTypeName, Consumer<com.google.common.collect.ImmutableList<T>> builderSetter) throws ConfigAgentUtils.ConfigurationException
      Resolves and sets callbacks from configuration.
      Type Parameters:
      T - The type of the callback.
      Parameters:
      refs - The list of callback references from config.
      callbackBaseClass - The base class of the callback.
      callbackTypeName - The name of the callback type for error messages.
      builderSetter - The setter method on the builder to apply the resolved callbacks.
      Throws:
      ConfigAgentUtils.ConfigurationException - if a callback cannot be resolved.
    • setBaseAgentCallbacks

      public static void setBaseAgentCallbacks(BaseAgentConfig config, Consumer<com.google.common.collect.ImmutableList<com.google.adk.agents.Callbacks.BeforeAgentCallbackBase>> beforeSetter, Consumer<com.google.common.collect.ImmutableList<com.google.adk.agents.Callbacks.AfterAgentCallbackBase>> afterSetter) throws ConfigAgentUtils.ConfigurationException
      Sets the common agent callbacks (before/after agent) from the config to the builder setters.
      Parameters:
      config - The agent configuration.
      beforeSetter - The setter for before-agent callbacks.
      afterSetter - The setter for after-agent callbacks.
      Throws:
      ConfigAgentUtils.ConfigurationException - if a callback cannot be resolved.
    • fromConfig

      public static BaseAgent fromConfig(String configPath) throws ConfigAgentUtils.ConfigurationException
      Load agent from a YAML config file path.
      Parameters:
      configPath - the path to a YAML config file
      Returns:
      the created agent instance as a BaseAgent
      Throws:
      ConfigAgentUtils.ConfigurationException - if loading fails
    • resolveSubAgents

      public static com.google.common.collect.ImmutableList<BaseAgent> resolveSubAgents(List<BaseAgentConfig.AgentRefConfig> subAgentConfigs, String configAbsPath) throws ConfigAgentUtils.ConfigurationException
      Resolves subagent configurations into actual BaseAgent instances. This method is used by concrete agent implementations to resolve their subagents.
      Parameters:
      subAgentConfigs - The list of subagent configurations
      configAbsPath - The absolute path to the parent config file for resolving relative paths
      Returns:
      A list of resolved BaseAgent instances
      Throws:
      ConfigAgentUtils.ConfigurationException - if any subagent fails to resolve