Class ConfigAgentLoader

java.lang.Object
com.google.adk.maven.ConfigAgentLoader
All Implemented Interfaces:
AgentLoader

@ThreadSafe public class ConfigAgentLoader extends Object implements AgentLoader
Configuration-based AgentLoader that loads agents from YAML configuration files.

This loader monitors a configured source directory for folders containing `root_agent.yaml` files and automatically reloads agents when the files change (if hot-reloading is enabled).

The loader treats each subdirectory with a `root_agent.yaml` file as an agent, using the folder name as the agent identifier. Agents are loaded lazily when first requested.

Directory structure expected:

source-dir/
  ├── agent1/
  │   └── root_agent.yaml
  ├── agent2/
  │   └── root_agent.yaml
  └── ...

Hot-reloading can be disabled by setting hotReloadingEnabled to false.

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

  • Constructor Details

    • ConfigAgentLoader

      public ConfigAgentLoader(String sourceDir, boolean hotReloadingEnabled)
      Creates a new ConfigAgentLoader.
      Parameters:
      sourceDir - The directory to scan for agent configuration files
      hotReloadingEnabled - Controls whether hot-reloading is enabled
    • ConfigAgentLoader

      public ConfigAgentLoader(String sourceDir)
      Creates a new ConfigAgentLoader with hot-reloading enabled.
      Parameters:
      sourceDir - The directory to scan for agent configuration files
  • Method Details

    • listAgents

      @Nonnull public com.google.common.collect.ImmutableList<String> listAgents()
      Description copied from interface: AgentLoader
      Returns a list of available agent names.
      Specified by:
      listAgents in interface AgentLoader
      Returns:
      ImmutableList of agent names. Must not return null - return an empty list if no agents are available.
    • loadAgent

      public BaseAgent loadAgent(String name)
      Description copied from interface: AgentLoader
      Loads the BaseAgent instance for the specified agent name.
      Specified by:
      loadAgent in interface AgentLoader
      Parameters:
      name - the name of the agent to load
      Returns:
      BaseAgent instance for the given name
    • stop

      public void stop()
      Stops the hot-loading service.