Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,19 @@
package com.google.adk.a2a;
/*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.adk.a2a.agent;

import static com.google.common.base.Strings.nullToEmpty;

Expand Down Expand Up @@ -44,26 +59,21 @@
import org.slf4j.LoggerFactory;

/**
* Agent that communicates with a remote A2A agent via A2A client.
*
* <p>This agent supports multiple ways to specify the remote agent:
* Agent that communicates with a remote A2A agent via an A2A client.
*
* <ol>
* <li>Direct AgentCard object
* <li>URL to agent card JSON
* <li>File path to agent card JSON
* </ol>
* <p>The remote agent can be specified directly by providing an {@link AgentCard} to the builder,
* or it can be resolved automatically using the provided A2A client.
*
* <p>The agent handles:
* <p>Key responsibilities of this agent include:
*
* <ul>
* <li>Agent card resolution and validation
* <li>A2A message conversion and error handling
* <li>Session state management across requests
* <li>Converting ADK session history events into A2A requests ({@link io.a2a.spec.Message})
* <li>Handling streaming and non-streaming responses from the A2A client
* <li>Buffering and aggregating streamed response chunks into ADK {@link
* com.google.adk.events.Event}s
* <li>Converting A2A client responses back into ADK format
* </ul>
*
* <p>**EXPERIMENTAL:** Subject to change, rename, or removal in any future patch release. Do not
* use in production code.
*/
public class RemoteA2AAgent extends BaseAgent {

Expand Down
15 changes: 15 additions & 0 deletions a2a/src/main/java/com/google/adk/a2a/common/A2AClientError.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.adk.a2a.common;

/** Exception thrown when the A2A client encounters an error. */
Expand Down
15 changes: 15 additions & 0 deletions a2a/src/main/java/com/google/adk/a2a/common/A2AMetadata.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.adk.a2a.common;

/** Constants and utilities for A2A metadata keys. */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.adk.a2a.common;

/** Exception thrown when the the genai class has an empty field. */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.adk.a2a.converters;

/** Enum for the type of A2A DataPart metadata. */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.adk.a2a.converters;

import static com.google.common.collect.ImmutableList.toImmutableList;
Expand All @@ -13,12 +28,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Converter for ADK Events to A2A Messages.
*
* <p>**EXPERIMENTAL:** Subject to change, rename, or removal in any future patch release. Do not
* use in production code.
*/
/** Converter for ADK Events to A2A Messages. */
public final class EventConverter {
private static final Logger logger = LoggerFactory.getLogger(EventConverter.class);

Expand Down
22 changes: 16 additions & 6 deletions a2a/src/main/java/com/google/adk/a2a/converters/PartConverter.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.adk.a2a.converters;

import static com.google.common.collect.ImmutableList.toImmutableList;
Expand Down Expand Up @@ -32,12 +47,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Utility class for converting between Google GenAI Parts and A2A DataParts.
*
* <p>**EXPERIMENTAL:** Subject to change, rename, or removal in any future patch release. Do not
* use in production code.
*/
/** Utility class for converting between Google GenAI Parts and A2A DataParts. */
public final class PartConverter {

private static final Logger logger = LoggerFactory.getLogger(PartConverter.class);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.adk.a2a.converters;

import static com.google.common.collect.ImmutableList.toImmutableList;
Expand Down Expand Up @@ -27,12 +42,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Utility for converting ADK events to A2A spec messages (and back).
*
* <p>**EXPERIMENTAL:** Subject to change, rename, or removal in any future patch release. Do not
* use in production code.
*/
/** Utility for converting ADK events to A2A spec messages (and back). */
public final class ResponseConverter {
private static final Logger logger = LoggerFactory.getLogger(ResponseConverter.class);
private static final ImmutableSet<TaskState> PENDING_STATES =
Expand Down
22 changes: 16 additions & 6 deletions a2a/src/main/java/com/google/adk/a2a/executor/AgentExecutor.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.adk.a2a.executor;

import static java.util.Objects.requireNonNull;
Expand Down Expand Up @@ -44,12 +59,7 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Implementation of the A2A AgentExecutor interface that uses ADK to execute agent tasks.
*
* <p>**EXPERIMENTAL:** Subject to change, rename, or removal in any future patch release. Do not
* use in production code.
*/
/** Implementation of the A2A AgentExecutor interface that uses ADK to execute agent tasks. */
public class AgentExecutor implements io.a2a.server.agentexecution.AgentExecutor {
private static final Logger logger = LoggerFactory.getLogger(AgentExecutor.class);
private static final String USER_ID_PREFIX = "A2A_USER_";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.adk.a2a.executor;

import com.google.adk.a2a.executor.Callbacks.AfterEventCallback;
Expand Down
15 changes: 15 additions & 0 deletions a2a/src/main/java/com/google/adk/a2a/executor/Callbacks.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
/*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.adk.a2a.executor;

import com.google.adk.events.Event;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.google.adk.a2a;
package com.google.adk.a2a.agent;

import static com.google.common.truth.Truth.assertThat;
import static java.util.concurrent.TimeUnit.SECONDS;
Expand Down
2 changes: 1 addition & 1 deletion contrib/samples/a2a_basic/A2AAgent.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.example.a2a_basic;

import com.google.adk.a2a.RemoteA2AAgent;
import com.google.adk.a2a.agent.RemoteA2AAgent;
import com.google.adk.agents.BaseAgent;
import com.google.adk.agents.LlmAgent;
import com.google.adk.tools.FunctionTool;
Expand Down