Skip to content

Commit faadef1

Browse files
seanzhougooglecopybara-github
authored andcommitted
fix: incompatible a2a sdk changes
a. camel case to snake case b. A2ACardResolver moved to different module PiperOrigin-RevId: 789807686
1 parent bead607 commit faadef1

File tree

5 files changed

+31
-26
lines changed

5 files changed

+31
-26
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ dev = [
8181

8282
a2a = [
8383
# go/keep-sorted start
84-
"a2a-sdk>=0.2.16,<0.3.0;python_version>='3.10'",
84+
"a2a-sdk>=0.3.0,<0.4.0;python_version>='3.10'",
8585
# go/keep-sorted end
8686
]
8787

src/google/adk/a2a/logs/log_utils.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,11 @@ def build_a2a_request_log(req: SendMessageRequest) -> str:
136136
config_log = "None"
137137
if req.params.configuration:
138138
config_data = {
139-
"acceptedOutputModes": req.params.configuration.acceptedOutputModes,
139+
"accepted_output_modes": req.params.configuration.accepted_output_modes,
140140
"blocking": req.params.configuration.blocking,
141-
"historyLength": req.params.configuration.historyLength,
142-
"pushNotificationConfig": bool(
143-
req.params.configuration.pushNotificationConfig
141+
"history_length": req.params.configuration.history_length,
142+
"push_notification_config": bool(
143+
req.params.configuration.push_notification_config
144144
),
145145
}
146146
config_log = json.dumps(config_data, indent=2)

src/google/adk/agents/remote_a2a_agent.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
try:
2828
from a2a.client import A2AClient
29-
from a2a.client.client import A2ACardResolver
29+
from a2a.client.card_resolver import A2ACardResolver
3030
from a2a.types import AgentCard
3131
from a2a.types import Message as A2AMessage
3232
from a2a.types import MessageSendParams as A2AMessageSendParams

tests/unittests/a2a/logs/test_log_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ def test_request_with_parts_and_config(self):
184184
assert "Part 0:" in result
185185
assert "Part 1:" in result
186186
assert '"blocking": true' in result
187-
assert '"historyLength": 10' in result
187+
assert '"history_length": 10' in result
188188
assert '"key1": "value1"' in result
189189

190190
def test_request_without_parts(self):

tests/unittests/agents/test_remote_a2a_agent.py

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,10 @@
2020
from unittest.mock import Mock
2121
from unittest.mock import patch
2222

23-
# Try to import a2a library - will fail on Python < 3.10
23+
import pytest
24+
25+
# Check if A2A dependencies are available
26+
A2A_AVAILABLE = True
2427
try:
2528
from a2a.types import AgentCapabilities
2629
from a2a.types import AgentCard
@@ -32,32 +35,34 @@
3235
from google.adk.agents.remote_a2a_agent import A2A_METADATA_PREFIX
3336
from google.adk.agents.remote_a2a_agent import AgentCardResolutionError
3437
from google.adk.agents.remote_a2a_agent import RemoteA2aAgent
35-
36-
A2A_AVAILABLE = True
3738
except ImportError:
3839
A2A_AVAILABLE = False
40+
3941
# Create dummy classes to prevent NameError during test collection
40-
AgentCapabilities = type("AgentCapabilities", (), {})
41-
AgentCard = type("AgentCard", (), {})
42-
AgentSkill = type("AgentSkill", (), {})
43-
A2AMessage = type("A2AMessage", (), {})
44-
SendMessageSuccessResponse = type("SendMessageSuccessResponse", (), {})
45-
A2ATask = type("A2ATask", (), {})
42+
class DummyTypes:
43+
pass
44+
45+
AgentCapabilities = DummyTypes()
46+
AgentCard = DummyTypes()
47+
AgentSkill = DummyTypes()
48+
A2AMessage = DummyTypes()
49+
SendMessageSuccessResponse = DummyTypes()
50+
A2ATask = DummyTypes()
51+
InvocationContext = DummyTypes()
52+
RemoteA2aAgent = DummyTypes()
53+
AgentCardResolutionError = Exception
54+
A2A_METADATA_PREFIX = ""
55+
56+
# Skip all tests in this module if Python < 3.10 or A2A dependencies are not available
57+
pytestmark = pytest.mark.skipif(
58+
sys.version_info < (3, 10) or not A2A_AVAILABLE,
59+
reason="A2A requires Python 3.10+ and A2A dependencies must be available",
60+
)
4661

4762

4863
from google.adk.events.event import Event
4964
from google.adk.sessions.session import Session
5065
import httpx
51-
import pytest
52-
53-
# Skip all tests in this module if Python < 3.10 or a2a library is not available
54-
pytestmark = pytest.mark.skipif(
55-
sys.version_info < (3, 10) or not A2A_AVAILABLE,
56-
reason=(
57-
"a2a library requires Python 3.10+ and is not available, skipping"
58-
" RemoteA2aAgent tests"
59-
),
60-
)
6166

6267

6368
# Helper function to create a proper AgentCard for testing

0 commit comments

Comments
 (0)