Skip to content

Commit c898c20

Browse files
authored
Merge pull request #9 from ddobrin/main
Merge main into planner
2 parents c2ec25b + 897f9d9 commit c898c20

59 files changed

Lines changed: 4364 additions & 972 deletions

File tree

Some content is hidden

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

.github/workflows/validation.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@ jobs:
2323
uses: actions/checkout@v6
2424

2525
- name: Set up Java ${{ matrix.java-version }}
26-
uses: actions/setup-java@v4
26+
uses: actions/setup-java@v5
2727
with:
2828
distribution: temurin
2929
java-version: ${{ matrix.java-version }}
3030

3131
- name: Cache Maven packages
32-
uses: actions/cache@v3
32+
uses: actions/cache@v5
3333
with:
3434
path: ~/.m2/repository
3535
key: ${{ runner.os }}-maven-${{ matrix.java-version }}-${{ hashFiles('**/pom.xml') }}

.release-please-manifest.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
{
22
".": "0.9.0"
33
}
4-

AGENTS.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# AGENTS.md
2+
3+
Validate changes by running `./mvnw test`.

a2a/src/main/java/com/google/adk/a2a/agent/RemoteA2AAgent.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ private RemoteA2AAgent(Builder builder) {
117117
if (this.description.isEmpty() && this.agentCard.description() != null) {
118118
this.description = this.agentCard.description();
119119
}
120-
this.streaming = this.agentCard.capabilities().streaming();
120+
this.streaming = builder.streaming && this.agentCard.capabilities().streaming();
121121
}
122122

