### Build and Run ADK Agent with Maven Source: https://github.com/google/adk-java/blob/main/maven_plugin/examples/simple-agent/README.md Command to compile, build, and start the ADK web server with custom agents. It requires navigating to the example directory and using `mvn` with specific goals and parameters. ```bash # Navigate to the example directory cd maven_plugin/examples/simple-agent # Clean, compile, and start the server mvn clean compile google-adk:web \ -Dagents=com.example.SimpleAgentLoader ``` -------------------------------- ### Navigate to Example Directory Source: https://github.com/google/adk-java/blob/main/tutorials/city-time-weather/README.md Changes the current directory to the location of the city-time-weather example within the Google ADK tutorials. This is a prerequisite step before running the agent. ```shell cd /google_adk/tutorials/city-time-weather ``` -------------------------------- ### Bash: Build and run ADK with a custom registry Source: https://github.com/google/adk-java/blob/main/maven_plugin/examples/custom_tools/README.md This bash command compiles and starts the ADK web server using Maven. It includes the '-Dregistry' flag to specify a custom registry ('com.example.CustomDieRegistry'), enabling registry-based tool discovery for agents. This is necessary when using custom registries to alias tools. ```bash # Navigate to the example directory cd maven_plugin/examples/custom_tools # Clean, compile, and start the server mvn clean compile google-adk:web \ -Dagents=config_agents \ -Dregistry=com.example.CustomDieRegistry ``` -------------------------------- ### Setup and Run Sub-Agent Resolution Demo Source: https://github.com/google/adk-java/blob/main/contrib/samples/configagent/README.md Provides the necessary Maven command to compile and run the web agent for the sub-agent configuration demo. It specifies the agent to use (`sub_agents_config`) and the custom registry (`com.example.CustomDemoRegistry`). ```bash mvn clean compile google-adk:web \ -Dagents=sub_agents_config \ -Dregistry=com.example.CustomDemoRegistry ``` -------------------------------- ### Implement AgentLoader for ADK Source: https://github.com/google/adk-java/blob/main/maven_plugin/README.md Java code example demonstrating how to implement the AgentLoader interface for the ADK Maven Plugin. This includes listing available agents and loading them based on name. ```java package com.example; import com.google.adk.agents.BaseAgent; import com.google.adk.agents.LlmAgent; import com.google.adk.web.AgentLoader; import com.google.common.collect.ImmutableList; import java.util.NoSuchElementException; public class MyAgentLoader implements AgentLoader { public static final MyAgentLoader INSTANCE = new MyAgentLoader(); @Override public ImmutableList listAgents() { return ImmutableList.of("chat_bot", "code_assistant"); } @Override public BaseAgent loadAgent(String name) { switch (name) { case "chat_bot": return createChatBot(); case "code_assistant": return createCodeAssistant(); default: throw new NoSuchElementException("Agent not found: " + name); } } private BaseAgent createChatBot() { return LlmAgent.builder() .name("chat_bot") .description("A helpful chat bot") .model("gemini-2.0-flash") .instruction("You are a helpful assistant.") .build(); } private BaseAgent createCodeAssistant() { return LlmAgent.builder() .name("code_assistant") .description("A code assistance agent") .model("gemini-2.0-flash") .instruction("You are a coding assistant. Help users with programming questions.") .build(); } } ``` ```java public class SimpleAgentLoader implements AgentLoader { // No static field needed, uses default constructor @Override public ImmutableList listAgents() { return ImmutableList.of("simple_agent"); } @Override public BaseAgent loadAgent(String name) { if ("simple_agent".equals(name)) { return createSimpleAgent(); } throw new NoSuchElementException("Agent not found: " + name); } private BaseAgent createSimpleAgent() { return LlmAgent.builder() .name("simple_agent") .description("A simple agent") .model("gemini-2.0-flash") .instruction("You are a helpful assistant.") .build(); } } ``` -------------------------------- ### Setup Gemini API Key Source: https://github.com/google/adk-java/blob/main/tutorials/city-time-weather/README.md Sets the Gemini API key as an environment variable. This key is essential for the AI agent to access external services for weather and time information. Ensure you replace `{YOUR-KEY}` with your actual API key. ```shell GEMINI_API_KEY={YOUR-KEY} ``` -------------------------------- ### Format Code with google-java-format (Maven) Source: https://github.com/google/adk-java/blob/main/CONTRIBUTING.md The Maven build automatically runs google-java-format to ensure code adheres to the Google Java Style Guide. Pull requests will fail if code is not reformatted. ```bash mvn compile ``` -------------------------------- ### Implement Agent Loading Logic in Java Source: https://github.com/google/adk-java/blob/main/maven_plugin/examples/simple-agent/README.md Java code demonstrating the `AgentLoader` interface implementation. It lists available agents and provides logic to load a specific agent based on its name. Dependencies include Guava's `ImmutableList` and standard Java exception handling. ```java @Override @Nonnull public ImmutableList listAgents() { return ImmutableList.of("chat_assistant", "search_agent", "code_helper"); } @Override public BaseAgent loadAgent(String name) { switch (name) { case "chat_assistant": return createChatAssistant(); case "search_agent": return createSearchAgent(); case "code_helper": return createCodeHelper(); default: throw new NoSuchElementException("Agent not found: " + name); } } ``` -------------------------------- ### Manage Filesystem with MCP stdio using Node.js Source: https://github.com/google/adk-java/blob/main/contrib/samples/configagent/README.md An assistant agent for file system management using Model Context Protocol (MCP) stdio transport. It leverages the `@modelcontextprotocol/server-filesystem` npm package for operations like reading, writing, and searching files. Requires Node.js and setup of a demo directory. ```bash mkdir -p /tmp/mcp-demo ``` ```bash mvn google-adk:web -Dagents=tool_mcp_stdio_file_system_config -Dport=8001 ``` -------------------------------- ### YAML: Configure function-based tools for an agent Source: https://github.com/google/adk-java/blob/main/maven_plugin/examples/custom_tools/README.md This YAML configuration file sets up a function-based agent. It explicitly lists the FunctionTool instances (e.g., 'com.example.CustomDieTool.ROLL_DIE_INSTANCE') that should be made available as tools. This approach provides finer control, allowing only specific methods from a tool class to be exposed. ```yaml tools: - name: com.example.CustomDieTool.ROLL_DIE_INSTANCE - name: com.example.CustomDieTool.CHECK_PRIME_INSTANCE ``` -------------------------------- ### Configure Registry Die Agent in YAML Source: https://github.com/google/adk-java/blob/main/maven_plugin/examples/custom_tools/README.md This YAML configuration file defines the tools available to the `registry_die_agent`. It specifies the names of the tools, enabling the agent to access and utilize registered functionalities like rolling a die and checking for prime numbers. ```yaml tools: - name: tools.roll_die - name: tools.check_prime ``` -------------------------------- ### YAML: Configure class-based tool discovery for an agent Source: https://github.com/google/adk-java/blob/main/maven_plugin/examples/custom_tools/README.md This YAML configuration file sets up a class-based agent. By specifying the fully qualified class name of the tool class ('com.example.GetWeatherTool') in the 'tools' section, the ADK automatically discovers and makes all public, static, @Schema-annotated methods within that class available as tools for the agent. ```yaml name: "class_weather_agent" instruction: "You are a helpful weather assistant." tools: - name: "com.example.GetWeatherTool" ``` -------------------------------- ### Java: Define a simple custom tool with @Schema Source: https://github.com/google/adk-java/blob/main/maven_plugin/examples/custom_tools/README.md This Java code defines a simple tool class with a single static method annotated with @Schema. This allows the ADK to discover and use the method as a tool, describing its function to the LLM. It takes a city name as input and returns weather information. ```java public class GetWeatherTool { @Schema(name = "get_weather", description = "Get current weather information for a city") public static Map getWeather( @Schema(name = "city", description = "The city to fetch weather for.") String city) { ... } } ``` -------------------------------- ### Java: Define a multi-method custom tool with FunctionTool instances Source: https://github.com/google/adk-java/blob/main/maven_plugin/examples/custom_tools/README.md This Java code defines a custom tool class with multiple static methods, 'rollDie' and 'checkPrime'. Each method is annotated with @Schema and explicitly creates FunctionTool instances. These instances are used to provide more granular control over which methods are exposed as tools. ```java public class CustomDieTool { public static final FunctionTool ROLL_DIE_INSTANCE = FunctionTool.create(CustomDieTool.class, "rollDie"); public static final FunctionTool CHECK_PRIME_INSTANCE = FunctionTool.create(CustomDieTool.class, "checkPrime"); @Schema(name = "roll_die", description = "Roll a die with specified number of sides") public static Single> rollDie(...) { ... } @Schema(name = "check_prime", description = "Check if numbers are prime") public static Single> checkPrime(...) { ... } } ``` -------------------------------- ### Sub Agents Config - LifeAgent (Java) Source: https://github.com/google/adk-java/blob/main/contrib/samples/configagent/README.md Example of a Java class representing a sub-agent ('LifeAgent') that can be programmatically resolved and used within a multi-agent system. It's registered via the 'code' field in the agent's YAML configuration. ```java package com.example; import dev.langchain4j.agent.tool.Tool; import dev.langchain4j.core.agent.Agent; import dev.langchain4j.core.agent.DefaultAgent; import dev.langchain4j.core.agent.When; import dev.langchain4j.core.agent.tool.ToolExecutionRequest; import dev.langchain4j.core.context.prompt.PromptTemplate; import dev.langchain4j.model.chat.ChatLanguageModel; import dev.langchain4j.model.input.Prompt; @Agent public interface LifeAgent { @When("I need to live my life") String liveLife(); static LifeAgent builder(ChatLanguageModel model) { return DefaultAgent.builder(LifeAgent.class) .model(model) .promptTemplate(PromptTemplate.builder() .instruction("You are a life coach. Respond to the user's request to live life.") .build()) .build(); } } ``` -------------------------------- ### Register Custom Die Tools in Java Source: https://github.com/google/adk-java/blob/main/maven_plugin/examples/custom_tools/README.md This Java code defines a custom component registry that registers instances of `CustomDieTool` for rolling dice and checking prime numbers. It extends `ComponentRegistry` and overrides the constructor to define tool aliases. ```java public class CustomDieRegistry extends ComponentRegistry { public CustomDieRegistry() { super(); register("tools.roll_die", CustomDieTool.ROLL_DIE_INSTANCE); register("tools.check_prime", CustomDieTool.CHECK_PRIME_INSTANCE); } } ``` -------------------------------- ### Maven Build and Run for Hello World Agent Source: https://github.com/google/adk-java/blob/main/contrib/samples/helloworld/README.md Compiles and runs the Hello World Agent sample using Maven. The default execution runs a starter prompt, while an extended argument allows for additional prompts. ```bash mvn clean compile exec:java ``` ```bash mvn exec:java -Dexec.args="--run-extended" ``` -------------------------------- ### Building an LLM Agent with GoogleSearchTool in Java Source: https://github.com/google/adk-java/blob/main/README.md This Java code demonstrates how to initialize an LlmAgent using the ADK. It configures the agent's name, description, model, instructions, and integrates the GoogleSearchTool for web searching capabilities. ```java import com.google.adk.agents.LlmAgent; import com.google.adk.tools.GoogleSearchTool; LlmAgent rootAgent = LlmAgent.builder() .name("search_assistant") .description("An assistant that can search the web.") .model("gemini-2.0-flash") // Or your preferred models .instruction("You are a helpful assistant. Answer user questions using Google Search when needed.") .tools(new GoogleSearchTool()) .build(); ``` -------------------------------- ### Run ADK Web Server with Maven Source: https://github.com/google/adk-java/blob/main/contrib/samples/configagent/README.md Demonstrates how to compile and run the ADK web server using Maven. It allows running all agents simultaneously or specific agents by providing agent names and a custom registry if needed. ```bash mvn clean compile google-adk:web -Dagents=. \ -Dregistry=com.example.CustomDemoRegistry ``` ```bash mvn google-adk:web -Dagents=core_basic_config ``` ```bash mvn clean compile google-adk:web \ -Dagents=tool_functions_config \ -Dregistry=com.example.CustomDemoRegistry ``` -------------------------------- ### Run Agent with AgentStaticLoader (Maven) Source: https://github.com/google/adk-java/blob/main/tutorials/city-time-weather/README.md Executes the agent using Maven by programmatically providing agent instances with AgentStaticLoader. This method allows for precise control and is often used in production environments. You can specify a custom server port. ```shell mvn exec:java -Dexec.mainClass="com.google.adk.tutorials.CityTimeWeather" -Dserver.port=8081 ``` -------------------------------- ### Core Basic Agent Configuration (YAML) Source: https://github.com/google/adk-java/blob/main/contrib/samples/configagent/README.md Defines a basic Q&A agent with essential fields: name, model, description, and instruction. This is the simplest agent configuration. ```yaml # Basic agent configuration name: BasicAgent model: "gemini-pro" description: "A simple Q&A agent." instruction: "You are a helpful assistant." ``` -------------------------------- ### YAML Configuration for a Chat Assistant Agent Source: https://github.com/google/adk-java/blob/main/maven_plugin/README.md This YAML file defines the configuration for a chat assistant agent, including its name, description, model, and a multi-line instruction prompt. This format is used with ConfigAgentLoader. ```yaml name: "chat_assistant" description: "A friendly chat assistant" model: "gemini-2.0-flash" instruction: | You are a helpful and friendly assistant. Answer questions clearly and concisely. Be encouraging and positive in your responses. ``` -------------------------------- ### Run ADK Web Server with Maven Source: https://github.com/google/adk-java/blob/main/maven_plugin/README.md Executes the ADK Web Server using the Maven plugin. Requires specifying the agent loader class or configuration directory. ```bash mvn google-adk:web -Dagents=com.example.MyAgentLoader.INSTANCE ``` ```bash mvn google-adk:web \ -Dagents=com.example.MyAgentLoader.INSTANCE \ -Dhost=0.0.0.0 \ -Dport=9090 \ -DhotReloading=false ``` ```bash mvn google-adk:web -Dagents=com.example.SimpleAgentLoader ``` -------------------------------- ### Maven Command with Absolute Path for Agents Source: https://github.com/google/adk-java/blob/main/maven_plugin/README.md This command demonstrates how to use the google-adk Maven plugin to load agents from an absolute directory path on the filesystem. ```bash mvn google-adk:web -Dagents=/home/user/my-agents ``` -------------------------------- ### Integrate Google Search Tool into Agent Source: https://github.com/google/adk-java/blob/main/contrib/samples/configagent/README.md Shows an agent configured with a built-in Google search tool. This enables the agent to perform web searches directly to answer queries related to current events or information retrieval. No external dependencies are explicitly mentioned for this basic integration. -------------------------------- ### Maven Command Using Plugin Declaration Source: https://github.com/google/adk-java/blob/main/maven_plugin/README.md This bash command executes the 'web' goal of the google-adk Maven plugin, assuming the plugin is declared in the pom.xml. It specifies the agents to be loaded using a class path reference. ```bash mvn google-adk:web -Dagents=com.example.MyAgentLoader.INSTANCE ``` -------------------------------- ### Run Agent with CompiledAgentLoader (Maven) Source: https://github.com/google/adk-java/blob/main/tutorials/city-time-weather/README.md Executes the agent using Maven with the CompiledAgentLoader. This approach automatically discovers agents by scanning compiled classes for ROOT_AGENT fields. It's suitable for development and when managing multiple agents. ```shell mvn exec:java -Dadk.agents.source-dir=$PWD ``` -------------------------------- ### Maven Command to Run Agents Source: https://github.com/google/adk-java/blob/main/maven_plugin/README.md This bash command utilizes the google-adk Maven plugin to run web services, specifying agents to load using a fully qualified class name with a static field. ```bash mvn google-adk:web -Dagents=com.example.MultipleLoaders.ADVANCED ``` -------------------------------- ### Core Callbacks Implementation (Java) Source: https://github.com/google/adk-java/blob/main/contrib/samples/configagent/README.md Java class containing implementations for various agent, model, and tool callback hooks. These methods are invoked at different stages of agent execution. ```java package com.example; import dev.langchain4j.agent.tool.ToolExecutionRequest; import dev.langchain4j.agent.tool.ToolExecutionResult; import dev.langchain4j.agent.tool.ToolSpecification; import dev.langchain4j.data.message.ChatMessage; import dev.langchain4j.model.chat.ChatCompletionRequest; import dev.langchain4j.model.chat.ChatCompletionResponse; import java.util.List; import java.util.function.BiConsumer; import java.util.function.Consumer; public class CoreCallbacks { // Agent Callbacks public void beforeAgent(List messages) { System.out.println("Before agent processing. Messages: " + messages.size()); } public void afterAgent(String response) { System.out.println("After agent processing. Response: " + response); } // Model Callbacks public void beforeModel(ChatCompletionRequest request) { System.out.println("Before model invocation."); } public void afterModel(ChatCompletionResponse response) { System.out.println("After model invocation."); } // Tool Callbacks public void beforeTool(ToolExecutionRequest request) { System.out.println("Before tool execution: " + request.toolName() + "(" + request.toolArguments() + ")"); } public void afterTool(ToolExecutionResult result) { System.out.println("After tool execution. Output: " + result.output()); } } ``` -------------------------------- ### Custom Demo Registry Implementation (Java) Source: https://github.com/google/adk-java/blob/main/contrib/samples/configagent/README.md A consolidated custom registry for ADK that registers custom tools and agents. This is used when running specific agents that rely on custom implementations. ```java package com.example; import dev.langchain4j.agent.tool.ToolExecutionHelper; import dev.langchain4j.core.agent.AgentCreationContext; import dev.langchain4j.core.agent.AgentRegistry; import dev.langchain4j.core.agent.DefaultAgentRegistry; import dev.langchain4j.core.agent.SimpleAgentConfigurator; import dev.langchain4j.core.agent.function.FunctionCallingMode; import dev.langchain4j.core.context.prompt.PromptTemplate; import dev.langchain4j.core.tool.ToolSpecification; import dev.langchain4j.model.chat.ChatLanguageModel; import dev.langchain4j.model.openai.OpenAiChatModel; import java.util.List; public class CustomDemoRegistry implements AgentRegistry { private final AgentRegistry delegate = new DefaultAgentRegistry(); public CustomDemoRegistry() { // Register custom tools delegate.registerTool(new CustomDieTool()); delegate.registerTool(new CustomPrimeCheckerTool()); // Assuming CustomPrimeCheckerTool exists // Register custom agents delegate.registerAgent( SimpleAgentConfigurator.builder() .name("CoreBasicAgent") .model(OpenAiChatModel.builder().apiKey(System.getenv("OPENAI_API_KEY")).build()) .promptTemplate(PromptTemplate.builder().build()) .instruction("You are a helpful assistant.") .build() ); delegate.registerAgent( SimpleAgentConfigurator.builder() .name("SearchAgent") .model(OpenAiChatModel.builder().apiKey(System.getenv("OPENAI_API_KEY")).build()) .instruction("Answer questions using the available search tool.") .tools(List.of("google-search")) .build() ); delegate.registerAgent( SimpleAgentConfigurator.builder() .name("FunctionToolAgent") .model(OpenAiChatModel.builder().apiKey(System.getenv("OPENAI_API_KEY")).build()) .instruction("Perform custom actions using the provided tools.") .tools(List.of(ToolExecutionHelper.from(new CustomDieTool()))) .build() ); delegate.registerAgent( SimpleAgentConfigurator.builder() .name("CallbackAgent") .model(OpenAiChatModel.builder().apiKey(System.getenv("OPENAI_API_KEY")).build()) .instruction("Respond to user queries and trigger callbacks.") .callbacks(new CoreCallbacks()) .build() ); } @Override public void registerAgent(Object agent) { delegate.registerAgent(agent); } @Override public void registerTool(Object tool) { delegate.registerTool(tool); } @Override public void registerTool(ToolSpecification toolSpecification) { delegate.registerTool(toolSpecification); } @Override public List agentNames() { return delegate.agentNames(); } @Override public Object getAgent(String name) { return delegate.getAgent(name); } @Override public List toolSpecifications() { return delegate.toolSpecifications(); } @Override public ToolSpecification getToolSpecification(String name) { return delegate.getToolSpecification(name); } @Override public void init(AgentCreationContext context) { delegate.init(context); } } ``` -------------------------------- ### Maven Command for Directory Path Agents Source: https://github.com/google/adk-java/blob/main/maven_plugin/README.md This bash command executes the google-adk Maven plugin, directing it to load agents from a specified directory path. The plugin will automatically discover agents using ConfigAgentLoader. ```bash mvn google-adk:web -Dagents=my-agents ``` -------------------------------- ### Configure LLM Generation Parameters with generate_content_config Source: https://github.com/google/adk-java/blob/main/contrib/samples/configagent/README.md Demonstrates how to control LLM generation parameters such as temperature and max output tokens using `generate_content_config`. This allows for fine-tuning creativity and response length. It is useful for scenarios requiring focused or constrained text generation. ```yaml generate_content_config: temperature: 0.1 # Lower temperature for more focused responses max_output_tokens: 2000 # Limit response length ``` -------------------------------- ### Tool Built-in Agent Configuration (YAML) Source: https://github.com/google/adk-java/blob/main/contrib/samples/configagent/README.md An agent configuration that includes built-in tools, such as the Google search tool, enabling the agent to perform external lookups. ```yaml # Agent with built-in search tool name: SearchAgent model: "gemini-pro" description: "Agent with built-in Google search tool." instruction: "Answer questions using the available search tool." tools: - "google-search" ``` -------------------------------- ### Core Callback Agent Configuration (YAML) Source: https://github.com/google/adk-java/blob/main/contrib/samples/configagent/README.md An agent configuration that utilizes comprehensive callback hooks for monitoring agent lifecycle events such as agent processing, model invocation, and tool usage. ```yaml # Agent with callback hooks name: CallbackAgent model: "gemini-pro" description: "Agent demonstrating callback hooks." instruction: "Respond to user queries and trigger callbacks." callbacks: agent: before: - "com.example.CoreCallbacks.beforeAgent" after: - "com.example.CoreCallbacks.afterAgent" model: before: - "com.example.CoreCallbacks.beforeModel" after: - "com.example.CoreCallbacks.afterModel" tool: before: - "com.example.CoreCallbacks.beforeTool" after: - "com.example.CoreCallbacks.afterTool" ``` -------------------------------- ### Tool Functions Agent Configuration (YAML) Source: https://github.com/google/adk-java/blob/main/contrib/samples/configagent/README.md An agent configuration that integrates custom Java-based function tools. This requires defining the tools in Java and referencing them in the YAML configuration. ```yaml # Agent with custom function tools name: FunctionToolAgent model: "gemini-pro" description: "Agent with custom Java function tools." instruction: "Perform custom actions using the provided tools." tools: - "CustomDieTool" ``` -------------------------------- ### Squash Git Commits with Interactive Rebase Source: https://github.com/google/adk-java/blob/main/CONTRIBUTING.md Use git rebase -i main to combine multiple existing commits into a single commit, often used to prepare a pull request with only one commit. ```bash git rebase -i main ``` -------------------------------- ### Configure Google ADK Maven Plugin in pom.xml Source: https://github.com/google/adk-java/blob/main/maven_plugin/README.md XML configuration snippet to add the Google ADK Maven Plugin to a Maven project's pom.xml file. This allows the project to utilize the plugin's functionalities. ```xml com.google.adk google-adk-maven-plugin 0.3.0 ``` -------------------------------- ### Maven Dependency for ADK Java Source: https://github.com/google/adk-java/blob/main/README.md This XML snippet shows how to add the Google ADK and its development UI dependencies to a Maven project. Ensure you use the correct version for your project. ```xml com.google.adk google-adk 0.3.0 com.google.adk google-adk-dev 0.3.0 ``` -------------------------------- ### Programmatically Resolve Sub-Agents using 'code' Field Source: https://github.com/google/adk-java/blob/main/contrib/samples/configagent/README.md Demonstrates programmatic sub-agent resolution using the `code` field for Python ADK compatibility, allowing agents to be referenced from the ComponentRegistry. It shows loading agents via YAML config and dynamically via the `code` field, utilizing a custom registry. ```yaml sub_agents: - config_path: ./work_agent.yaml # Traditional YAML file reference - code: sub_agents_config.life_agent.agent # Programmatic reference via registry ``` -------------------------------- ### Maven Dependency for Google ADK Core Source: https://github.com/google/adk-java/blob/main/maven_plugin/README.md This XML snippet shows how to include the core Google ADK library as a project dependency in a Maven pom.xml file. Ensure the version matches your project requirements. ```xml com.google.adk google-adk 0.3.0 com.google.adk google-adk-dev 0.3.0 compile ``` -------------------------------- ### Java Agent Loader with Static Fields Source: https://github.com/google/adk-java/blob/main/maven_plugin/README.md This Java code defines a custom agent loader using static fields for agent instances. It implements the AgentLoader interface to list and load agents. Dependencies include ImmutableList from Guava and LlmAgent from the ADK. ```java public class MultipleLoaders implements AgentLoader { public static final MultipleLoaders DEFAULT = new MultipleLoaders(); public static final MultipleLoaders ADVANCED = new MultipleLoaders(true); private final boolean advanced; public MultipleLoaders() { this(false); } public MultipleLoaders(boolean advanced) { this.advanced = advanced; } @Override public ImmutableList listAgents() { if (advanced) { return ImmutableList.of("advanced_agent"); } return ImmutableList.of("basic_agent"); } @Override public BaseAgent loadAgent(String name) { if (advanced && "advanced_agent".equals(name)) { return createAdvancedAgent(); } else if (!advanced && "basic_agent".equals(name)) { return createBasicAgent(); } throw new NoSuchElementException("Agent not found: " + name); } private BaseAgent createBasicAgent() { return LlmAgent.builder() .name("basic_agent") .description("A basic agent") .model("gemini-2.0-flash") .instruction("You are a basic helpful assistant.") .build(); } private BaseAgent createAdvancedAgent() { return LlmAgent.builder() .name("advanced_agent") .description("An advanced agent with more capabilities") .model("gemini-2.0-flash") .instruction("You are an advanced assistant with enhanced capabilities.") .build(); } } ``` -------------------------------- ### Amend and Force Push Git Commit Source: https://github.com/google/adk-java/blob/main/CONTRIBUTING.md Use git commit --amend to modify the last commit, typically for incorporating code review feedback. Then, use git push --force-with-lease to update the pull request branch. ```bash git commit --amend git push --force-with-lease ``` -------------------------------- ### Maven Command Without Plugin Declaration Source: https://github.com/google/adk-java/blob/main/maven_plugin/README.md This bash command directly invokes the google-adk Maven plugin's 'web' goal using its full coordinates. This method is used when the plugin is not declared in the pom.xml. ```bash mvn com.google.adk:google-adk-maven-plugin:web -Dagents=com.example.MyAgentLoader.INSTANCE ``` -------------------------------- ### Custom Die Tool Implementation (Java) Source: https://github.com/google/adk-java/blob/main/contrib/samples/configagent/README.md A Java class implementing a custom tool for rolling dice. This tool can be referenced in agent configurations to provide dice rolling capabilities. ```java package com.example; import dev.langchain4j.agent.tool.Tool; import java.util.Random; public class CustomDieTool { private static final Random random = new Random(); @Tool("Roll a D6 dice") public int rollD6() { return random.nextInt(6) + 1; } @Tool("Roll a D20 dice") public int rollD20() { return random.nextInt(20) + 1; } @Tool("Roll a dice with N sides") public int rollNDS(int n) { return random.nextInt(n) + 1; } } ``` -------------------------------- ### Disable Hot Reloading with Maven Source: https://github.com/google/adk-java/blob/main/maven_plugin/README.md This bash command invokes the google-adk Maven plugin while explicitly disabling hot reloading for configuration-based agents by setting the 'hotReloading' property to 'false'. ```bash mvn google-adk:web -Dagents=my-agents -DhotReloading=false ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.