Skip to content

Commit d0b3b5d

Browse files
seanzhougooglecopybara-github
authored andcommitted
chore: add experimental messages for a2a related API
PiperOrigin-RevId: 793812544
1 parent d674178 commit d0b3b5d

File tree

8 files changed

+74
-20
lines changed

8 files changed

+74
-20
lines changed

src/google/adk/a2a/converters/event_converter.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
from ...agents.invocation_context import InvocationContext
3939
from ...events.event import Event
4040
from ...flows.llm_flows.functions import REQUEST_EUC_FUNCTION_CALL_NAME
41-
from ...utils.feature_decorator import experimental
41+
from ..experimental import a2a_experimental
4242
from .part_converter import A2A_DATA_PART_METADATA_IS_LONG_RUNNING_KEY
4343
from .part_converter import A2A_DATA_PART_METADATA_TYPE_FUNCTION_CALL
4444
from .part_converter import A2A_DATA_PART_METADATA_TYPE_KEY
@@ -224,7 +224,7 @@ def convert_a2a_task_to_event(
224224
raise
225225

226226

227-
@experimental
227+
@a2a_experimental
228228
def convert_a2a_message_to_event(
229229
a2a_message: Message,
230230
author: Optional[str] = None,
@@ -320,7 +320,7 @@ def convert_a2a_message_to_event(
320320
raise RuntimeError(f"Failed to convert message: {e}") from e
321321

322322

323-
@experimental
323+
@a2a_experimental
324324
def convert_event_to_a2a_message(
325325
event: Event, invocation_context: InvocationContext, role: Role = Role.agent
326326
) -> Optional[Message]:
@@ -471,7 +471,7 @@ def _create_status_update_event(
471471
)
472472

473473

474-
@experimental
474+
@a2a_experimental
475475
def convert_event_to_a2a_events(
476476
event: Event,
477477
invocation_context: InvocationContext,

src/google/adk/a2a/converters/part_converter.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939

4040
from google.genai import types as genai_types
4141

42-
from ...utils.feature_decorator import experimental
42+
from ..experimental import a2a_experimental
4343

4444
logger = logging.getLogger('google_adk.' + __name__)
4545

@@ -51,7 +51,7 @@
5151
A2A_DATA_PART_METADATA_TYPE_EXECUTABLE_CODE = 'executable_code'
5252

5353

54-
@experimental
54+
@a2a_experimental
5555
def convert_a2a_part_to_genai_part(
5656
a2a_part: a2a_types.Part,
5757
) -> Optional[genai_types.Part]:
@@ -140,7 +140,7 @@ def convert_a2a_part_to_genai_part(
140140
return None
141141

142142

143-
@experimental
143+
@a2a_experimental
144144
def convert_genai_part_to_a2a_part(
145145
part: genai_types.Part,
146146
) -> Optional[a2a_types.Part]:

src/google/adk/a2a/converters/request_converter.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
from google.genai import types as genai_types
3131

3232
from ...runners import RunConfig
33-
from ...utils.feature_decorator import experimental
33+
from ..experimental import a2a_experimental
3434
from .part_converter import convert_a2a_part_to_genai_part
3535

3636

@@ -47,7 +47,7 @@ def _get_user_id(request: RequestContext) -> str:
4747
return f'A2A_USER_{request.context_id}'
4848

4949

50-
@experimental
50+
@a2a_experimental
5151
def convert_a2a_request_to_adk_run_args(
5252
request: RequestContext,
5353
) -> dict[str, Any]:

src/google/adk/a2a/executor/a2a_agent_executor.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,23 +50,23 @@
5050
from pydantic import BaseModel
5151
from typing_extensions import override
5252

53-
from ...utils.feature_decorator import experimental
5453
from ..converters.event_converter import convert_event_to_a2a_events
5554
from ..converters.request_converter import convert_a2a_request_to_adk_run_args
5655
from ..converters.utils import _get_adk_metadata_key
56+
from ..experimental import a2a_experimental
5757
from .task_result_aggregator import TaskResultAggregator
5858

5959
logger = logging.getLogger('google_adk.' + __name__)
6060

6161

62-
@experimental
62+
@a2a_experimental
6363
class A2aAgentExecutorConfig(BaseModel):
6464
"""Configuration for the A2aAgentExecutor."""
6565

6666
pass
6767

6868

69-
@experimental
69+
@a2a_experimental
7070
class A2aAgentExecutor(AgentExecutor):
7171
"""An AgentExecutor that runs an ADK Agent against an A2A request and
7272
publishes updates to an event queue.

src/google/adk/a2a/executor/task_result_aggregator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
from a2a.types import TaskState
2020
from a2a.types import TaskStatusUpdateEvent
2121

22-
from ...utils.feature_decorator import experimental
22+
from ..experimental import a2a_experimental
2323

2424

25-
@experimental
25+
@a2a_experimental
2626
class TaskResultAggregator:
2727
"""Aggregates the task status updates and provides the final task state."""
2828

src/google/adk/a2a/experimental.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
"""A2A specific experimental decorator with custom warning message."""
16+
17+
from __future__ import annotations
18+
19+
from google.adk.utils.feature_decorator import _make_feature_decorator
20+
21+
a2a_experimental = _make_feature_decorator(
22+
label="EXPERIMENTAL",
23+
default_message=(
24+
"ADK Implementation for A2A support (A2aAgentExecutor, RemoteA2aAgent "
25+
"and corresponding supporting components etc.) is in experimental mode "
26+
"and is subjected to breaking changes. A2A protocol and SDK are"
27+
"themselves not experimental. Once it's stable enough the experimental "
28+
"mode will be removed. Your feedback is welcome."
29+
),
30+
)
31+
"""Mark a class or function as experimental A2A feature.
32+
33+
This decorator shows a specific warning message for A2A functionality,
34+
indicating that the API is experimental and subject to breaking changes.
35+
36+
Sample usage:
37+
38+
```
39+
# Use with default A2A experimental message
40+
@a2a_experimental
41+
class A2AExperimentalClass:
42+
pass
43+
44+
# Use with custom message (overrides default A2A message)
45+
@a2a_experimental("Custom A2A experimental message.")
46+
def a2a_experimental_function():
47+
pass
48+
49+
# Use with empty parentheses (same as default A2A message)
50+
@a2a_experimental()
51+
class AnotherA2AClass:
52+
pass
53+
```
54+
"""

src/google/adk/a2a/utils/agent_card_builder.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,10 @@
4141
from ...agents.parallel_agent import ParallelAgent
4242
from ...agents.sequential_agent import SequentialAgent
4343
from ...tools.example_tool import ExampleTool
44-
from ...utils.feature_decorator import experimental
44+
from ..experimental import a2a_experimental
4545

4646

47-
@experimental
47+
@a2a_experimental
4848
class AgentCardBuilder:
4949
"""Builder class for creating agent cards from ADK agents.
5050

src/google/adk/agents/remote_a2a_agent.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,14 @@
5858
from ..a2a.converters.event_converter import convert_a2a_task_to_event
5959
from ..a2a.converters.event_converter import convert_event_to_a2a_message
6060
from ..a2a.converters.part_converter import convert_genai_part_to_a2a_part
61+
from ..a2a.experimental import a2a_experimental
6162
from ..a2a.logs.log_utils import build_a2a_request_log
6263
from ..a2a.logs.log_utils import build_a2a_response_log
6364
from ..agents.invocation_context import InvocationContext
6465
from ..events.event import Event
6566
from ..flows.llm_flows.contents import _convert_foreign_event
6667
from ..flows.llm_flows.contents import _is_other_agent_reply
6768
from ..flows.llm_flows.functions import find_matching_function_call
68-
from ..utils.feature_decorator import experimental
6969
from .base_agent import BaseAgent
7070

7171
__all__ = [
@@ -83,21 +83,21 @@
8383
logger = logging.getLogger("google_adk." + __name__)
8484

8585

86-
@experimental
86+
@a2a_experimental
8787
class AgentCardResolutionError(Exception):
8888
"""Raised when agent card resolution fails."""
8989

9090
pass
9191

9292

93-
@experimental
93+
@a2a_experimental
9494
class A2AClientError(Exception):
9595
"""Raised when A2A client operations fail."""
9696

9797
pass
9898

9999

100-
@experimental
100+
@a2a_experimental
101101
class RemoteA2aAgent(BaseAgent):
102102
"""Agent that communicates with a remote A2A agent via A2A client.
103103

0 commit comments

Comments
 (0)