123123
public static Builder builder() {
@@ -133,6 +133,13 @@ public static class Builder {
133133
private List<? extends BaseAgent> subAgents;
134134
private List<Callbacks.BeforeAgentCallback> beforeAgentCallback;
135135
private List<Callbacks.AfterAgentCallback> afterAgentCallback;
136+
private boolean streaming;
137+
138+
@CanIgnoreReturnValue
139+
public Builder streaming(boolean streaming) {
140+
this.streaming = streaming;
141+
return this;
142+
}
136143

137144
@CanIgnoreReturnValue
138145
public Builder name(String name) {
@@ -181,6 +188,10 @@ public RemoteA2AAgent build() {
181188
}
182189
}
183190

191+
public boolean isStreaming() {
192+
return streaming;
193+
}
194+
184195
private Message.Builder newA2AMessage(Message.Role role, List<io.a2a.spec.Part<?>> parts) {
185196
return new Message.Builder().messageId(UUID.randomUUID().toString()).role(role).parts(parts);
186197
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright 2026 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.google.adk.a2a.converters;
17+
18+
/**
19+
* Enum for the type of A2A metadata. Adds a prefix used to differentiage ADK-related values stored
20+
* in Metadata an A2A event.
21+
*/
22+
public enum A2AMetadataKey {
23+
TYPE("type"),
24+
IS_LONG_RUNNING("is_long_running"),
25+
PARTIAL("partial"),
26+
GROUNDING_METADATA("grounding_metadata"),
27+
USAGE_METADATA("usage_metadata"),
28+
CUSTOM_METADATA("custom_metadata"),
29+
ERROR_CODE("error_code");
30+
31+
private final String type;
32+
33+
private A2AMetadataKey(String type) {
34+
this.type = "adk_" + type;
35+
}
36+
37+
public String getType() {
38+
return type;
39+
}
40+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright 2026 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.google.adk.a2a.converters;
17+
18+
/**
19+
* Enum for the type of ADK metadata. Adds a prefix used to differentiate A2A-related values stored
20+
* in custom metadata of an ADK session event.
21+
*/
22+
public enum AdkMetadataKey {
23+
TASK_ID("task_id"),
24+
CONTEXT_ID("context_id");
25+
26+
private final String type;
27+
28+
private AdkMetadataKey(String type) {
29+
this.type = "a2a:" + type;
30+
}
31+
32+
public String getType() {
33+
return type;
34+
}
35+
}

a2a/src/main/java/com/google/adk/a2a/converters/PartConverter.java

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,7 @@ public final class PartConverter {
5252

5353
private static final Logger logger = LoggerFactory.getLogger(PartConverter.class);
5454
private static final ObjectMapper objectMapper = new ObjectMapper();
55-
// Constants for metadata types. By convention metadata keys are prefixed with "adk_" to align
56-
// with the Python and Golang libraries.
57-
public static final String A2A_DATA_PART_METADATA_TYPE_KEY = "adk_type";
58-
public static final String A2A_DATA_PART_METADATA_IS_LONG_RUNNING_KEY = "adk_is_long_running";
59-
public static final String A2A_DATA_PART_METADATA_IS_PARTIAL_KEY = "adk_partial";
55+
// Constants for metadata types.
6056
public static final String LANGUAGE_KEY = "language";
6157
public static final String OUTCOME_KEY = "outcome";
6258
public static final String CODE_KEY = "code";
@@ -135,7 +131,7 @@ private static com.google.genai.types.Part convertDataPartToGenAiPart(DataPart d
135131
Map<String, Object> metadata =
136132
Optional.ofNullable(dataPart.getMetadata()).map(HashMap::new).orElseGet(HashMap::new);
137133

138-
String metadataType = metadata.getOrDefault(A2A_DATA_PART_METADATA_TYPE_KEY, "").toString();
134+
String metadataType = metadata.getOrDefault(A2AMetadataKey.TYPE.getType(), "").toString();
139135

140136
if ((data.containsKey(NAME_KEY) && data.containsKey(ARGS_KEY))
141137
|| metadataType.equals(A2ADataPartMetadataType.FUNCTION_CALL.getType())) {
@@ -218,7 +214,7 @@ private static DataPart createDataPartFromFunctionCall(
218214
addValueIfPresent(data, WILL_CONTINUE_KEY, functionCall.willContinue());
219215
addValueIfPresent(data, PARTIAL_ARGS_KEY, functionCall.partialArgs());
220216

221-
metadata.put(A2A_DATA_PART_METADATA_TYPE_KEY, A2ADataPartMetadataType.FUNCTION_CALL.getType());
217+
metadata.put(A2AMetadataKey.TYPE.getType(), A2ADataPartMetadataType.FUNCTION_CALL.getType());
222218

223219
return new DataPart(data.buildOrThrow(), metadata.buildOrThrow());
224220
}
@@ -245,7 +241,7 @@ private static DataPart createDataPartFromFunctionResponse(
245241
addValueIfPresent(data, PARTS_KEY, functionResponse.parts());
246242

247243
metadata.put(
248-
A2A_DATA_PART_METADATA_TYPE_KEY, A2ADataPartMetadataType.FUNCTION_RESPONSE.getType());
244+
A2AMetadataKey.TYPE.getType(), A2ADataPartMetadataType.FUNCTION_RESPONSE.getType());
249245

250246
return new DataPart(data.buildOrThrow(), metadata.buildOrThrow());
251247
}
@@ -268,7 +264,7 @@ private static DataPart createDataPartFromCodeExecutionResult(
268264
addValueIfPresent(data, OUTPUT_KEY, codeExecutionResult.output());
269265

270266
metadata.put(
271-
A2A_DATA_PART_METADATA_TYPE_KEY, A2ADataPartMetadataType.CODE_EXECUTION_RESULT.getType());
267+
A2AMetadataKey.TYPE.getType(), A2ADataPartMetadataType.CODE_EXECUTION_RESULT.getType());
272268

273269
return new DataPart(data.buildOrThrow(), metadata.buildOrThrow());
274270
}
@@ -290,8 +286,7 @@ private static DataPart createDataPartFromExecutableCode(
290286
.orElse(Language.Known.LANGUAGE_UNSPECIFIED.toString()));
291287
addValueIfPresent(data, CODE_KEY, executableCode.code());
292288

293-
metadata.put(
294-
A2A_DATA_PART_METADATA_TYPE_KEY, A2ADataPartMetadataType.EXECUTABLE_CODE.getType());
289+
metadata.put(A2AMetadataKey.TYPE.getType(), A2ADataPartMetadataType.EXECUTABLE_CODE.getType());
295290

296291
return new DataPart(data.buildOrThrow(), metadata.buildOrThrow());
297292
}
@@ -305,7 +300,7 @@ public static io.a2a.spec.Part<?> fromGenaiPart(Part part, boolean isPartial) {
305300
}
306301
ImmutableMap.Builder<String, Object> metadata = ImmutableMap.builder();
307302
if (isPartial) {
308-
metadata.put(A2A_DATA_PART_METADATA_IS_PARTIAL_KEY, true);
303+
metadata.put(A2AMetadataKey.PARTIAL.getType(), true);
309304
}
310305

311306
if (part.text().isPresent()) {

0 commit comments

Comments
 (0)