Skip to content

Commit 5b77c0a

Browse files
authored
Merge pull request #15 from ddobrin/main
Merge main into planner
2 parents ec776c5 + 88eb0f5 commit 5b77c0a

22 files changed

Lines changed: 3446 additions & 377 deletions

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@
2828
import com.google.adk.agents.Callbacks;
2929
import com.google.adk.agents.InvocationContext;
3030
import com.google.adk.events.Event;
31+
import com.google.adk.utils.AgentEnums.AgentOrigin;
3132
import com.google.common.collect.ImmutableList;
3233
import com.google.errorprone.annotations.CanIgnoreReturnValue;
3334
import com.google.genai.types.Content;
3435
import com.google.genai.types.CustomMetadata;
3536
import com.google.genai.types.Part;
3637
import io.a2a.client.Client;
3738
import io.a2a.client.ClientEvent;
38-
import io.a2a.client.MessageEvent;
3939
import io.a2a.client.TaskEvent;
4040
import io.a2a.client.TaskUpdateEvent;
4141
import io.a2a.spec.A2AClientException;
@@ -541,6 +541,11 @@ protected Flowable<Event> runLiveImpl(InvocationContext invocationContext) {
541541
"runLiveImpl for " + getClass() + " via A2A is not implemented.");
542542
}
543543

544+
@Override
545+
public AgentOrigin toolOrigin() {
546+
return AgentOrigin.A2A;
547+
}
548+
544549
/** Exception thrown when the agent card cannot be resolved. */
545550
public static class AgentCardResolutionError extends RuntimeException {
546551
public AgentCardResolutionError(String message) {

core/src/main/java/com/google/adk/agents/BaseAgent.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import com.google.adk.events.Event;
2626
import com.google.adk.plugins.Plugin;
2727
import com.google.adk.telemetry.Tracing;
28+
import com.google.adk.utils.AgentEnums.AgentOrigin;
2829
import com.google.common.collect.ImmutableList;
2930
import com.google.errorprone.annotations.CanIgnoreReturnValue;
3031
import com.google.errorprone.annotations.DoNotCall;
@@ -256,6 +257,15 @@ public ImmutableList<? extends AfterAgentCallback> afterAgentCallback() {
256257
return afterAgentCallback;
257258
}
258259

260+
/**
261+
* Returns the origin of the tool when this agent is used as a tool.
262+
*
263+
* @return the tool origin, defaults to "BASE_AGENT".
264+
*/
265+
public AgentOrigin toolOrigin() {
266+
return AgentOrigin.BASE_AGENT;
267+
}
268+
259269
/**
260270
* The resolved beforeAgentCallback field as a list.
261271
*

core/src/main/java/com/google/adk/models/ChatCompletionsResponse.java

Lines changed: 0 additions & 224 deletions
This file was deleted.

core/src/main/java/com/google/adk/models/LlmRegistry.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package com.google.adk.models;
1818

19+
import com.google.common.annotations.VisibleForTesting;
1920
import java.util.Map;
2021
import java.util.concurrent.ConcurrentHashMap;
2122

@@ -38,6 +39,7 @@ public interface LlmFactory {
3839
static {
3940
registerLlm("gemini-.*", modelName -> Gemini.builder().modelName(modelName).build());
4041
registerLlm("apigee/.*", modelName -> ApigeeLlm.builder().modelName(modelName).build());
42+
registerLlm("gemma-.*", modelName -> Gemini.builder().modelName(modelName).build());
4143
}
4244

4345
/**
@@ -50,6 +52,17 @@ public static void registerLlm(String modelNamePattern, LlmFactory factory) {
5052
llmFactories.put(modelNamePattern, factory);
5153
}
5254

55+
/**
56+
* Checks if the given model name matches any of the registered LLM factory patterns.
57+
*
58+
* @param modelName The model name to check.
59+
* @return {@code true} if the model name matches at least one pattern, {@code false} otherwise.
60+
*/
61+
@VisibleForTesting
62+
static boolean matchesAnyPattern(String modelName) {
63+
return llmFactories.keySet().stream().anyMatch(modelName::matches);
64+
}
65+
5366
/**
5467
* Returns an LLM instance for the given model name, using a cached or new factory-created
5568
* instance.
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
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+
* https://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+
17+
package com.google.adk.models.chat;
18+
19+
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
20+
import com.fasterxml.jackson.annotation.JsonInclude;
21+
import com.fasterxml.jackson.annotation.JsonProperty;
22+
import java.util.Map;
23+
24+
/** Shared models for Chat Completions Request and Response. */
25+
@JsonIgnoreProperties(ignoreUnknown = true)
26+
@JsonInclude(JsonInclude.Include.NON_NULL)
27+
final class ChatCompletionsCommon {
28+
29+
private ChatCompletionsCommon() {}
30+
31+
/**
32+
* See
33+
* https://developers.openai.com/api/reference/resources/chat#(resource)%20chat.completions%20%3E%20(model)%20chat_completion_message_tool_call%20%3E%20(schema)
34+
*/
35+
@JsonIgnoreProperties(ignoreUnknown = true)
36+
@JsonInclude(JsonInclude.Include.NON_NULL)
37+
static class ToolCall {
38+
/** See class definition for more details. */
39+
public Integer index;
40+
41+
/** See class definition for more details. */
42+
public String id;
43+
44+
/** See class definition for more details. */
45+
public String type;
46+
47+
/** See class definition for more details. */
48+
public Function function;
49+
50+
/** See class definition for more details. */
51+
public Custom custom;
52+
53+
/**
54+
* Used to supply additional parameters for specific models, for example:
55+
* https://ai.google.dev/gemini-api/docs/openai#thinking
56+
*/
57+
@JsonProperty("extra_content")
58+
public Map<String, Object> extraContent;
59+
}
60+
61+
/**
62+
* See
63+
* https://developers.openai.com/api/reference/resources/chat#(resource)%20chat.completions%20%3E%20(model)%20chat_completion_message_function_tool_call%20%3E%20(schema)
64+
*/
65+
@JsonIgnoreProperties(ignoreUnknown = true)
66+
@JsonInclude(JsonInclude.Include.NON_NULL)
67+
static class Function {
68+
/** See class definition for more details. */
69+
public String name;
70+
71+
/** See class definition for more details. */
72+
public String arguments; // JSON string
73+
}
74+
75+
/**
76+
* See
77+
* https://developers.openai.com/api/reference/resources/chat#(resource)%20chat.completions%20%3E%20(model)%20chat_completion_custom_tool%20%3E%20(schema)
78+
*/
79+
@JsonIgnoreProperties(ignoreUnknown = true)
80+
@JsonInclude(JsonInclude.Include.NON_NULL)
81+
static class Custom {
82+
/** See class definition for more details. */
83+
public String input;
84+
85+
/** See class definition for more details. */
86+
public String name;
87+
}
88+
}

0 commit comments

Comments
 (0)