Skip to content

Commit 723ed18

Browse files
authored
Merge branch 'main' into feature/inputAudioTranscription
2 parents 1e030a0 + cfdb958 commit 723ed18

File tree

68 files changed

+3982
-692
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

68 files changed

+3982
-692
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
# Maven target directory
1717
target/
18-
.mvn/
1918

2019
# IntelliJ IDEA files
2120
.idea/

GEMINI.md

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
# Gemini Code Assistant Context
2+
3+
This document provides context for the Gemini Code Assistant to understand the "Agent Development Kit (ADK) for Java" project.
4+
5+
## Project Overview
6+
7+
The "Agent Development Kit (ADK) for Java" is an open-source, code-first toolkit for building, evaluating, and deploying sophisticated AI agents with flexibility and control. It allows developers to define agent behavior, orchestration, and tool use directly in Java code, enabling robust debugging, versioning, and deployment.
8+
9+
The project is a multi-module Maven project with the following key modules:
10+
11+
* **core**: The core module contains the main logic of the ADK. It includes the following key components:
12+
* **`BaseAgent`**: The abstract base class for all agents. It defines the basic properties of an agent, such as its name, description, and sub-agents. It also defines the `runAsync()` and `runLive()` methods, which are the entry points for running an agent.
13+
* **`LlmAgent`**: The primary implementation of a `BaseAgent`. It can be configured with a model, instructions, tools, and sub-agents.
14+
* **`BaseSessionService`**: An interface for managing sessions. It provides methods for creating, retrieving, listing, and deleting sessions, as well as listing and appending events to a session.
15+
* **`Runner`**: The main class for running agents. It takes a `BaseAgent`, a `BaseArtifactService`, a `BaseSessionService`, and a `BaseMemoryService` as input. It provides `runAsync()` and `runLive()` methods for running the agent.
16+
* **Core Runtime**: The core runtime of the ADK is responsible for orchestrating the execution of agents. It uses the `Runner` to run the agent and the `BaseSessionService` to manage the session.
17+
* **dev**: This module contains the development UI for testing, evaluating, and debugging agents. It includes a Spring Boot-based web server that can be used to debug agents developed using ADK.
18+
19+
**Agent Loading:**
20+
21+
The `dev` module provides a flexible mechanism for loading agents into the ADK Web Server through the `AgentLoader` interface. This interface has two implementations:
22+
23+
* **`AgentStaticLoader`**: This loader takes a static list of pre-created agent instances. It's ideal for production environments or when you have a fixed set of agents.
24+
* **`CompiledAgentLoader`**: This loader scans a directory for pre-compiled agent classes. It identifies agents by looking for a `public static` field named `ROOT_AGENT` of type `BaseAgent`. This is useful for development environments where you want to automatically discover and load agents.
25+
* **maven_plugin**: This module provides a Maven plugin for the ADK. The plugin provides the `google-adk:web` goal, which starts the ADK Web Server with user-provided agents. The plugin can be configured with the following parameters:
26+
27+
* `agents`: The fully qualified class name of an `AgentLoader` implementation or a path to a directory containing agent configurations.
28+
* `port`: The port number for the web server.
29+
* `host`: The host address to bind the web server to.
30+
* `hotReloading`: Whether to enable hot reloading of agent configurations.
31+
* `registry`: The fully qualified class name of a custom `ComponentRegistry` subclass.
32+
33+
The `maven_plugin` module also includes the `ConfigAgentLoader` class, which is an implementation of the `AgentLoader` interface that loads agents from YAML configuration files. It scans a source directory for subdirectories containing a `root_agent.yaml` file. Each subdirectory is treated as an agent, and the folder name is used as the agent identifier. The `ConfigAgentLoader` also supports hot-reloading.
34+
35+
36+
## Building and Running
37+
38+
The project is built using Maven. Use the `./mvnw` wrapper script for all commands.
39+
40+
### Maven Commands
41+
42+
* **Build the entire project**:
43+
44+
```shell
45+
./mvnw clean install
46+
```
47+
48+
* **Run tests**:
49+
50+
```shell
51+
./mvnw test
52+
```
53+
54+
* **Format code**:
55+
56+
```shell
57+
./mvnw fmt:format
58+
```
59+
60+
* **Skip tests during build**:
61+
62+
```shell
63+
./mvnw clean install -DskipTests
64+
```
65+
66+
## Development Workflow
67+
68+
### Running the Development UI
69+
70+
The development UI provides an interactive chat interface for testing and debugging agents. It can be started using the Maven plugin:
71+
72+
* **Using an `AgentLoader` class**:
73+
74+
```shell
75+
mvn google-adk:web -Dagents=com.example.MyAgentLoader.INSTANCE -Dport=8000
76+
```
77+
78+
* **Using a config directory (YAML-based agents)**:
79+
80+
```shell
81+
mvn google-adk:web -Dagents=path/to/config/dir
82+
```
83+
84+
* **With hot reloading disabled**:
85+
86+
```shell
87+
mvn google-adk:web -Dagents=... -DhotReloading=false
88+
```
89+
90+
Once started, the dev UI is available at `http://localhost:8000` (or the specified port).
91+
92+
## Development Conventions
93+
94+
* **Coding Style**: The project follows the Google Java Style Guide. The `fmt-maven-plugin` is used to format the code automatically.
95+
* **Import Style**: Always use import statements instead of fully qualified class names in code. Prefer `import com.google.adk.agents.InvocationContext;` over using `com.google.adk.agents.InvocationContext` directly in the code.
96+
* **Testing**: The project uses JUnit 5 for testing. Tests are located in the `src/test/java` directory of each module.
97+
* **Contributing**: Contributions are welcome. Please see the `CONTRIBUTING.md` file for more information.

README.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,6 @@ Coming soon...
104104

105105
For remote agent-to-agent communication, ADK integrates with the
106106
[A2A protocol](https://github.com/google/A2A/).
107-
To build the full runtime, Spring transport, and samples, activate the
108-
`a2a` Maven profile:
109-
110-
```bash
111-
./mvnw -Pa2a clean package
112-
```
113-
114107
See `a2a/README.md` for end-to-end setup instructions and sample commands.
115108

116109
## 🤝 Contributing

a2a/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ transport-agnostic `a2a/src/...` tree described above.
111111

112112
### Quick Start
113113

114-
All commands below assume you are in `/google_adk`.
114+
All commands below assume you are in `google_adk`.
115115

116116
1. **Start the Spring webservice sample** (run in its own terminal)
117117
```bash
@@ -158,7 +158,7 @@ To build the runtime, Spring webservice, and both samples together, activate the
158158
opt-in Maven profile:
159159

160160
```bash
161-
./mvnw -Pa2a clean package
161+
./mvnw -pl a2a -am clean package
162162
```
163163

164164
#### Manual Smoke Test

a2a/pom.xml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
<?xml version="1.0" encoding="UTF-8"?>
2-
<project xmlns="http://maven.apache.org/POM/4.0.0"
3-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
1+
<?xml version='1.0' encoding='utf-8'?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
53
<modelVersion>4.0.0</modelVersion>
64

75
<parent>
86
<groupId>com.google.adk</groupId>
97
<artifactId>google-adk-parent</artifactId>
10-
<version>0.3.1-SNAPSHOT</version>
8+
<version>0.3.1-SNAPSHOT</version><!-- {x-version-update:google-adk:current} -->
119
</parent>
1210

1311
<artifactId>google-adk-a2a</artifactId>
@@ -18,7 +16,7 @@
1816
<properties>
1917
<java.version>17</java.version>
2018
<maven.compiler.release>${java.version}</maven.compiler.release>
21-
<a2a.sdk.version>0.3.0.Beta2-SNAPSHOT</a2a.sdk.version>
19+
<a2a.sdk.version>0.3.0.Beta1</a2a.sdk.version>
2220
<google.adk.version>${project.version}</google.adk.version>
2321
<guava.version>33.0.0-jre</guava.version>
2422
<jackson.version>2.19.0</jackson.version>
@@ -104,7 +102,6 @@
104102
<scope>test</scope>
105103
</dependency>
106104
</dependencies>
107-
108105
<build>
109106
<plugins>
110107
<plugin>

a2a/webservice/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>com.google.adk</groupId>
99
<artifactId>google-adk-parent</artifactId>
10-
<version>0.3.1-SNAPSHOT</version>
10+
<version>0.3.1-SNAPSHOT</version><!-- {x-version-update:google-adk:current} -->
1111
</parent>
1212

1313
<artifactId>google-adk-a2a-webservice</artifactId>

contrib/samples/a2a_basic/pom.xml

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,14 @@
44
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
55
<modelVersion>4.0.0</modelVersion>
66

7-
<groupId>com.google.adk</groupId>
7+
<parent>
8+
<groupId>com.google.adk</groupId>
9+
<artifactId>google-adk-samples</artifactId>
10+
<version>0.3.1-SNAPSHOT</version><!-- {x-version-update:google-adk:current} -->
11+
<relativePath>..</relativePath>
12+
</parent>
13+
814
<artifactId>google-adk-sample-a2a-basic</artifactId>
9-
<version>0.3.1-SNAPSHOT</version>
1015
<packaging>jar</packaging>
1116

1217
<name>Google ADK - Sample - A2A Basic Client</name>
@@ -15,8 +20,8 @@
1520
<properties>
1621
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1722
<java.version>17</java.version>
18-
<google-adk.version>0.3.1-SNAPSHOT</google-adk.version>
19-
<google-adk-a2a.version>0.3.1-SNAPSHOT</google-adk-a2a.version>
23+
<google-adk.version>${project.version}</google-adk.version>
24+
<google-adk-a2a.version>${project.version}</google-adk-a2a.version>
2025
<slf4j.version>2.0.16</slf4j.version>
2126
</properties>
2227

@@ -69,6 +74,16 @@
6974
</execution>
7075
</executions>
7176
</plugin>
77+
<plugin>
78+
<groupId>org.apache.maven.plugins</groupId>
79+
<artifactId>maven-source-plugin</artifactId>
80+
<configuration>
81+
<excludes>
82+
<exclude>**/*.jar</exclude>
83+
<exclude>target/**</exclude>
84+
</excludes>
85+
</configuration>
86+
</plugin>
7287
<plugin>
7388
<groupId>org.codehaus.mojo</groupId>
7489
<artifactId>exec-maven-plugin</artifactId>

contrib/samples/a2a_remote/pom.xml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<parent>
88
<groupId>com.google.adk</groupId>
99
<artifactId>google-adk-parent</artifactId>
10-
<version>0.3.1-SNAPSHOT</version>
10+
<version>0.3.1-SNAPSHOT</version><!-- {x-version-update:google-adk:current} -->
1111
</parent>
1212

1313
<artifactId>google-adk-sample-a2a-remote</artifactId>
@@ -114,6 +114,16 @@
114114
</execution>
115115
</executions>
116116
</plugin>
117+
<plugin>
118+
<groupId>org.apache.maven.plugins</groupId>
119+
<artifactId>maven-source-plugin</artifactId>
120+
<configuration>
121+
<excludes>
122+
<exclude>**/*.jar</exclude>
123+
<exclude>target/**</exclude>
124+
</excludes>
125+
</configuration>
126+
</plugin>
117127
<plugin>
118128
<groupId>org.codehaus.mojo</groupId>
119129
<artifactId>exec-maven-plugin</artifactId>

contrib/samples/configagent/pom.xml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,22 @@
22
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
33
<modelVersion>4.0.0</modelVersion>
44

5+
<parent>
6+
<groupId>com.google.adk</groupId>
7+
<artifactId>google-adk-samples</artifactId>
8+
<version>0.3.1-SNAPSHOT</version><!-- {x-version-update:google-adk:current} -->
9+
<relativePath>..</relativePath>
10+
</parent>
11+
512
<groupId>com.google.adk.samples</groupId>
613
<artifactId>configagent-samples</artifactId>
7-
<version>0.3.1-SNAPSHOT</version>
814
<packaging>jar</packaging>
915

1016
<properties>
1117
<maven.compiler.source>11</maven.compiler.source>
1218
<maven.compiler.target>11</maven.compiler.target>
1319
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
14-
<google-adk.version>0.3.0</google-adk.version>
20+
<google-adk.version>${project.version}</google-adk.version>
1521
</properties>
1622

1723
<dependencies>

contrib/samples/helloworld/pom.xml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,15 @@
1717
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
1818
<modelVersion>4.0.0</modelVersion>
1919

20+
<parent>
21+
<groupId>com.google.adk</groupId>
22+
<artifactId>google-adk-samples</artifactId>
23+
<version>0.3.1-SNAPSHOT</version><!-- {x-version-update:google-adk:current} -->
24+
<relativePath>..</relativePath>
25+
</parent>
26+
2027
<groupId>com.google.adk.samples</groupId>
2128
<artifactId>google-adk-sample-helloworld</artifactId>
22-
<version>0.3.1-SNAPSHOT</version>
2329
<name>Google ADK - Sample - Hello World</name>
2430
<description>
2531
A sample "Hello World" application demonstrating basic agent and tool usage with the Google ADK,
@@ -33,7 +39,7 @@
3339
<auto-value.version>1.11.0</auto-value.version>
3440
<!-- Main class for exec-maven-plugin -->
3541
<exec.mainClass>com.example.helloworld.HelloWorldRun</exec.mainClass>
36-
<google-adk.version>0.3.0</google-adk.version>
42+
<google-adk.version>${project.version}</google-adk.version>
3743
</properties>
3844

3945
<dependencies>
@@ -80,6 +86,16 @@
8086
</execution>
8187
</executions>
8288
</plugin>
89+
<plugin>
90+
<groupId>org.apache.maven.plugins</groupId>
91+
<artifactId>maven-source-plugin</artifactId>
92+
<configuration>
93+
<excludes>
94+
<exclude>**/*.jar</exclude>
95+
<exclude>target/**</exclude>
96+
</excludes>
97+
</configuration>
98+
</plugin>
8399
<plugin>
84100
<groupId>org.codehaus.mojo</groupId>
85101
<artifactId>exec-maven-plugin</artifactId>

0 commit comments

Comments
 (0)